📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials API Design Error Handling

Error Handling

5 min read Quiz at the end
Consistent error objects with machine-readable codes, human-readable messages, and field context.

API Error Handling

# Consistent error structure
{
  "error": {
    "code":    "VALIDATION_ERROR",
    "message": "Email is required",
    "field":   "email"
  },
  "request_id": "req-abc-123"
}

# Multiple validation errors
{
  "error": {
    "code": "VALIDATION_ERROR",
    "errors": [
      {"field":"email",    "message":"Invalid format"},
      {"field":"password", "message":"Min 8 chars"}
    ]
  }
}

# Error codes
# VALIDATION_ERROR  400
# UNAUTHORIZED      401
# FORBIDDEN         403
# NOT_FOUND         404
# RATE_LIMITED      429
# INTERNAL_ERROR    500
Topic Quiz · 1 questions

Test your understanding before moving on

1. What is the purpose of an idempotency key in a POST request?
💡 Idempotency keys allow clients to safely retry failed POST requests without causing duplicate side effects.