StoicBuilder

HandbookXI the TabulariumREST API design

XIthe Tabularium, Model the data

REST API design

1 min readUpdated 28 November

In plain words

REST API design means modelling your data as resources with noun addresses like /teams/42/invoices, using HTTP methods for the action and status codes for the outcome, and keeping all of it consistent.

Where you see it

Harbor opens a public API so customers can pull invoices into their accounting tools. GET /v1/teams/42/invoices lists them, GET /v1/invoices/inv_81 fetches one, and POST /v1/invoices/inv_81/refunds creates a refund, while every error comes back in the same JSON shape.

API requests and responsesserver
GET /v1/invoices/inv_81 200 { "id": "inv_81", "amount_cents": 3000, "status": "paid" }POST /v1/invoices/inv_81/refunds 201 { "id": "re_12", "invoice_id": "inv_81" }GET /v1/invoices/inv_99 404 { "error": { "code": "invoice_not_found", "message": "No invoice with id inv_99." } }
Nouns in the address, the verb in the method, and one error shape with a stable code clients can check.

What goes wrong

  1. Verbs in the address

    /getInvoices, /createRefund and /removeTeamMember make every endpoint something new to learn. Use nouns, and let GET, POST, PATCH and DELETE say what happens.

    POST /api/getInvoicesForTeam
  2. Returning 200 with an error inside

    A 200 response with { "success": false } looks like success to every HTTP client, monitoring tool and retry rule. Use the status code that fits, such as 400, 401, 403, 404, 409 or 422.

  3. Exposing your tables as they are

    If the API returns rows exactly as stored, every column rename breaks customers, and internal fields like stripe_customer_id leak out. Design the response for the client, and map your data to it.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Design the REST endpoints for Harbor's invoices API before writing code: resource paths, methods, request and response bodies, status codes and one consistent error format with a machine-readable code. Return only fields we intend to support publicly, and show me the design as a short table first.

Quick check

Sign in to earn +10 XP for it

A Harbor endpoint returns status 200 with {"success": false, "error": "Invoice not found"}. What's the problem?

Got a prompt that touches REST API design?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.