> For the complete documentation index, see [llms.txt](https://docs.metasleuth.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.metasleuth.io/blocksec-aml-api/introduction/response-format.md).

# Response Format

A business API request is successful only when the HTTP status is **200** and the top-level JSON `code` is **200000**. Check both values; an HTTP 200 response alone does not indicate success.

## Response fields

| Field        | Description                                                                                                                   |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `request_id` | Request identifier, when available. Include it when contacting support. It may be empty.                                      |
| `code`       | Integer business status code. `200000` indicates success. This is separate from address label codes and risk indicator codes. |
| `message`    | Description of the result. Use the business code, rather than matching message text, to handle errors.                        |
| `data`       | Endpoint-specific result data. This field may be absent from error responses.                                                 |
| `cause`      | Additional error details that may be included in an Address Label API response. Optional.                                     |

For example, an invalid signature returns HTTP 401:

```json
{
  "request_id": "example-request-id",
  "code": 401002,
  "message": "Invalid request signature"
}
```

Not every error returns JSON or a business code. Handle empty and non-JSON error responses as well.

## Authentication and security errors

The following codes apply to registered Address Label API and Risk Score API business endpoints.

| Code     | HTTP | Message                                                                 | Recommended action                                                                                                                                                                                            |
| -------- | ---- | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `403001` | 403  | API security setup is required. Enable IP allowlist or request signing. | Open API Security Settings and complete the required setup shown on the API management page.                                                                                                                  |
| `403002` | 403  | Request IP is not allowed                                               | Check your application's public outbound IP and the configured IP Allowlist.                                                                                                                                  |
| `401001` | 401  | Request signing is not configured                                       | Configure Request Signing and ensure an available secret exists for this service.                                                                                                                             |
| `401002` | 401  | Invalid request signature                                               | Check all signature headers, secret, method, full path, normalized query and exact body bytes. Incomplete signature headers, invalid signature length or a nonce longer than 256 bytes also cause this error. |
| `401003` | 401  | Invalid request timestamp                                               | Use a Unix timestamp in seconds. Synchronize your clock; the timestamp must be within 5 minutes of server time.                                                                                               |
| `401004` | 401  | Request has already been used                                           | Generate a fresh nonce and recalculate the signature before retrying.                                                                                                                                         |
| `413001` | 413  | Request body is too large                                               | Keep the request body within 16 MiB and check for interrupted or incomplete uploads.                                                                                                                          |

If both IP Allowlist and Request Signing are enabled, requests must pass both checks. Sending any non-empty signature header also triggers signature verification, even if Request Signing is not enabled. The response reports the first security check that fails.

Requests rejected by security checks are not forwarded for business processing and are not charged.

## Service errors

| Code     | HTTP | Message                                     | Recommended action                                                                                                  |
| -------- | ---- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `500001` | 500  | API security policy is unavailable          | Retry with bounded exponential backoff. Contact support if the problem persists.                                    |
| `500002` | 500  | API subscription information is unavailable | Retry with bounded exponential backoff. Contact support if the problem persists.                                    |
| `500003` | 500  | Request signing verification is unavailable | Retry with bounded exponential backoff, using a fresh nonce and signature. Contact support if the problem persists. |
| `502001` | 502  | Invalid upstream response                   | Contact support with the request details and request ID, if available.                                              |
| `502002` | 502  | Failed to receive upstream response         | Retry with bounded exponential backoff. Contact support if the problem persists.                                    |

## Existing business codes

Existing codes remain supported. Message wording may vary by service or deployed version; use `code` to identify the error.

| Code     | Description                                                                          | Recommended action                                                                                                                          |
| -------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `200000` | Success                                                                              | Read the endpoint-specific `data`.                                                                                                          |
| `400001` | Unauthorized operation                                                               | Check your access permissions. This is separate from the security-specific codes above.                                                     |
| `400002` | Request rate is too high. Please try again later.                                    | Reduce request frequency and back off. Rate-limit responses use HTTP 429.                                                                   |
| `400004` | Invalid params                                                                       | Check the endpoint's request schema.                                                                                                        |
| `400005` | User does not exist                                                                  | Legacy code retained for compatibility.                                                                                                     |
| `400006` | Server busy                                                                          | Retry with bounded exponential backoff.                                                                                                     |
| `400007` | Invalid API key                                                                      | Check the key, service and validity. The returned message may be `Invalid api-key`.                                                         |
| `400008` | Invalid auth format                                                                  | Legacy code retained for compatibility; check authentication headers.                                                                       |
| `400009` | The API key is expired                                                               | Check your API access and obtain valid credentials.                                                                                         |
| `400010` | Route not found                                                                      | Check the base URL and endpoint path. The message may be `Router not found!` or `404 not found!`.                                           |
| `400011` | Invalid address. Please ensure that you have provided the correct chain and address. | Check the address and its chain.                                                                                                            |
| `400012` | Daily request limit exceeded. Please try again tomorrow.                             | Check remaining quota and the next reset time. Quota-limit responses use HTTP 429.                                                          |
| `400013` | Unsupported chain                                                                    | Check `chain_id`. The current message is `Invalid params. Unsupported chain id`; older documentation refers to a chain name.                |
| `400014` | Method not allowed                                                                   | Check the HTTP method. A response may instead have HTTP 405 with no business code.                                                          |
| `400015` | The number of addresses in a single request exceeds the limit.                       | Reduce the batch size. For multi-chain label queries, the limit considers the number of input addresses multiplied by the number of chains. |
| `500000` | Internal error                                                                       | Retry with bounded exponential backoff. Contact support if the problem persists.                                                            |

## Rate limits and quota

Rate-limit responses use HTTP **429** with `400002` for request frequency or `400012` for insufficient daily quota. If remaining quota cannot cover an entire batch, the request returns no business data and is not partially charged.

Where present, the following headers describe daily quota:

| Header                  | Meaning                                                                 |
| ----------------------- | ----------------------------------------------------------------------- |
| `X-RateLimit-Limit`     | Daily quota limit.                                                      |
| `X-RateLimit-Used`      | Quota used.                                                             |
| `X-RateLimit-Remaining` | Remaining quota.                                                        |
| `X-RateLimit-Reset`     | Next reset time: the next UTC midnight, as a Unix timestamp in seconds. |
| `X-RateLimit-Cost`      | Quota charged for this response.                                        |

Authentication rejections do not include quota headers. The service does not currently return `Retry-After`. Supported-chain and risk-indicator list endpoints still require authentication, applicable security checks and request-rate compliance, even when they have no quota cost.

## Retry safely

* Generate a new timestamp, nonce and signature for every signed retry.
* A nonce prevents replay; it is not an idempotency key. A successful retry may be charged again.
* Do not retry invalid credentials, invalid signatures, disallowed IPs or invalid parameters without correcting the cause.
* Use bounded exponential backoff for transient service errors. If a response is lost or the outcome is uncertain, do not assume that the original request was not processed or charged.

## Errors without a business code

Some errors have only an HTTP status and an empty or non-JSON response body.

| HTTP | Possible cause                                                       | Recommended action                                        |
| ---- | -------------------------------------------------------------------- | --------------------------------------------------------- |
| 404  | Unknown endpoint.                                                    | Check the base URL and path.                              |
| 405  | Unsupported method.                                                  | Check the endpoint method and `Allow` header, if present. |
| 413  | Request rejected before signature verification because of body size. | Reduce the request body size.                             |
| 500  | Unexpected server error.                                             | Use bounded retries and contact support if it persists.   |
| 502  | Failure communicating with the API's backing service.                | Use bounded retries and contact support if it persists.   |
| 503  | Timeout or temporary service unavailability.                         | Retry with bounded exponential backoff.                   |

When contacting [support](mailto:ms_support@blocksec.com), include the endpoint, HTTP method, UTC request time, HTTP status, business code and request ID, if available. Do not send your API key, secret, signature or authorization headers. Share only the endpoint path without sensitive query values; redact credentials, personal information and sensitive request/response data from logs, screenshots and attachments.
