API Design Best Practices
Document breaking changes like database migrations: deliberate, reviewed, and announced. These practices keep Node.js HTTP APIs predictable for integrators.
Search across all documentation pages
Document breaking changes like database migrations: deliberate, reviewed, and announced. These practices keep Node.js HTTP APIs predictable for integrators.
/v1/orders, not /getOrders.{ data } success, { error } or Problem Details on failure.code per error type. Clients never parse English message.requestId in error payload for support correlation.limit at 100./v1. New breaking major -> /v2.* with credentials.express.json({ limit }) or Fastify bodyLimit./health/live and /health/ready.Public B2B follows full list. Internal /admin may use offset pagination and simpler errors if documented.
Use GraphQL conventions for errors and versioning; REST list still applies to webhook payloads.
Internal tools and Stripe-style POST actions (/v1/payment_intents/:id/capture) as sub-resources, not top-level verbs.
Pick one org-wide. JavaScript APIs usually camelCase; document in OpenAPI.
Checklist + OpenAPI diff + example curl in PR description.
eventVersion field; separate signing secret per major version if payload shape changes.
Worth it for cacheable GET resources; If-None-Match returns 304.
POST /v1/orders:batch or /v1/orders/batch - document partial success shape.
Multipart documented separately; not forced into JSON envelope.
Undocumented breaking field rename without version bump - prevented by section E.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 19, 2026