REST APIs use standard HTTP methods—GET, POST, PUT, PATCH, and DELETE—to perform actions on resources, where each method has a specific, well-defined purpose and safety behavior. The most common error is assuming POST and PUT are interchangeable, but POST creates new resources while PUT replaces an entire existing resource. Understanding these distinctions helps you design predictable, maintainable APIs and avoid unintended side effects.

What Each HTTP Method Does

HTTP methods (also called verbs) tell the server what kind of operation you want to perform on a resource, such as a user profile or an order. The five core methods are standardized by the IETF in RFC 7231 and related documents.

GET retrieves data without changing anything on the server. It is safe (no side effects) and idempotent (repeating it has the same result). Use it for fetching resources, like /users/123 to get user #123. Query parameters can filter or paginate results, but the request body must be ignored by servers per the spec.

POST creates a new resource under a collection. It is not idempotent—sending the same POST twice creates two separate resources. For example, sending a POST to /orders with order details adds a new order each time. The server assigns the new resource’s ID and usually returns it in the response.

PUT replaces an entire resource at a known URI. It is idempotent: sending the same PUT request multiple times leaves the resource unchanged after the first request. For instance, PUT /users/123 with updated user data overwrites all fields in that user record. If a field is omitted, it may be reset to null or default, depending on server implementation.

PATCH updates part of a resource. It is also idempotent when using standard patch formats like JSON Patch (RFC 6902), though some implementations are not. You send only the fields to change, such as PATCH /users/123 with {"email": "new@example.com"} to update just the email address. This avoids accidentally overwriting other fields.

DELETE removes a resource. It is idempotent: deleting an already-deleted resource typically returns a 404, which is acceptable because the end state (resource gone) is the same. Use DELETE /users/123 to remove user #123. Some APIs return a 204 No Content to indicate successful deletion with no response body.

Safety and Idempotency Matter

Two key properties—safety and idempotency—help you reason about how methods behave, especially when handling network errors or retries.

Safety means the method does not change server state. Only GET is safe. HEAD is also safe (it returns headers only), and OPTIONS is safe (it describes communication options). POST, PUT, PATCH, and DELETE all modify resources and are not safe.

Idempotency means making the same request multiple times has the same effect as making it once. GET, PUT, DELETE, HEAD, OPTIONS, and TRACE are idempotent. POST is not idempotent because each request creates a new resource. PATCH is idempotent only if the patch document is designed that way—for example, JSON Patch operations are idempotent, but arbitrary partial updates may not be.

Why this matters: if a client sends a request and loses the response (e.g., timeout), it can safely retry GET, PUT, DELETE, and idempotent PATCH requests. For POST, the client must use idempotency keys or check for duplicates to avoid unintended duplication.

Common Misconceptions and Corrections

Many developers mix up POST and PUT or assume PATCH is always safer than PUT. Here are two frequent misunderstandings.

Misconception: "POST is for updates, PUT is for creation."
Correction: POST creates new resources; PUT replaces existing ones. Using POST for updates is common but technically incorrect—PATCH or PUT should be used instead.

Misconception: "PATCH is only for partial updates, so it’s safer."
Correction: PATCH is for partial updates, but safety depends on implementation. A poorly designed PATCH that adds items to a list each time is not idempotent. PUT can be safer if you always send the full resource state.

How to Choose the Right Method

Selecting the correct HTTP method depends on three factors: whether you’re creating or updating, whether you know the resource URI, and whether you want full or partial replacement.

Action Method When to Use
Create new resource POST When the server assigns the ID (e.g., /users)
Replace entire resource PUT When you know the exact URI and send full state (e.g., /users/123)
Update part of a resource PATCH When you want to modify only specific fields without altering others
Retrieve resource GET Any read-only operation; never for actions that change data

Use POST when the client doesn’t control the resource identifier and the server generates it. Use PUT when the client specifies the identifier and wants to ensure the resource matches exactly the payload. Use PATCH when bandwidth or convenience makes sending only changed fields preferable.

Worked Example: Managing a Todo List

Consider a simple todo API where each task has an ID, title, and completion status. Here’s how you’d use each method in practice.

  1. Create a new task (unknown ID): send POST /todos with {"title": "Buy milk"}. The server responds with {"id": 42, "title": "Buy milk", "completed": false} and status 201 Created.
  2. Replace the entire task: send PUT /todos/42 with {"title": "Buy almond milk", "completed": true}. This overwrites all fields on the task. If you omit "completed", it may become null or false depending on the server.
  3. Update only the title: send PATCH /todos/42 with {"title": "Buy oat milk"}. The completed status remains unchanged.
  4. Fetch the task: send GET /todos/42. The server returns the current state without side effects.
  5. Delete the task: send DELETE /todos/42. The server removes it; repeating the request still returns 404 (resource not found) or 204 No Content.

Notice that using POST to update (e.g., POST /todos/42 with update data) violates REST conventions and can cause confusion. Similarly, using PUT with partial data risks losing information if the server expects full replacement.

What Happens If You Use the Wrong Method?

Misusing methods can lead to subtle bugs or security issues. Here’s what typically goes wrong and how to prevent it.

Using POST to update (e.g., POST /users/123) often causes duplication if the server treats it as a new resource, or it may be rejected if the route only allows creation. Clients may retry POST on timeout, accidentally creating multiple resources.

Using GET for state changes (e.g., GET /users/123/deactivate) violates the safe method rule. Caches may store the response, proxies may reissue it, and browsers may prefetch it, leading to unintended deactivation. Always use POST or DELETE for actions that change state.

Using PUT without full state can erase fields. For example, PUT /users/123 with only the email field may set other fields (like name or role) to null. To avoid this, either send the complete current state or use PATCH for targeted updates.

Ignoring idempotency for retries means POST requests can create duplicates. If a request times out after the server processes it but before the client receives the response, retrying with POST adds a second resource. Use idempotency keys (sent in a header) to let the server recognize duplicate requests.

How to Check Your API’s Behavior

Test your endpoints to confirm method behavior:

  • Send the same GET request twice and verify the response is identical with no side effects.
  • Send the same PUT request twice and confirm the resource state does not change after the first request.
  • Send the same POST request twice and verify two distinct resources are created.
  • Check status codes: 200 or 201 for success, 204 for no content (DELETE), 400 for bad request, 405 for method not allowed, 409 for conflict.

Use tools like curl, Postman, or HTTPie to simulate requests. For example, curl -X PUT -d '{"title":"Updated"}' http://localhost:3000/todos/1 shows how PUT behaves in your environment.

What to Do If Your Server Doesn’t Support All Methods

Some older frameworks or proxies block PATCH or PUT. In that case, use POST with a hidden method override (e.g., X-HTTP-Method-Override: PATCH) or fall back to PUT with full resource state. Always document your approach so clients know what to expect.

Never change the method’s meaning to fit tooling. If PATCH is not available, implement full-state updates via PUT instead of repurposing POST for updates. This keeps your API aligned with HTTP standards and reduces confusion for other developers.

Next Steps to Apply This Knowledge

Start by reviewing your current API endpoints and mapping each to the correct HTTP method. Ask: is this creating, replacing, updating, reading, or deleting? Then verify behavior with test requests. Finally, update client code to use the right method—especially for updates, where many systems default to POST incorrectly.

When designing new APIs, follow these rules of thumb:

  1. Use GET only for read-only operations.
  2. Use POST to create new resources in a collection.
  3. Use PUT to fully replace a known resource.
  4. Use PATCH to modify part of a resource.
  5. Use DELETE to remove a resource.

Stick to these, and your API will be easier to learn, test, and maintain. If a client or framework limits your options, document the workaround clearly and ensure the server responds with appropriate status codes and messages.

Remember: HTTP methods are part of the contract between client and server. Using them correctly avoids silent failures and makes your API predictable for others to use.