Guides ยท Engineering

API Error Handling Basics

Return errors clients can use

Effective API error handling maps failures to accurate HTTP codes, returns concise messages with correlation IDs, avoids leaking secrets, and documents retry/backoff guidance for clients.

Map codes to causes

Use 4xx for client issues, 5xx for server faults; avoid 200s on errors.

Structure responses

Return machine-readable fields (code, message, details, trace_id).

Add retry guidance

Document which errors are retryable and preferred backoff patterns.

Log with correlation

Include trace IDs in responses and logs to speed support.

Keep Exploring

Related Terms