Coding Standards

REST API Conventions

Foundational

Our HTTP APIs should feel like one team designed them: consistent URLs, verbs, status codes, error shapes, pagination, and versioning. This is the concrete conventions reference that goes with the broader API & Contract Design guideline. Consistency makes APIs predictable to use, safe to change, and easy to secure.

API & Contract Design covers the principles (consumer-first, stable, safe). This page sets the specific conventions so every endpoint looks and behaves the same. Pick one convention and apply it everywhere. A consistent API is far easier to consume, document, and maintain than one where every endpoint is a surprise.

All the security rules still apply: authenticate and authorise every endpoint, validate input at the boundary, never return too much data, and never leak internals (see Authentication & Authorization, Trust Boundaries).

Resources & URLs

Status codes & responses

Collections, filtering & versioning

Safety & robustness

An endpoint, end to end

RPC verbs, wrong codes, leaky POST /getCustomerById?id=5 -> 200 { error: "not found" }
POST /deleteCustomer -> 200 { ok: true }
// 500 body: stack trace and SQL

Verbs in URLs, a 200 for a not-found and for errors, inconsistent shapes, and an internal stack trace and SQL leaked to the caller. Unpredictable and unsafe.

Resourceful, correct codes, safe errors GET /customers/{id} -> 200 CustomerResponse | 404
DELETE /customers/{id} -> 204 | 404
// errors: application/problem+json (type/title/status/detail and code), no internals; 401/403/422/429 as appropriate

Nouns and HTTP verbs, correct status codes, a single Problem Details error shape with no internal detail, and identity and tenant derived on the server.

Self-review checklist

Why it matters: A consistent API is much cheaper to consume, document, secure, and change than a mix of one-off endpoints. The conventions here (status codes, error shapes, pagination, versioning) are exactly what integration partners and our own front-ends rely on. Predictable APIs mean fewer bugs, less support load, and fewer breaking changes.