Design HTTP APIs that age well: resource modeling, versioning and deprecation policy, error conventions (RFC 9457 problem details), pagination, idempotency, and docs-first OpenAPI contracts. Triggers when someone asks to design an API, add or review endpoints, set up versioning, fix inconsistent errors, or establish API design standards.
./install.sh api-designname: "api_design" description: "Design HTTP APIs that age well: resource modeling, versioning and deprecation policy, error conventions (RFC 9457 problem details), pagination, idempotency, and docs-first OpenAPI contracts. Triggers when someone asks to design an API, add or review endpoints, set up versioning, fix inconsistent errors, or establish API design standards."
Design REST/HTTP APIs around resources (not actions), write a machine-readable contract (OpenAPI 3.1) before code, and bake in versioning, error conventions, and pagination so the API can evolve without breaking clients.
/users, /orders. Nest only where ownership is real (/users/{id}/orders). No verbs in paths — HTTP methods express actions. If an endpoint wants a verb, it is a smell; model it as a resource instead (e.g. POST /reports not /generateReport) or, rarely, a clearly-named controller sub-resource (POST /orders/{id}/cancellations).Idempotency-Key header for retries); PUT = full replace (idempotent); PATCH = partial update; DELETE = remove (idempotent). Return 201 on create, 204 on successful delete, 410 Gone (never 404) for sunset resources.type, title, status, detail, instance) plus one machine-readable code extension. Validation failures include field-level detail. Never leak stack traces or internals in production./v1 → /v2) only on breaking changes; additive, backward-compatible changes stay on the same version. Version the whole API surface, never individual endpoints. Support N and N-1 concurrently. Deprecated responses carry Sunset (RFC 8594, HTTP-date) and Deprecation headers, deprecated: true in OpenAPI, and a changelog entry with a migration guide.bin/api-lint.py against the OpenAPI file to catch verb-in-path, naming, missing-error-response, and unversioned-collection violations before review.components and referenced everywhere, deprecated: true plus sunset dates on retiring operations, and pagination parameters on all list endpoints.Sunset is RFC 8594; problem details are RFC 9457 (not the obsolete 7807); the Deprecation header is RFC 9745 (Standards Track, 2025) — its value is an RFC 9651 structured-field date (@-prefixed Unix timestamp, e.g. Deprecation: @1768435200), not an HTTP-date. Unverifiable = cut or label as opinion.code a machine can switch on. "Internal Server Error" alone is a design failure.Idempotency-Key mechanism; document its behavior on retry.publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.