> ## 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.

# Orders and callbacks

> How database and offline orders move through status values, how to poll, and how signed callbacks are delivered.

Every report request becomes an **order** that belongs to your client. You can always read your own orders; you cannot read another client's.

## Kinds of order

| Kind | How you place it | When the report is ready |
| - | - | - |
| Database | `POST /v1/database-reports` | Immediately, if a report is on file. The response includes the report. |
| Offline | `POST /v1/offline-reports` or `POST /v1/offline-reports/by-details` | Later. The place-order response is `202 Accepted` with status `Active` and no report. |

In the sandbox, a database order never reaches INRA's head-office system and is not billed. An offline sandbox order completes automatically after a short delay with a sample report (or is cancelled if your `reference` starts with `test-cancel`).

In production, both kinds are real orders and may be billed. Offline orders are reviewed by INRA staff first, for example to catch a repeat order for the same company within an agreed period, and may be cancelled instead of completed.

## Status values

| Status | `status_code` | Meaning |
| - | - | - |
| `Active` | `0` | The order is in progress. Typical for a new offline order. |
| `Completed` | `1` | The report is available. Download it from the order, or from `GET /v1/orders/{order_id}/report`. |
| `Cancelled` | `2` | The order will not be fulfilled. See `cancellation` for the reason. |

A database order is created already `Completed` (or the request fails and no order is stored). An offline order stays `Active` until it is completed or cancelled.

## Polling

You can:

* `GET /v1/orders/{order_id}` for a single order
* `GET /v1/orders?status=completed&since=...` to pick up finished work, and follow `next_cursor` for later pages

If you download `GET /v1/orders/{order_id}/report` while the order is still `Active`, the API returns `409` with the code `order_not_completed`. If it was cancelled, the code is `order_cancelled`.

## Callbacks

INRA can register **one callback URL per client**. You cannot set a URL per order, and you cannot change the registered URL through the API. When you have a URL, email it to [inraasth@inra.co.th](mailto:inraasth@inra.co.th); INRA will review it and configure the subscription (and a signing secret) for you.

Each callback is an HTTPS `POST` with a small JSON body. Typical event types include a ping, order identification (when an offline-by-details order receives a `company_id`), completion, and cancellation. The body carries `event_id`, `event_type`, `created_at`, `environment`, and `data` with `order_id`, `status`, and `links`.

Verify every callback:

* `X-INRA-Signature: v1=<hex>` must equal HMAC-SHA256 of `secret` over `<X-INRA-Timestamp>.<raw body>`
* Reject timestamps older than five minutes
* De-duplicate on `X-INRA-Event-Id`

Answer with a `2xx` within 10 seconds. Other answers are retried with backoff for about 35 hours.

`GET /v1/webhook` shows the URL INRA configured and the last delivery. `POST /v1/webhook/test` queues a signed `webhook.ping` so you can check your receiver. The full request shape and a verification example are in [Callbacks](https://docs.partners.inra.co.th/guides/webhooks.md).


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