Designing a modern REST API requires balancing developer experience, consistency, backward compatibility, and system performance. Following established web standards guarantees that client integrators can intuitively predict API behavior without constantly consulting documentation.
1. Adhere Strictly to HTTP Method Semantics
HTTP verbs communicate action intent. RFC 9110 cleanly defines safe, idempotent, and state-modifying operations:
| Method | Safety | Idempotence | Primary Target Use Case |
|---|---|---|---|
| GET | Safe (No state change) | Idempotent | Fetch resource representations or collections. |
| POST | Unsafe (Mutates state) | Non-Idempotent | Create new resources, trigger complex operations. |
| PUT | Unsafe (Mutates state) | Idempotent | Full resource replacement or create with client ID. |
| PATCH | Unsafe (Mutates state) | Non-Idempotent | Apply delta modifications to target resource. |
| DELETE | Unsafe (Mutates state) | Idempotent | Remove specified resource from state store. |
HTTP Method Semantics Matrix
2. Utilize Proper HTTP Status Codes
Never return a 200 OK status code with an inline status: 'error' payload. Choose precise status codes to convey execution results:
- 200 OK: Successful GET, PUT, or PATCH call returning data.
- 201 Created: Successful POST creation, returning Location header pointing to new resource URI.
- 202 Accepted: Asynchronous job processing initiated; returns status poll location.
- 204 No Content: Successful DELETE or action returning no body.
- 400 Bad Request: Malformed JSON syntax or schema validation failure.
- 401 Unauthorized: Missing or invalid authentication credential (JWT/API key).
- 403 Forbidden: Authenticated identity lacks required scope or permissions.
- 404 Not Found: Requested resource URI does not exist.
- 409 Conflict: State collision (e.g., duplicate unique constraint or optimistic locking error).
- 422 Unprocessable Entity: Valid JSON syntax but semantic business rule violation.
- 429 Too Many Requests: Rate limit quota exceeded; include Retry-After header.
3. Standardize Naming Conventions & Case Sensitivity
Enforce strict consistency across URIs, query parameters, headers, and payload keys. Mixing camelCase and snake_case creates friction for SDK generators and typescript clients.
{
"id": "usr_8492049281",
"firstName": "Alex",
"lastName": "Morgan",
"emailAddress": "alex.morgan@example.com",
"accountStatus": "active",
"createdAt": "2026-09-26T18:30:00Z"
}4. Enforce Filtering, Sorting, and Cursor Pagination
Collection endpoints must never return unbounded arrays. For high-volume collections, prefer cursor-based pagination over offset-limit to avoid database performance penalties and drift during writes.
/v1/audit-logs:
get:
summary: Retrieve paginated audit logs
parameters:
- name: limit
in: query
schema:
type: integer
default: 25
maximum: 100
- name: startingAfter
in: query
description: Cursor for pagination (ID of last item in previous page)
schema:
type: stringEvaluate Your REST API Quality
Benchmark your REST API against industry standards for URI structure, HTTP verb usage, error schemas, and response consistency.
