> ## Documentation Index
> Fetch the complete documentation index at: https://docs.partners.inra.co.th/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> The /v1 error envelope, the catalogue of stable codes, and how to retry.

Every `/v1` error uses a small envelope with a stable `code`, a human `message`, and a `request_id`. The same `code` is used in JSON and XML. Every response also carries the `X-Request-Id` header — please include it when you email [inraasth@inra.co.th](mailto:inraasth@inra.co.th).

JSON:

```json theme={null}
{
  "error": {
    "code": "company_not_found",
    "message": "No company matched the request.",
    "request_id": "..."
  }
}
```

XML:

```xml theme={null}
<error xmlns="https://partners.inra.co.th/schema/v1">
  <code>company_not_found</code>
  <message>No company matched the request.</message>
  <request_id>...</request_id>
</error>
```

The OAuth token endpoint is the exception: it uses standard OAuth error JSON (for example `invalid_client`), not this envelope.

## Codes

| HTTP | `code` | Typical cause |
| - | - | - |
| 401 | `unauthorized` | Missing, malformed, or expired Bearer token |
| 403 | `insufficient_scope` | The token does not include the scope for this route |
| 403 | `client_not_configured` | This production client is not yet enabled for the report type you requested |
| 404 | `company_not_found` | No company in this environment matches the id or the search did not apply |
| 404 | `report_not_available` | The company exists, but no database report is on file |
| 404 | `not_found` | The order does not exist, or it belongs to another client |
| 406 | `not_acceptable` | `Accept` and `format` disagree |
| 406 | `pdf_not_available` | PDF is not offered in v1; ask for JSON or XML |
| 409 | `order_not_completed` | You asked for a report while the order is still `Active` |
| 409 | `order_cancelled` | The order was cancelled; see `cancellation` on the order |
| 410 | `company_retired` | This production `company_id` has been retired and will not be reused |
| 422 | `validation_error` | A parameter or body field failed validation |
| 422 | `callback_url_not_allowed` | No callback URL is registered, or the test URL's host is not allowed |
| 429 | `rate_limited` | You exceeded the per-minute quota; wait for `Retry-After` |
| 503 | `service_unavailable` | Temporary unavailability (for example the company file or callback path). Wait for `Retry-After` |
| 503 | `order_failed` | The order could not be queued. No charge was made. Retry later |
| 500 | `internal_error` | An unexpected error. Send us the `request_id` |

A `staging_restriction` code exists in the catalogue for environment-specific constraints; you should not see it on the public sandbox or production hosts.

## Retries

* Honour `Retry-After` on `429` and `503`.
* Retry `order_failed` and `service_unavailable`; do not retry `company_retired`, `order_cancelled`, or `validation_error` without changing the request.
* Idempotency for a retried report order is not expressed as a client key in v1. Use your `reference` to recognise a duplicate on your side, and email [inraasth@inra.co.th](mailto:inraasth@inra.co.th) if a production retry may have created two orders.

Default per-client rate limits are described in [Authentication](https://docs.partners.inra.co.th/guides/authentication.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.