API Design

This is the standard the Quality Gate's Sustainability lens holds HTTP API work to. Where the Development Guide covers how a change is proposed and reviewed, and the Architecture Standards cover how a service is shaped internally, this page covers the one thing consumers actually depend on: the contract we expose over the wire. An API is the longest-lived promise most services make β€” sustaining it means designing it once, consistently, so it can grow for years without every addition becoming a new dialect. Deviations are allowed, but β€” as everywhere in the handbook β€” they must be deliberate and justified in the project's design notes.

This standard leans on the public HTTP standards and the enterprise API style guides that already exist β€” Fielding's REST constraints, HTTP Semantics (RFC 9110), the Microsoft REST API Guidelines, the Google API Design Guide (AIPs), and the Zalando RESTful API Guidelines β€” and right-sizes them for an SME. We adopt their criteria without adopting their scale.

An API is where OSBR's values become a public interface. Be Kind: an API is a promise you make to everyone downstream β€” client developers, integration partners, your own future services, and the AI agents that call it without a human reading the docs first β€” so a predictable, uniform surface that lets a consumer reason about an endpoint by analogy with one it already knows is a kindness owed to all of them. Be Strong: a uniform contract is the load-bearing structure that lets the system grow without every addition becoming a special case, and it is designed to fail safely under the retries and partial outages real networks produce. Be Nice: the contract and its definition are documentation a teammate β€” human or AI β€” reads to learn what the system promises, so both must read plainly and stay honest.

How to read this policy

1. Goal

Every business concept is exposed as a resource, and the same concept is always found at the same URL, reached with the same method, at the same granularity, and returned in the same representation β€” everywhere in the API. A consumer who has learned one part of the API can predict the rest.

An inconsistent API forces every consumer to special-case every corner, and that is where 3am incidents come from. This matters more, not less, as AI agents become callers: an agent cannot ask a colleague "oh, that one endpoint is weird" β€” it infers behaviour from patterns. When GET /orders/{id} and GET /invoices/{id} behave identically in shape, status codes, pagination, and errors, an agent that learned one can safely drive the other. Consistent with OSBR building for AI users, uniformity here is not just developer ergonomics β€” it is machine-readability, and human⇄AI cooperation depends on it.

2. Responsibility

3. Practices

3-1. Model business concepts as resources

This is levels 1 and 2 of the Richardson Maturity Model (Leonard Richardson; popularised by Martin Fowler): level 1 introduces resources, level 2 uses HTTP verbs and status codes correctly. Level 2 is the OSBR baseline. Level 3 (hypermedia / HATEOAS) is encouraged where it earns its keep but is not mandated.

3-2. Same concept, same shape

The core rule. For any given business concept, these MUST be identical everywhere it appears:

Naming and representation are house decisions, not per-endpoint choices. Field casing (snake_case vs camelCase), timestamp format (RFC 3339 / ISO 8601, UTC), money (integer minor units or decimal string β€” never a binary float), enum spelling, and null-vs-absent semantics are decided once per API and never re-litigated per endpoint. Pick the convention your primary style guide dictates (Google AIP-140/142 and Zalando both give concrete rulings) and hold every endpoint to it.

3-3. Confirm neighbouring conventions before adding an endpoint

An endpoint is not a fresh design surface; it is another instance of an already-agreed pattern. Consistency is a property you protect on every addition, not one you can add back later.

3-4. Use HTTP semantics as defined

Follow HTTP Semantics (RFC 9110) and the Fielding constraints (client–server, stateless, cacheable, uniform interface, layered system) as written β€” do not invent local meanings for standard machinery.

3-5. RPC-style endpoints only where a resource form distorts meaning

Some operations are genuinely verbs β€” POST /orders/{id}:cancel, POST /payments/{id}:refund, POST /reports:export. Forcing these into pure resource CRUD (e.g. inventing a cancellation resource nobody in the business talks about) can distort the domain more than it clarifies it. A custom method is then acceptable.

The bar is "a resource form distorts meaning" β€” not "a resource form is slightly more typing." Custom methods are the documented exception, not an escape hatch. Every one you add is a thing consumers and agents cannot predict by analogy, so each MUST earn its place in writing.

3-6. Idempotency and safe retries

Networks retry. An API that double-charges on a retry is not being kind to anyone.

3-7. Collections: filtering, sorting, pagination

3-8. Errors: one machine-readable shape

3-9. The OpenAPI contract

3-10. Versioning

References

REST & HTTP foundations

Enterprise API style guides

Contract, format & conventions

Related OSBR standards