# Headers & Permissions

## Required Headers

All endpoints under `/api/v1/**` require the following headers:

| Header           | Required | Description                                                                              |
| ---------------- | -------- | ---------------------------------------------------------------------------------------- |
| `x-api-key`      | Yes      | Partner API Key.                                                                         |
| `x-api-ts`       | Yes      | Unix millisecond timestamp. Server allows ≤ **45 seconds** drift from current UTC time.  |
| `x-api-nonce`    | Yes      | Random string. Must be unique per API Key within the 45-second window. UUID recommended. |
| `x-api-sign`     | Yes      | HMAC-SHA256 signature, hex format. Case-insensitive.                                     |
| `x-api-chain-id` | Yes      | Chain ID for the current request.                                                        |
| `x-api-p`        | Yes      | Product type for the current request.                                                    |

## Supported Chain IDs

| Value      | Chain            |
| ---------- | ---------------- |
| `1`        | Ethereum Mainnet |
| `143`      | Monad Mainnet    |
| `11155111` | Ethereum Sepolia |
| `10143`    | Monad Testnet    |
| `84532`    | Base Sepolia     |

## Supported Product Types

| Value         | Description           |
| ------------- | --------------------- |
| `MondayTrade` | Monday Trade product. |
| `Anchored`    | Anchored product.     |

{% hint style="info" %}
Enum values are case-sensitive. `x-api-p` uses exact matching — only `MondayTrade` and `Anchored` are accepted.
{% endhint %}

## API Key Validation Rules

| Check        | Rule                                                                                        |
| ------------ | ------------------------------------------------------------------------------------------- |
| API Key      | Must exist and be in `active` status.                                                       |
| Expiry       | `expires_at` is null or later than current time.                                            |
| IP Whitelist | Must be configured. Client IP must exactly match one entry. CIDR matching is NOT supported. |
| Scope        | Must have a matching `chainId + productType + access` permission.                           |

### Client IP Resolution Priority

1. First non-empty IP in `X-Forwarded-For`
2. `X-Real-IP`
3. TCP connection `remoteAddr`

## Permission Levels

| access      | Allowed Operations                |
| ----------- | --------------------------------- |
| `READ_ONLY` | `GET` requests only.              |
| `WRITABLE`  | `GET`, `POST`, `DELETE` requests. |


---

# 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-en/authentication/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.
