A consistent error shape makes it easier for clients to show good messages, retry safely, and debug issues.
{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid token"
}
}
Trace IDs let support and SRE teams find the exact server-side logs.
{
"error": {
"code": "INTERNAL",
"message": "Unexpected error"
},
"traceId": "b4f8f8e7d7d44b1a"
}
Great for forms and API clients:
{
"error": {
"code": "VALIDATION_FAILED",
"message": "Some fields are invalid",
"details": [
{"field": "email", "issue": "invalid_format"},
{"field": "age", "issue": "must_be_greater_than_or_equal_to_18"}
]
}
}
code, not free-text messages.Related: Privacy & safety · Escape JSON strings