Card 05/ 07

ExampleDifficulty: Advanced2 min

Review Example: Ten Problems in One Endpoint

A POST /createOrder endpoint fails ten checks, from its path to its error bodies.

An API design review applies the checklist to one endpoint, comparing it as written and as reviewed. A pull request titled "Add order creation" adds the endpoint below, and the reviewer runs the twelve questions against it. The requests and responses are illustrative.

The endpoint as written in the pull request, and as reviewed

As writtenten problems

POST /createOrder?userId=5 takes the whole order model as its body, returns 200 with the stored record including internalNotes, and on failure returns 200 with {"error": "failed"}. A retry after a timeout creates a second order. GET /getOrders?userId=5 returns every order at once, and there is no contract.

As reviewedpasses the checklist

POST /v1/orders takes the customer from the token and accepts only items and deliveryAddress. It returns 201 with Location and a designed response, honours Idempotency-Key, and reports failures as problem details with 4xx or 5xx codes. GET /v1/orders is paginated, and both are in the OpenAPI document with examples.

Each problem, the evidence, and the fix
ProblemEvidenceFix
A verb in the path /createOrderPOST /orders
The user from the query ?userId=5The caller from the token
Mass assignment The whole model acceptedAn allow-list of fields
Wrong success code 200 for a creation201 with Location
Data exposure internalNotes returnedA designed response type
Errors with 200 {"error": "failed"}Problem details with a 4xx or 5xx code
Unsafe retries A second order on retryIdempotency-Key
A verb in the read path /getOrdersGET /orders
Unbounded list Every order at onceCursor pagination with a maximum
No contract or version Nothing publishedAn OpenAPI document, under /v1

What the review found. None of the ten would fail the author's tests, which used one user, one request and no retries. Every one would have reached clients, and three of them, the user in the query, the exposed notes and the duplicate orders, are incidents rather than inconveniences.

What made it quick. Each problem matched a question on the checklist and had a known fix. The reviewer did not have to argue from taste.