API Reliability

API Error Response Design Guide

Design stable API error responses with machine-readable codes, safe messages, field details, correlation IDs and retry guidance. Last updated September 17, 2026.

Design stable API error responses with machine-readable codes, safe messages, field details, correlation IDs and retry guidance. This reference is written for developers who need practical validation behavior, reviewable rules and safe examples rather than copied snippets with no explanation.

Recommended workflow

StepWhy it matters
Choose the HTTP statusUse transport semantics to separate invalid input, authentication, conflicts, limits and server failures.
Add a stable codeClients should branch on a documented code, not a translated human message.
Include safe contextField-level details and correlation IDs help debugging without exposing stack traces.
Document recoverySay whether callers should fix input, refresh credentials, retry later or contact support.

Starter snippet

status + stable code + safe message + field details + correlation id + retry hint

Review checks

Common mistakes

Validation should help users correct input while protecting systems from bad data. Keep syntax checks, product policy, security review and deliverability checks separate.

Related Formalint references

Continue with Rest Api Error Response Guide, Api Correlation Id Logging Guide, Api Request Body Validation Guide.