📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials API Design Request and Response Design

Request and Response Design

5 min read Quiz at the end
Consistent response envelopes with data, meta, error objects, and pagination metadata.

Request and Response Design

# Success response
{
  "data": {"id":1,"title":"Docker Guide"},
  "meta": {"request_id":"abc-123","took_ms":45}
}

# Error response
{
  "error": {
    "code":    "VALIDATION_ERROR",
    "message": "Title is required",
    "field":   "title"
  }
}

# Collection with pagination
{
  "data": [{...},{...}],
  "pagination": {"total":100,"page":1,"per_page":20,"pages":5}
}
Topic Quiz · 1 questions

Test your understanding before moving on

1. In a REST API response, what should an error always include?
💡 Error responses should include a machine-readable code and a human-readable message for debugging.