> This page is for version v1 (default).
> For other versions, use one of these documentation indexes:
> - v1 (default): https://docs.butterix.com/llms.txt
> - v0: https://docs.butterix.com/v0/llms.txt

> For the MDX source of any page, append .mdx to the page URL.
> For a complete documentation index, see https://docs.butterix.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.butterix.com/_mcp/server.
> If something on this page is wrong or missing, POST JSON {"page": "<page URL>", "message": "<what is wrong>"} to https://docs.butterix.com/_biti/feedback/agent.

# API 试调代理

`POST /_biti/proxy`

API 参考页的「试一试」通过它转发请求，避免浏览器跨域限制。为防止被滥用为开放代理：

- 只允许站点 OpenAPI 规范中声明过的 `servers` 源站，其他地址返回 403；
- 托管平台上拒绝解析到内网、回环地址的主机；
- 剥离 `Cookie`、`Host` 等头，不跟随重定向，响应体最多 2 MB，30 秒超时；
- 每个 IP 每分钟最多 60 次。

Base URL: https://butterix-sites.butterix.com

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `url` | string | yes |  |
| `method` | string | yes |  |
| `headers` | map from strings to strings | no |  |
| `body` | string | no |  |

## Example request

```bash
curl -X POST https://butterix-sites.butterix.com/_biti/proxy \
     -H "Content-Type: application/json" \
     -d '{
         "url": "https://api.butterix.com/v1/whoami",
         "method": "GET"
       }'
```

## Responses

### 200

目标服务的响应（无论其状态码如何）

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `status` | integer | no |  |
| `statusText` | string | no |  |
| `headers` | map from strings to strings | no |  |
| `body` | string | no |  |
| `truncated` | boolean | no |  |
| `size` | integer | no |  |
| `timeMs` | integer | no |  |

### 403

目标主机未在规范中声明，或解析到内网地址

Content type: `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | string | yes | 人类可读的错误信息 |
| `code` | string | no | 机器可读的错误码（部分接口提供） |

### Example response (200)

```json
{
  "status": 200,
  "statusText": "OK",
  "headers": {
    "key": "string"
  },
  "body": "string",
  "truncated": true,
  "size": 1,
  "timeMs": 84
}
```
