Skip to main content

Error Codes

All CRAFT APIs return consistent error responses. This page documents the error format, all error codes, and troubleshooting guidance for each.

Error Response Format

Error responses follow a standard JSON structure:

HTTP Status Codes

Error Codes Reference

The OpenAPI specifications define a base ErrorCode enum with 9 values: INVALID_REQUEST, INVALID_TOKEN, INSUFFICIENT_PERMISSIONS, RESOURCE_NOT_FOUND, RESOURCE_ALREADY_EXISTS, VALIDATION_ERROR, RATE_LIMIT_EXCEEDED, SERVICE_UNAVAILABLE, INTERNAL_ERROR. The implementation may return more specific codes within each category as documented below.

Authentication Errors (401)

Authorization Errors (403)

Resource Errors (404, 409)

Validation Errors (400, 422)

Rate Limiting Errors (429)

Server Errors (500, 502, 503)

Handling Errors in Code

UnexpectedStatus.content is raw bytes; decode and json.loads() to read the envelope ({"error": {"code", "message", "request_id"}}).

Retry Strategy

For transient errors (429, 500, 502, 503), implement exponential backoff with jitter:
For 429 errors, always respect the Retry-After header rather than using exponential backoff. The header provides the exact wait time until the rate limit window resets.

Getting Help

When reporting an issue, include:
  1. The request_id from the error response
  2. The trace_id for end-to-end correlation
  3. The timestamp of the request
  4. The full error response body

Next Steps

API Overview

Review the full API structure and endpoints.

API Authentication

Learn how to obtain and manage JWT tokens.

Python SDK

Use the Python SDK with built-in error handling.

TypeScript SDK

Use the TypeScript SDK with built-in error handling.