How do CRUD operations map to HTTP methods?
CRUD (Create, Read, Update, Delete) maps onto HTTP methods through REST conventions. The mapping is not one-to-one—HTTP provides more verbs than CRUD has operations—and understanding the nuances prevents common API design mistakes.
**Create → POST (or PUT)**. POST to a collection URL (`POST /articles`) creates a new resource with a server-assigned ID. The response should be `201 Created` with a `Location` header pointing to the new resource. PUT to a specific URL (`PUT /articles/abc`) creates or replaces the resource at that exact URL—used when the client controls the ID (e.g., upserts).
**Read → GET**. `GET /articles` returns a collection; `GET /articles/1` returns a single resource. GET is safe and idempotent, so it can be cached and retried freely. The response is `200 OK` with the representation in the body. If the resource does not exist, return `404 Not Found`.
**Update → PUT or PATCH**. This is where most confusion lives. PUT sends a complete replacement of the resource—the client must include all fields. PATCH sends a partial update—only the changed fields. Use PUT when the client always has the full representation; use PATCH for partial edits (e.g., updating a single status field). Both return `200 OK` with the updated resource, or `204 No Content` when no body is needed.
**Delete → DELETE**. `DELETE /articles/1` removes the resource. Return `204 No Content` on success (no body needed) or `200 OK` if you return the deleted representation. A second DELETE on an already-deleted resource should return `404 Not Found`—the resource is gone.
**Status codes matter**: returning `200` for a creation instead of `201`, or returning `200` for a deletion instead of `204`, technically works but loses semantic signal. Clients that inspect status codes (reverse proxies, monitoring tools, generated SDK clients) rely on this precision.
A consistent, semantically correct CRUD-to-HTTP mapping makes APIs predictable, reduces client bugs, and enables standard tooling (caches, retry logic, API gateways) to work correctly out of the box.
| CRUD | HTTP Method | URL Pattern | Success Code | Notes |
|---|---|---|---|---|
| Create | POST | POST /resources | 201 Created | Server assigns ID; Location header |
| Create (upsert) | PUT | PUT /resources/:id | 200 or 201 | Client controls ID |
| Read (list) | GET | GET /resources | 200 OK | Cacheable |
| Read (single) | GET | GET /resources/:id | 200 OK | 404 if not found |
| Update (full) | PUT | PUT /resources/:id | 200 or 204 | Must send complete representation |
| Update (partial) | PATCH | PATCH /resources/:id | 200 or 204 | Send only changed fields |
| Delete | DELETE | DELETE /resources/:id | 204 No Content | 404 on second call |
Correctly maps all four CRUD operations to HTTP methods with appropriate status codes.
Covers PUT vs. PATCH distinction, explains when PUT can be used for create, gives correct status codes (201 for create, 204 for delete), and notes idempotency implications.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment