{
"name": "Ava Martin",
"email": "ava@example.com",
"role": "admin"
}A clean top-level object is often enough for private APIs and straightforward CRUD designs.
JSON request bodies, envelope choices, sparse fieldsets, includes, concurrency control, and common response contracts.
Shape JSON bodies consistently for creates and updates.
{
"name": "Ava Martin",
"email": "ava@example.com",
"role": "admin"
}A clean top-level object is often enough for private APIs and straightforward CRUD designs.
{
"timezone": "America/Los_Angeles",
"marketing_opt_in": false
}Small patch bodies minimize payload size and avoid accidental overwrites.
{
"items": [
{ "sku": "sku_1", "qty": 2 },
{ "sku": "sku_2", "qty": 1 }
]
}Bulk endpoints can reduce chattiness, but they need clear per-item success and failure semantics.
Support flexible reads without proliferating endpoints.
GET /users/usr_123?fields=id,name,emailSparse fieldsets reduce overfetching for large objects and mobile clients.
Include relationships when the client asks for them.
GET /orders/ord_123?include=customer,itemsOptional includes preserve a lightweight base contract while allowing richer reads.
Tag a representation with a revision validator.
ETag: "686897696a7c876b7e"ETags can power both conditional caching and optimistic concurrency checks.
Prevent lost updates from concurrent writes.
PATCH /documents/doc_123
If-Match: "686897696a7c876b7e"If the entity tag no longer matches, the API can reject the write and ask the client to refetch.
Queue work and let clients poll job state.
{
"id": "job_123",
"status": "queued",
"url": "/jobs/job_123"
}This pattern works well when a request takes too long to finish within a normal synchronous response window.