# API design review checklist

From ArchitectureCompass (https://architecturecompass.com/toolkit/checklists/api-design/). Free to use and adapt.

An API is a promise that's expensive to change once someone depends on it. Review it while changing it is still free. Most items apply to HTTP APIs and translate directly to messaging and gRPC.

**When to use it:** Before an API is published to other teams or customers, and before any breaking change.

## Purpose and shape

- [ ] The API's consumers and the jobs they need to do are written down.
- [ ] Resources and operations are named in the consumer's language, not the internal data model's.
- [ ] The API exposes what consumers need, not every field in the database.
  - *Why:* Every exposed field becomes something you can't change without a version.
- [ ] Consistency rules are clear: which operations are strongly consistent, and where a read may lag a write.

## Requests and responses

- [ ] Field names, date formats, units and currencies follow one convention across the API.
- [ ] Every field's meaning, unit and allowed values are documented with an example.
- [ ] Optional and required fields are explicit, and unknown fields are ignored by consumers.
- [ ] Large collections are paginated with a stable cursor, not page numbers over a changing list.

## Errors

- [ ] Errors use the right status codes and a consistent error body with a machine-readable code and a human message.
- [ ] Validation errors say which field failed and why.
- [ ] Errors don't leak internals: stack traces, SQL or internal hostnames.
- [ ] Retryable errors are distinguished from permanent ones, so clients know what to retry.

## Safe retries

- [ ] Operations that create or change something accept an idempotency key, or are idempotent by design.
- [ ] Reusing an idempotency key with a different request is rejected, not answered with the old response.
- [ ] Long-running operations return immediately with a status resource that clients can poll or be notified about.
- [ ] The API documents its timeouts, and recommends client retry behavior with backoff and jitter.

## Versioning and change

- [ ] The versioning approach is decided and documented, including what counts as a breaking change.
- [ ] Additive changes don't break consumers: new optional fields and new endpoints only.
- [ ] Deprecation has a policy: notice period, headers or warnings, and usage tracking to see who still calls old versions.
- [ ] Consumer contract tests run against the API in its pipeline.

## Security and limits

- [ ] Authentication and authorization are required on every endpoint, with scopes matched to operations.
- [ ] Object-level authorization is checked: a caller can only reach records they're allowed to see.
  - *Why:* Broken object-level authorization is among the most common API vulnerabilities in practice.
- [ ] Rate limits and quotas are defined per consumer and documented, with clear responses when exceeded.
- [ ] Request size and complexity are limited, including query depth for GraphQL.

## Documentation and operations

- [ ] An OpenAPI or equivalent specification is the source of truth, published and versioned with the code.
- [ ] Every endpoint has a working example request and response.
- [ ] Usage, latency and errors are measured per consumer.
- [ ] A named team owns the API and a channel exists for consumers to ask questions and report problems.
