HTTP Request Methods Explained - GET/POST/PUT/DELETE/PATCH Comparison

Purpose and differences of GET / POST / PUT / PATCH / DELETE

MethodCommon useSafeIdempotentRequest body
GETRetrieve a resourceYesYesUsually none
POSTCreate resource / submit dataNoNoUsually yes
PUTReplace a resource entirelyNoYesUsually yes
PATCHPartially update a resourceNoNoUsually yes
DELETEDelete a resourceNoYesUsually none
HEADFetch response headers onlyYesYesNone
OPTIONSQuery server capabilities / CORS preflightYesYesUsually none
TRACEDiagnostic request echoYesYesNone
CONNECTEstablish a tunnelNoNoNone

GET

Retrieves a resource without changing server state; parameters usually go in the URL query string.

GET /api/users?page=1

POST

Submits a form, creates a resource or performs a non-idempotent action; the body is often JSON, a form or a file.

POST /api/users

PUT

Replaces a resource as a whole; submitting the same content multiple times should give the same result.

PUT /api/users/1001

PATCH

Updates part of a resource’s fields; whether it is idempotent depends on the API design.

PATCH /api/users/1001

DELETE

Deletes the specified resource; deleting the same resource multiple times usually gives the same result.

DELETE /api/users/1001

HEAD

Like GET but returns only the response headers, often used to check resource existence or get a file size.

HEAD /download/file.zip

OPTIONS

Queries the methods the server supports and is also commonly used for browser cross-origin preflight requests.

OPTIONS /api/users

TRACE

Echoes the request path back; usually disabled in production for security reasons.

TRACE /debug

CONNECT

Commonly used by proxies to establish an HTTPS tunnel; rarely used by ordinary business APIs.

CONNECT example.com:443

How to Use

HTTP methods define the semantics of a client’s operation on a resource. To actually send requests, use the HTTP Test Tool; for the Content-Type request header, see the HTTP MIME Types Guide.

FAQ

What is the difference between GET and POST?

GET is usually for querying resources, with parameters mostly in the URL; POST is usually for submitting data or creating resources, and its request body may carry JSON, form data or files.

What is an idempotent request?

Idempotent means running the same request once or many times has the same final effect on the server resource; GET, PUT and DELETE are usually designed to be idempotent.

What is the difference between PUT and PATCH?

PUT usually means replacing a resource as a whole, while PATCH usually means partially updating a resource.

What is an OPTIONS request for?

OPTIONS can query the request methods a server supports, and is also common in browser CORS preflight.

Does a DELETE request always have no body?

The spec does not absolutely forbid a DELETE body, but real APIs usually send none, and compatibility depends on the server implementation.