API errors
When a request fails, the API responds with a 4xx or 5xx HTTP status and a JSON body that describes the error. The format is the same for all methods.
Response format
{
"code": "BadRequest",
"error": "Missing required field 'name'",
"param": "name",
"rule": "missing_required_field",
"request_id": "2qNfB7c4XkPZ1mVd8sHwR3tYgLe"
}
| Field | Contents |
|---|---|
code | Error code, such as NotFound or PlanLimitReached. Check this field in your code, not the text. |
error | Human-readable description in English. The text may change, and sometimes it is empty: rely on code then. |
request_id | Request ID, the same as in the X-Request-ID header. See Request ID. |
documentation_url | Link to the documentation page about this error. Not every error has one. |
param | Validation errors only: the request field that failed validation. |
rule | Validation errors only: the rule that was broken. |
Validation errors
If a field in the request body fails validation, the API responds with 400, code BadRequest, and adds the param and rule fields. The response always describes one error, for the first invalid field. Fix it and send the request again: if several fields are invalid, you will get an error for the next one.
Common rule values:
rule | What is wrong |
|---|---|
missing_required_field | A required field is missing. |
below_minimum, above_maximum | The value or string length is out of the allowed range. |
invalid_enum_value | The value is not in the list of allowed values. |
invalid_email, invalid_uuid, invalid_url | Invalid email address, UUID or URL format. |
invalid_hostname, invalid_fqdn | Invalid host or domain name. |
invalid_cron | Invalid cron expression. |
HTTP status codes
| Status | Common code values | What to do |
|---|---|---|
400 | BadRequest | Check the request parameters and body. error, param and rule give a hint. |
401 | AuthorizationRequired | The request has no API key, or the key is invalid. Check the Authorization: Bearer … header and that the key has not been revoked. |
402 | PaymentRequired, PlanLimitReached | The feature is not available on your plan, or you have reached a plan limit. |
403 | Forbidden | Insufficient permissions: either your team role or the key itself lacks them. |
404 | NotFound | The object was not found. Check the ID: the object may belong to another team. |
409 | Conflict, SlugTaken | The request conflicts with the current state, for example, the name is already taken. |
429 | TooManyRequests, RateLimited | A limit was exceeded. Wait and retry, see Rate limits. |
500 | InternalServerError | An error on our side. Retry the request later. If the error persists, contact support. |
503 | ServiceUnavailable | The service is temporarily unavailable. Retry the request in a few seconds. |
Request ID
Every API response, successful or not, has an X-Request-ID header. We use it to find the request in our logs. If you contact support about an error, include the request_id from the response.
You can send your own X-Request-ID with the request: the API returns it in the response and writes it to the logs. This makes it easier to match the request with your application's logs.
curl -i -H "Authorization: Bearer {API-key}" \
-H "X-Request-ID: deploy-2026-12-05-001" \
https://api.tuna.am/v1/user