Utility Empire

JSON API Design - Quick Reference

HTTP verbs, status conventions, REST shape, payload discipline and security defaults for JSON APIs in 2026. All rows are plain text - search to filter, click Copy to grab the pattern.

Reference rack
STATUSREADY
ROWS48
NETWORKLOCAL
MODEREFERENCE
Item / patternWhat it means / how to use it
GET /resourceFetch a resource or collection - safe, cacheable, no side effects.
POST /resourceCreate a new resource; the server assigns the id.
PUT /resource/{id}Replace the whole resource - idempotent.
PATCH /resource/{id}Partial update - send only the changed fields.
DELETE /resource/{id}Remove the resource; often idempotent server-side.
HEAD / OPTIONSHeaders-only response / CORS preflight and advertised methods.
200 OKSuccess with a response body.
201 CreatedA resource was created; include a Location: /resource/{id} header.
204 No ContentSuccess with an empty body - deletes and silent updates.
400 Bad RequestMalformed request or schema failure; return your error model.
401 Unauthorized / 403 ForbiddenMissing or expired credentials vs authenticated-but-not-allowed.
404 Not FoundUnknown resource or id.
409 ConflictState conflict, for example a duplicate unique value.
422 Unprocessable EntityWell-formed but failed business validation; list field-level errors.
429 Too Many RequestsRate limited; set a Retry-After header.
5xx statusesServer-side failures - never leak stack traces or internals.
Plural nouns, no verbs/users not /getUser; actions become sub-resources like /users/{id}/activate.
Max two nesting levels/users/{id}/orders; deeper nesting usually hides a missing resource.
Filter, page and sort via query params"?status=active&page=2&limit=20&sort=-created".
Field selection"?fields=id,name" trims large collection payloads.
Idempotency keysClients send an Idempotency-Key header on POST/PUT so retries are safe.
Version the contract/v1/ prefix or an Accept header; never change semantics silently.
Pagination envelopeReturn { "data": [...] , "paging": { "next": "...", "limit": 20, "total": 412 } }.
List responseswrap arrays in { "data": [...] } - a top-level array breaks forward compatibility.
Single objectsreturn { "data": { ... } } for consistency with list envelopes.
Error modelUse { "error": { "code": "VALIDATION", "message": "...", "field": "email" } }.
Stable idsPrefer opaque strings over sequential integers to avoid enumeration attacks.
Timestamps ISO 8601 UTC"created_at": "2026-09-08T04:30:00Z" - always include the timezone.
camelCase or snake_casePick one naming convention and document it; don't mix.
null vs missingnull = known empty, absent = not provided - PATCH must treat them differently.
Money as integers or decimal stringscents (int) or "19.99" (string) - never binary floats.
Enums as stable stringsPrefer "status": "active" over opaque integers for safe evolution.
Explicit schema guardAdd "schema": "1.2" when clients can't ship fast enough.
Positive boolean naming"is_active", "has_billing" read better than negated flags.
Recalculate server-sideNever trust client-supplied sums or ranges; recompute authoritatively.
Authorization: Bearer <token>The standard placement for JWTs and tokens.
Scoped tokens"scope: api:read" - grant the least privilege.
Accept / Content-Type: application/jsonDeclare and require JSON on the wire.
Validate Content-Type before parsingReject anything unexpected with 415.
Layer validationSchema types + business rules + DB uniqueness, in that order.
Rate limit per key/IPSeparate anonymous and authenticated quotas.
CORS allowlistReflect an expected Origin list, not "*" with credentials.
HTTPS only + HSTSStrip plain HTTP; non-negotiable for any API in 2026.
curl smoke test"curl -si -H \"Authorization: Bearer $TOKEN\" https://api.example.com/v1/users?limit=1".
Contract tests with gold filesDiff responses against frozen JSON snapshots per endpoint.
Deprecation calendarAnnounce, run both versions, then 410 after N months.
Additive-only in a minor versionNew fields and endpoints only; removals need a version bump.
Cursor pagination over offsets?cursor=<opaque> stays stable when rows are inserted mid-page.