Get started
Errors and response format
Every response, success or error, uses the same JSON envelope. Use the HTTP status code and response.status to decide what to do, and show response.message to people.
The response envelope
A successful response has response.status: "success" and the result in data. An error has no data.
{
"response": {
"status": "success"
},
"data": {
"id": "01JD7Z1W3J8X0V4Q9T6M2K5R8N",
"status": "completed"
}
}Status codes
These are the statuses the public API returns:
| HTTP | response.status | Meaning |
|---|---|---|
200 / 201 | success | The request worked. Creating a session returns 201. |
400 | validation-error | Some fields are invalid. Details are in response.fields. |
400 | error | The request is valid but cannot be done now, for example the session is already closed. |
401 | need-auth | The API key is missing, wrong, expired or revoked. |
403 | forbidden | The API key is valid, but the request came from an IP that is not on its allowed list, or the key has no allowed IPs yet. |
404 | not-found | The flow or session does not exist for your company. |
429 | error | Too many requests for this key in the last minute. |
500 | error | An unexpected error on our side. Retry later with the same idempotency key. |
Validation errors
Invalid fields come back in response.fields. Each entry names the field in property and lists the problems in constraints. Nested fields use dots, for example metadata.plan.
{
"response": {
"status": "validation-error",
"message": "Validation failed.",
"fields": [
{
"property": "flowCode",
"constraints": [
"This field is required."
]
},
{
"property": "expiresInMinutes",
"constraints": [
"Must be at most 43200."
]
}
]
}
}Message language
Messages are translated. Send Accept-Language: fa for Persian or en for English. You can also add ?lang=fa to the URL. English is the default.
Common errors
Messages are written for people and may change, so do not compare their text in code. These are the cases you will meet most:
| HTTP | When it happens |
|---|---|
401 | The API key is invalid, expired or revoked. |
403 | The request came from an IP that is not on the key's allowed list, or the key has no allowed IPs yet. |
404 | No flow with this flowCode exists in your company. |
400 | The flow exists but is not published. |
404 | No session with this id exists in your company. |
400 | You cancelled a session that is already completed, expired or cancelled. |
400 | metadata has more than 20 keys or is larger than 4 KB. |
400 | The Idempotency-Key is invalid, reused with another body or still running. See Idempotent requests. |
429 | The rate limit of the key was reached. See Rate limits. |