Skip to main content

Success Responses

CodeMeaning
200Request succeeded
201Resource created
204Request succeeded, no content returned

Client Errors

CodeMeaningAction
400Bad requestCheck request format and required fields
401UnauthorizedVerify your API token
403ForbiddenCheck permissions for this resource
404Not foundResource doesn’t exist
429Rate limitedWait and retry with backoff

Server Errors

CodeMeaningAction
500Internal errorRetry the request
502Bad gatewayRetry the request
503Service unavailableRetry the request

Error Response Format

{
  "error": {
    "message": "Resource not found",
    "code": "NOT_FOUND",
    "status": 404
  }
}

Retry Strategy

For 5xx errors and 429 errors:
1

First Retry

Wait 1 second, retry
2

Second Retry

Wait 2 seconds, retry
3

Third Retry

Wait 4 seconds, retry
4

Continue

Continue doubling up to 30 seconds max

Example Error Handler

async function handleApiResponse(response) {
  if (response.ok) {
    return response.json();
  }

  const error = await response.json();

  switch (response.status) {
    case 400:
      throw new Error(`Bad request: ${error.error.message}`);
    case 401:
      throw new Error('Invalid API token');
    case 403:
      throw new Error('Permission denied');
    case 404:
      throw new Error('Resource not found');
    case 429:
      throw new Error('Rate limited - try again later');
    default:
      throw new Error(`API error: ${error.error.message}`);
  }
}