You don’t have to do anything special. By default these endpoints behave
like any other: you
POST and get { "data": … } back. The options below
are opt-in, for when you’d rather not hold a connection open.Which endpoints are async?
These lookups run as async jobs:- Policía Nacional, criminal records
- SICAAC, insolvency cases
- Superfinanciera, complaints
- RREE, foreigner cards
- SUNAT, RUC taxpayers
The three ways to get a result
| Mode | You send | You get back |
|---|---|---|
| Wait inline (default) | nothing extra, or Prefer: wait=N | 200 { data } if it finishes in time, else 202 |
| Poll | Prefer: wait=0 | 202 now, then GET /jobs/:id until done |
| Callback | callback_url in the body | 202 now, then a POST to your URL when done |
Mode 1: Wait inline (default)
Just call the endpoint. The request holds open until the job finishes (up to 55 seconds) and returns the result in the usual{ data } shape, identical
to a synchronous endpoint.
Prefer: wait=N
header (seconds, clamped to 55):
200: finished. Body is{ "data": … }, same as the synchronous shape.202: not finished within the wait. Body is a job envelope; follow itsstatus_urlto poll. TheX-Job-Idheader carries the job id.
Always handle both
200 and 202. A 202 is not an error; it just means
“still working, come back for it.”Mode 2: Poll
SendPrefer: wait=0 to get a 202 immediately, then GET the job’s
status_url until it reaches a terminal state.
GET /jobs/:id always returns 200 with the envelope.
While the job is still running it includes a Retry-After header (seconds);
use it to pace your polling. Jobs are scoped to your organization; a job
belonging to another org reads as 404.
Mode 3: Callback (webhook)
Include acallback_url in the request body. You get a 202 right away, and
Croma POSTs the result to your URL once the job finishes, with no polling.
callback_url must be an absolute HTTPS URL on a public host (localhost and
private ranges are rejected). When the job finishes, Croma sends a POST to it:
- Body: the same job envelope as the poll endpoint.
x-croma-job-id: the job id.x-croma-signature:sha256=<hmac>, an HMAC-SHA256 of the raw request body, so you can verify the payload’s integrity.
Signature verification uses a shared secret issued by Croma; reach out if you
want it enabled for your callbacks. Respond
2xx quickly; non-2xx responses
are retried.The job envelope
The202 response, GET /jobs/:id, and the callback body all share one shape:
datais populated only whenstatusiscompleted(and matches the endpoint’s normaldatapayload). Otherwise it’snull.erroris populated only when the job hasfailed, as{ "type", "code", "message" }.
Statuses
status | Terminal? | Meaning |
|---|---|---|
queued | no | Accepted, waiting to run. |
running | no | In progress. |
completed | yes | Done. Read data. |
failed | yes | The job errored. Read error. |
canceled | yes | The run was canceled. |
expired | yes | The run expired before completing. |
Headers reference
| Header | Where | Meaning |
|---|---|---|
Prefer: wait=N | request | Seconds to wait inline before returning 202. Clamped to 55. wait=0 returns 202 immediately. |
Preference-Applied: wait=N | 200 response | Echoes the wait that was applied. |
Location | 202 response | The job’s status_url. |
Retry-After | 202 / running poll | Suggested seconds before polling again. |
X-Job-Id | 202 / 200 response | The job id. |
Errors
How failures and the
error object work.