HTTP Request Methods Reference

Complete guide to all HTTP request methods: what they do, when to use them, and how they compare. The definitive cheat sheet for REST API developers.

On This Page

HTTP Methods Overview

Method Description Request Body Response Body Idempotent Safe Cacheable
GET Retrieve a resource
POST Create a resource / submit data
PUT Replace a resource entirely
PATCH Partially update a resource
DELETE Delete a resource
HEAD Same as GET but without response body
OPTIONS Describe communication options
TRACE Loop-back diagnostic test
CONNECT Establish a tunnel to a server

Detailed Method Reference

GET Retrieve a Resource

The GET method requests a representation of the specified resource. GET requests should only retrieve data and should have no other effect on the server state.

When to Use

Key Properties

Example Request

GET /api/users/42 HTTP/1.1
Host: api.example.com
Accept: application/json
Authorization: Bearer eyJhbGci...

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 42,
  "name": "Jane Doe",
  "email": "jane@example.com",
  "role": "admin"
}

Common Use Cases

POST Create a Resource / Submit Data

The POST method submits data to the server, typically causing a change in state or side effects. It is most commonly used to create new resources or submit form data.

When to Use

Key Properties

Example Request

POST /api/users HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer eyJhbGci...

{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "role": "editor"
}

Example Response

HTTP/1.1 201 Created
Content-Type: application/json
Location: /api/users/43

{
  "id": 43,
  "name": "Jane Doe",
  "email": "jane@example.com",
  "role": "editor",
  "createdAt": "2025-01-15T10:30:00Z"
}

Common Use Cases

PUT Replace a Resource Entirely

The PUT method replaces the entire target resource with the request payload. If the resource does not exist, PUT can create it. The client must send the complete representation of the resource.

When to Use

Key Properties

Example Request

PUT /api/users/42 HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer eyJhbGci...

{
  "name": "Jane Smith",
  "email": "jane.smith@example.com",
  "role": "admin",
  "bio": "Senior developer"
}

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 42,
  "name": "Jane Smith",
  "email": "jane.smith@example.com",
  "role": "admin",
  "bio": "Senior developer",
  "updatedAt": "2025-01-15T11:00:00Z"
}

Common Use Cases

PATCH Partially Update a Resource

The PATCH method applies partial modifications to a resource. Unlike PUT, you only send the fields that need to change, not the complete resource representation.

When to Use

Key Properties

Example Request

PATCH /api/users/42 HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer eyJhbGci...

{
  "role": "admin"
}

Example Response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": 42,
  "name": "Jane Doe",
  "email": "jane@example.com",
  "role": "admin",
  "updatedAt": "2025-01-15T11:15:00Z"
}

Common Use Cases

DELETE Delete a Resource

The DELETE method removes the specified resource from the server. After a successful deletion, subsequent GET requests for the same resource should return 404 Not Found or 410 Gone.

When to Use

Key Properties

Example Request

DELETE /api/users/42 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGci...

Example Response

HTTP/1.1 204 No Content

Common Use Cases

OPTIONS Describe Communication Options

The OPTIONS method describes the communication options for the target resource. It is most commonly seen as a CORS preflight request sent by browsers before cross-origin requests.

When to Use

Key Properties

Example Request (CORS Preflight)

OPTIONS /api/users HTTP/1.1
Host: api.example.com
Origin: https://app.example.com
Access-Control-Request-Method: POST
Access-Control-Request-Headers: Content-Type, Authorization

Example Response

HTTP/1.1 204 No Content
Allow: GET, POST, OPTIONS
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 86400

Common Use Cases

TRACE Loop-Back Diagnostic

The TRACE method performs a loop-back test along the path to the target resource. The server echoes the received request back in the response body, which is useful for diagnosing issues with proxies and intermediaries.

When to Use

Key Properties

Example Request

TRACE /api/users HTTP/1.1
Host: api.example.com

Example Response

HTTP/1.1 200 OK
Content-Type: message/http

TRACE /api/users HTTP/1.1
Host: api.example.com
X-Forwarded-For: 203.0.113.50
Via: 1.1 proxy.example.com

CONNECT Establish a Tunnel

The CONNECT method establishes a tunnel to the server identified by the target resource. It is primarily used by HTTP proxies to create an encrypted (HTTPS) tunnel through which the client and destination server communicate directly.

When to Use

Key Properties

Example Request

CONNECT www.example.com:443 HTTP/1.1
Host: www.example.com:443
Proxy-Authorization: Basic dXNlcjpwYXNz

Example Response

HTTP/1.1 200 Connection Established

(TLS handshake begins, then encrypted traffic flows through the tunnel)

GET vs POST

When Should You Use GET vs POST?

This is one of the most common questions in web development. Here is a detailed breakdown of the differences:

Aspect GET POST
Purpose Retrieve data Send data / create resources
Data location URL query string (?key=value) Request body
Data size limit ~2,048 characters (URL length limit) No inherent limit (server may impose one)
Visibility Parameters visible in URL, browser history, server logs Data hidden in request body (but not encrypted without HTTPS)
Cacheable Yes, by browsers and CDNs Not by default
Idempotent Yes No
Safe Yes No
Bookmarkable Yes No
Browser back/refresh Harmless (re-fetches data) Browser warns about resubmission
Encoding type application/x-www-form-urlencoded application/x-www-form-urlencoded, multipart/form-data, application/json
File uploads Not supported Supported (multipart/form-data)
Security Do NOT use for sensitive data (passwords, tokens) Safer for sensitive data (still needs HTTPS)

Rule of Thumb

PUT vs PATCH

When Should You Use PUT vs PATCH?

Both PUT and PATCH update resources, but they work differently. Understanding when to use each one is essential for designing correct REST APIs.

Aspect PUT PATCH
Update type Full replacement Partial modification
Request body Complete resource representation Only the fields to change
Omitted fields Set to null / defaults (the resource is replaced) Left unchanged
Idempotent Always (by specification) Usually (by convention, not required by spec)
Create resource Can create if resource doesn't exist Typically does not create
Bandwidth Higher (sends full object) Lower (sends only changes)
Complexity Simpler to implement Requires merge logic on the server

Example Comparison

Suppose you have a user resource and you want to change only the role:

With PUT (full replacement):

PUT /api/users/42
{
  "name": "Jane Doe",
  "email": "jane@example.com",
  "role": "admin",
  "bio": "Senior developer"
}
// You MUST include all fields, even those not changing

With PATCH (partial update):

PATCH /api/users/42
{
  "role": "admin"
}
// Only send the field that changed

Rule of Thumb

REST API Methods at a Glance

How HTTP methods map to standard CRUD operations in a REST API:

CRUD Operation HTTP Method Example Endpoint Typical Response Code
Create POST POST /api/users 201 Created
Read (all) GET GET /api/users 200 OK
Read (one) GET GET /api/users/42 200 OK
Update (full) PUT PUT /api/users/42 200 OK
Update (partial) PATCH PATCH /api/users/42 200 OK
Delete DELETE DELETE /api/users/42 204 No Content

Frequently Asked Questions

What is the difference between GET and POST?

GET retrieves data from a server without modifying it and sends parameters in the URL query string. POST sends data in the request body to create or process a resource. GET is idempotent, cacheable, and safe, while POST is none of those. GET requests have URL length limits, while POST can send unlimited data. Use GET for reading data and POST for creating resources or submitting forms.

What is the difference between PUT and PATCH?

PUT replaces an entire resource with the provided data (full update), while PATCH applies a partial modification to a resource (partial update). With PUT, you must send the complete resource representation even if only one field changed. With PATCH, you only send the fields that need to change. Both are idempotent, meaning multiple identical requests produce the same result.

What does idempotent mean for HTTP methods?

An idempotent HTTP method produces the same result whether it is called once or multiple times. GET, PUT, PATCH, DELETE, HEAD, and OPTIONS are idempotent. POST is not idempotent because calling it multiple times may create multiple resources. Idempotency is important for reliability: if a request fails and is retried, an idempotent method guarantees no unintended side effects.

What are safe HTTP methods?

Safe HTTP methods are those that do not modify server resources. GET, HEAD, and OPTIONS are safe methods. They are read-only operations intended only for retrieving information. POST, PUT, PATCH, and DELETE are not safe because they can create, update, or remove resources. Browsers and crawlers freely make safe requests without user confirmation.