GET
Purpose: Retrieve a resource.
Effect: Read-only, does not modify the server.
Example:
GET /users/123→ Retrieves the information of the user with ID 123.
POST
Purpose: Create a new resource.
Effect: Adds data to the server.
Example:
POST /userswith a JSON body → Creates a new user.
PUT
Purpose: Replace an existing resource entirely.
Effect: Completely overwrites the target resource with the sent data.
Example:
PUT /users/123→ Updates the entire profile of user 123.
PATCH
Purpose: Modify an existing resource partially.
Effect: Only changes the specified fields.
Example:
PATCH /users/123with{ "email": "new@mail.com" }→ Changes only the email.
DELETE
Purpose: Delete a resource.
Effect: Removes the resource specified in the URL.
Example:
DELETE /users/123→ Deletes user 123.
HEAD
Purpose: Retrieve the headers of a resource (without the body).
Effect: Useful to check if a resource exists or to know its size, type, etc.
Example:
HEAD /users/123→ Checks if user 123 exists.
OPTIONS
Purpose: Request the HTTP methods supported for a resource.
Effect: Used to discover what an endpoint accepts (
GET,POST, etc.), often used for CORS.Example:
OPTIONS /users→ Responds withAllow: GET, POST, OPTIONS.
