Skip to content
Get API key (opens in a new tab)

Error handling

Handle API errors by status and machine-readable error code.

API errors include an HTTP status, a stable code, a human-readable message, and optional debugging details. Use the status for broad handling and code for specific recovery behavior.

Error response

{
  "status": 422,
  "code": "validation_error",
  "message": "Request validation failed",
  "request_id": "req_abc123",
  "additional_data": {
    "errors": [
      {
        "field": "query.limit",
        "message": "Too big: expected number to be <=100"
      }
    ]
  }
}
FieldMeaning
statusHTTP status code
codeStable error code for programmatic handling
messageHuman-readable summary
request_idRequest identifier for support and debugging
additional_dataOptional details such as field validation errors

Status codes

StatusMeaningAction
400Invalid requestCheck the request syntax.
401Invalid or missing keyVerify the key with /v2/me.
403Missing permissionCreate a key with the required scope.
404Resource not foundCheck the path and resource ID.
422Validation failedFix the fields listed in additional_data.
429Rate limit exceededWait for Retry-After before retrying.
500Server errorRetry conservatively with backoff.

See Rate limits for throttling behavior.

Handle errors in code

const response = await fetch('https://api.cevoid.com/v2/posts?limit=250', {
  headers: { Authorization: `Bearer ${process.env.CEVOID_API_KEY}` }
});

if (!response.ok) {
  const error = await response.json();

  console.error({
    status: error.status,
    code: error.code,
    message: error.message,
    requestId: error.request_id
  });
}

Log request_id for every failed request. Do not retry 401, 403, 404, or 422 until you change the request.