Be explicit
Define required fields, allowed values, and how omitted fields differ from null values.
A concise reference for structured data, predictable requests, and thoughtful error handling. Keep the details small. Make the behavior explicit.
Before connecting two systems, document what a request accepts, what a successful response contains, and which failures a client can recover from.
Define required fields, allowed values, and how omitted fields differ from null values.
Treat resource IDs as opaque strings. Do not infer meaning or ordering from their format.
Set request timeouts and payload limits. Decide how cancellation reaches the calling application.
A consistent envelope can separate resource data from metadata. This sample represents a generic collection item; adapt its shape to your own documented contract.
{
"data": {
"id": "item_example_01",
"type": "note",
"attributes": {
"title": "A small, useful example",
"created_at": "2026-01-15T09:00:00Z"
}
},
"meta": { "request_id": "req_example" }
}Include a timezone offset in date-time values. Store the original instant and localize its display at the presentation layer.
Clients should tolerate unknown response fields. Renaming or removing a field needs an explicit compatibility plan.
Cursor-based pagination is useful when collections change between requests. Treat the cursor as opaque and continue only while the response supplies a next cursor.
{
"data": [{ "id": "item_example_01" }],
"page": {
"next_cursor": "opaque_example_cursor",
"has_more": true
}
}Set an overall page or time budget, detect repeated cursors, and define how your application handles duplicates. A cursor alone does not guarantee a consistent snapshot.
Use the provider's documented semantics to decide whether to retry. A status code is a starting point; request safety and the response body matter too.
| HTTP response | Typical client action |
|---|---|
400 / 422 | Inspect validation details and correct the request before resubmitting. |
401 / 403 | Check authentication and permissions. Avoid automatic retry loops. |
404 | Verify the resource identifier and handle absence in the interface. |
429 | Respect Retry-After when supplied; otherwise apply bounded backoff with jitter. |
5xx / timeout | Retry only when safe. A timeout does not prove a write was not applied. |
For write requests, use a documented idempotency mechanism when available. Keep a request identifier in logs, and exclude credentials and sensitive payloads.