1. Core HTTP Methods
1. Core HTTP Methods
Each HTTP method carries a specific semantic meaning. Choosing the right method for each endpoint is one of the most fundamental decisions in REST API design.
The Five Core Methods
| Method | Purpose | Typical Use |
|---|---|---|
| GET | Retrieve a resource or collection | GET /users, GET /users/42 |
| POST | Create a new resource | POST /users |
| PUT | Replace an entire resource | PUT /users/42 |
| PATCH | Partially update a resource | PATCH /users/42 |
| DELETE | Remove a resource | DELETE /users/42 |
How to Apply Them
GET requests must be safe and idempotent — they should never alter server state. Use them to fetch data at any level of your resource hierarchy.
POST creates a new resource. The server decides the identifier, and the response should include a Location header pointing to the newly created resource, alongside a 201 Created status code.
PUT replaces the entire representation of a resource. The client must send the full payload; any fields omitted will be cleared or set to their defaults.
PATCH applies a partial update. Only the fields included in the request body are modified. This is the preferred method when clients want to change a single attribute without fetching and resending the whole resource.
DELETE removes a resource permanently. Repeat calls to the same URL should return 404 once the resource is gone, or 204 if the server treats it as already deleted.
Avoid Verbs in URLs
Let the HTTP method express the action. Your URLs should be nouns, not verbs:
# Correct
GET /users
POST /users
DELETE /users/42
# Incorrect — the verb is redundant
GET /getUsers
POST /createUser
DELETE /deleteUser/42
Sticking to this convention makes your API predictable and easy to navigate.