Run this before shipping a new API or cutting a new version. Section headers link to the page where each standard is explained.
Endpoints
- Resources are plural nouns in
kebab-case; the HTTP method carries the action - Sub-resources are nested at most one level deep
- Partial updates use
PATCH;PUTis reserved for full replacement DELETEreturns204 No Contentand is idempotent- Non-CRUD actions are sub-resource nouns:
POST /invoices/{id}/void, notPOST /voidInvoice - Query parameters are
snake_case; sort uses-prefix for descending
Authentication
- Session cookies are signed,
HttpOnly,Secure,SameSite=Laxor stricter, with the__Host-prefix - Logout deletes the session row; expiry is enforced by
expires_atserver-side, not onlyMax-Age - Tokens travel in
Authorization: Beareronly: never in query strings or request bodies - Sign with
RS256orES256; avoidHS256in multi-service environments - Access tokens expire within one hour; refresh tokens rotate on each use
401means unauthenticated;403means authenticated but not authorized401responses to bearer-token requests include aWWW-Authenticateheader
Versioning
- The major version is the first path segment:
/v1/ - Deprecated versions send
DeprecationandSunsetheaders from the announcement date - Removed versions return
410 Gone, not404 Not Found - Clients get at least six months between deprecation announcement and removal
Errors
- Error codes are
SCREAMING_SNAKE_CASEstrings, not integers codeis stable API surface;messageis prose and may change freely- All validation failures are reported in a single response, not one per round-trip
- Field pointers follow JSON Pointer (RFC 6901):
/addresses/0/city - Adding new codes is non-breaking; renaming or removing codes is breaking
Response envelopes
- Add an envelope only when it earns its keep: pagination metadata, consistent error shape
- Success responses carry
data; failures carryerror; never both in the same response - Metadata already present in HTTP headers is not duplicated in the body
Pagination
- Use cursor-based pagination, not offset
- Paginated responses include
next_cursor,has_next_page, andlimit - No
total_countby default; expose a separate endpoint if clients need it - Enforce a maximum
limitserver-side; return an error for out-of-range values, not a silent clamp - Cursors encode the sort order and are not valid across different sort orders
CORS
- Origins are an explicit allowlist, not a wildcard
Access-Control-Allow-Origin: *cannot be combined withAccess-Control-Allow-Credentials: trueOPTIONSpreflight requests return204 No Contentwith the CORS headers