Skip to main content

Error Handling

The API returns consistent error responses with an error code and message.

Error Format

{
"error": {
"code": "ERR_INVALID_TOKEN",
"message": "The provided API token is invalid"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}

Save the request_id when contacting support.

HTTP Status Codes

StatusDescription
200Success
400Bad request
401Authentication error
403Permission denied
404Not found
422Validation error
429Rate limit exceeded
500Server error

Common Errors

Authentication (401)

{
"error": {
"code": "ERR_INVALID_TOKEN",
"message": "The provided API token is invalid"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}
CodeCause
ERR_TOKEN_MISSINGNo Authorization header
ERR_INVALID_TOKENToken is invalid
ERR_TOKEN_EXPIREDToken has expired

Authorization (403)

{
"error": {
"code": "ERR_FEATURE_NOT_ENABLED",
"message": "Public API access is not enabled for this account"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}
CodeCause
ERR_FORBIDDENInsufficient permissions
ERR_FEATURE_NOT_ENABLEDAPI access not enabled

Not Found (404)

{
"error": {
"code": "ERR_NOT_FOUND",
"message": "The requested resource was not found"
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}

Rate Limit (429)

{
"error": {
"code": "ERR_RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded. Please try again later."
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}

Check Retry-After header for wait time.

Validation (422)

Validation errors return an array of field-specific errors:

{
"error": {
"description": "Validation failed",
"errors": [
{
"field": "page",
"message": "Must be filled",
"code": "err_page_must_be_filled"
},
{
"field": "limit",
"message": "Must be between 1 and 100",
"code": "err_limit_must_be_between_1_and_100"
}
]
},
"meta": {
"timestamp": "2025-01-15T10:30:00Z",
"request_id": "req_abc123"
}
}

Handling Errors

async function fetchData(url, token) {
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});

if (!response.ok) {
const error = await response.json();
throw new Error(`${error.error.code}: ${error.error.message}`);
}

return response.json();
}

Retry Logic

Retry on 429 (rate limit) and 5xx (server) errors:

async function fetchWithRetry(url, token, retries = 3) {
for (let i = 0; i < retries; i++) {
const response = await fetch(url, {
headers: { 'Authorization': `Bearer ${token}` }
});

if (response.status === 429) {
const wait = response.headers.get('retry-after') || 60;
await new Promise(r => setTimeout(r, wait * 1000));
continue;
}

if (response.status >= 500 && i < retries - 1) {
await new Promise(r => setTimeout(r, 1000 * Math.pow(2, i)));
continue;
}

return response;
}
}