Errors

Understand API error responses, status codes, and error types.

The API uses conventional HTTP response codes to indicate the success or failure of a request. All error responses follow a consistent Stripe-style envelope format.

HTTP status codes

Status codeDescription
200 - OKEverything worked as expected.
201 - CreatedA new resource was successfully created.
204 - No ContentThe request succeeded but there is no response body (e.g. deletes).
400 - Bad RequestThe request was invalid — often a missing or malformed parameter.
401 - UnauthorizedNo valid authentication credentials provided.
403 - ForbiddenThe authenticated user doesn’t have access to the requested resource.
404 - Not FoundThe requested resource doesn’t exist.
409 - ConflictThe request conflicts with the current state (e.g. duplicate email, already revoked key).
429 - Too Many RequestsToo many requests in a given time period. Slow down.
500 - Internal Server ErrorSomething went wrong on our end.

Error types

Every error response includes a type field that categorizes the error:

TypeDescription
authentication_errorInvalid or missing authentication credentials.
authorization_errorValid credentials, but insufficient permissions.
invalid_request_errorThe request was malformed or contained invalid parameters.
not_found_errorThe requested resource was not found.
conflict_errorThe request conflicts with current state.
rate_limit_errorToo many requests — retry after the indicated period.
api_errorAn unexpected internal error occurred.

Error codes

Common error codes returned by the API:

CodeTypeDescription
invalid_credentialsauthentication_errorInvalid email or password
invalid_refresh_tokenauthentication_errorRefresh token is invalid or expired
revoked_refresh_tokenauthentication_errorRefresh token has been revoked
email_takenconflict_errorAn account with that email already exists
reseller_store_not_foundnot_found_errorReseller store not found
reseller_store_access_forbiddenauthorization_errorNot authorized to access this store
source_store_not_foundnot_found_errorSource store not found
sync_job_not_foundnot_found_errorSync job not found
sync_job_not_retryableinvalid_request_errorSync job cannot be retried in its current state
api_key_not_foundnot_found_errorAPI key not found
api_key_already_revokedconflict_errorAPI key was already revoked

Handling errors

We recommend writing code that handles errors by their type and code fields rather than relying on HTTP status codes alone.

const response = await fetch('https://api.example.com/v1/reseller_stores', {
  headers: { 'Authorization': 'Bearer sk_live_...' }
});

if (!response.ok) {
  const { error } = await response.json();
  
  switch (error.type) {
    case 'authentication_error':
      // Re-authenticate or refresh token
      break;
    case 'not_found_error':
      // Resource doesn't exist
      break;
    case 'rate_limit_error':
      // Back off and retry
      break;
    default:
      console.error(`API error: ${error.code}${error.message}`);
  }
}

Response

{
  "error": {
    "type": "not_found_error",
    "code": "reseller_store_not_found",
    "message": "No reseller store found with ID rst_invalid",
    "param": "id"
  },
  "request_id": "req_abc123def456"
}