# 请求头与权限

## 必要请求头

`/api/v1/**` 下的所有接口都需要以下请求头：

| Header           | 必填 | 说明                                         |
| ---------------- | -- | ------------------------------------------ |
| `x-api-key`      | 是  | 合作方 API Key。                               |
| `x-api-ts`       | 是  | Unix 毫秒时间戳。服务端允许与当前 UTC 时间相差 ≤ **45 秒**。   |
| `x-api-nonce`    | 是  | 随机字符串。同一个 API Key 在 45 秒窗口内不可重复。建议使用 UUID。 |
| `x-api-sign`     | 是  | HMAC-SHA256 签名，hex 格式。大小写不敏感。              |
| `x-api-chain-id` | 是  | 当前请求使用的链 ID。                               |
| `x-api-p`        | 是  | 当前请求使用的产品类型。                               |

## 支持的链 ID

| 值          | 链                |
| ---------- | ---------------- |
| `1`        | Ethereum Mainnet |
| `143`      | Monad Mainnet    |
| `11155111` | Ethereum Sepolia |
| `10143`    | Monad Testnet    |
| `84532`    | Base Sepolia     |

## 支持的产品类型

| 值             | 说明               |
| ------------- | ---------------- |
| `MondayTrade` | Monday Trade 产品。 |
| `Anchored`    | Anchored 产品。     |

{% hint style="info" %}
枚举值大小写敏感。`x-api-p` 使用精确匹配，只接受 `MondayTrade` 和 `Anchored`。
{% endhint %}

## API Key 校验规则

| 检查项     | 规则                                           |
| ------- | -------------------------------------------- |
| API Key | 必须存在且状态为 `active`。                           |
| 过期时间    | `expires_at` 为空或晚于当前时间。                      |
| IP 白名单  | 必须配置，且客户端 IP 必须与白名单中的某一项完全一致。不支持 CIDR 匹配。    |
| Scope   | 必须存在匹配 `chainId + productType + access` 的权限。 |

### 客户端 IP 取值优先级

1. `X-Forwarded-For` 的第一个非空 IP
2. `X-Real-IP`
3. TCP 连接的 `remoteAddr`

## 权限级别

| access      | 可调用接口                        |
| ----------- | ---------------------------- |
| `READ_ONLY` | 仅允许 `GET` 请求。                |
| `WRITABLE`  | 允许 `GET`、`POST`、`DELETE` 请求。 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.anchored.finance/trading-api-docs-zh/jian-quan/headers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
