What is the difference between PUT, POST and PATCH methods in HTTP protocol?
-
2http://stackoverflow.com/a/2590281/400277 – Nowhere man Jun 27 '15 at 13:30
-
4possible duplicate of [PUT vs POST in REST](http://stackoverflow.com/questions/630453/put-vs-post-in-rest) – Nowhere man Jun 27 '15 at 13:32
-
56Using anything other than GET/POST is insane in modern web APIs. Too many do it. URIs identified in most modern apps ARE NOT resources to be replaced, updated, etc. They're not documents. They're PROCEDURES being called. The URI itself rarely identifies an actual resource, other than the method being invoked. Therefore, use GET for querystring requests and POSTs when you need to post JSON data or files in the body of the request. IMO, anything else is trying to shoehorn obsolete concepts involving URIs and operations on static HTML documents into a new architecture that looks nothing like it. – Triynko Oct 26 '17 at 18:43
-
1All great answers. I just wanted to share my answer of [the differences and when you should use each one.](https://stackoverflow.com/a/47228528/4976025) – Train Nov 12 '17 at 16:26
-
1@Triynko And the _procedures_ you’re referring to involve _creation_, _deletion_, and _modification_ of resources. No better way to convey such ideas than being RESTful. Why not? – Константин Ван Jan 16 '20 at 23:19
-
15@Triynko, somehow you got stuck at Level 0 of the Richardson Maturity Model, time to move on: https://martinfowler.com/articles/richardsonMaturityModel.html – Marcel Toth Feb 06 '20 at 00:26
-
@MarcelToth In conclusion, is it recommended to use all the verbs or in practical terms is GET/POST enough? – Antonito Sep 20 '22 at 00:10
13 Answers
Difference between PUT
, POST
, GET
, DELETE
and PATCH
in HTTP Verbs:
The most commonly used HTTP verbs POST, GET, PUT, DELETE are similar to CRUD
(Create, Read, Update and Delete) operations in database. We specify these HTTP verbs in the capital case. So, the below is the comparison between them.
- Create - POST
- Read - GET
- Update - PUT
- Delete - DELETE
PATCH: Submits a partial modification to a resource. If you only need to update one field for the resource, you may want to use the PATCH
method.
Note:
Since POST, PUT, DELETE modifies the content, the tests with Fiddler for the below url just mimicks the updations. It doesn't delete or modify actually. We can just see the status codes to check whether insertions, updations, deletions occur.
URL: http://jsonplaceholder.typicode.com/posts/
- GET:
GET
is the simplest type of HTTP request method; the one that browsers use each time you click a link or type a URL into the address bar. It instructs the server to transmit the data identified by the URL to the client. Data should never be modified on the server side as a result of a GET
request. In this sense, a GET request is read-only.
Checking with Fiddler or PostMan: We can use Fiddler for checking the response. Open Fiddler and select the Compose tab. Specify the verb and url as shown below and click Execute to check the response.
Verb: GET
url: http://jsonplaceholder.typicode.com/posts/
Response: You will get the response as:
"userId": 1, "id": 1, "title": "sunt aut...", "body": "quia et suscipit..."
In the “happy” (or non-error) path, GET returns a representation in XML or JSON and an HTTP response code of 200 (OK). In an error case, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).
2) POST:
The POST
verb is mostly utilized to create new resources. In particular, it's used to create subordinate resources. That is, subordinate to some other (e.g. parent) resource.
On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the 201 HTTP status.
Checking with Fiddler or PostMan: We can use Fiddler for checking the response. Open Fiddler and select the Compose tab. Specify the verb and url as shown below and click Execute to check the response.
Verb: POST
url: http://jsonplaceholder.typicode.com/posts/
Request Body:
data: {
title: 'foo',
body: 'bar',
userId: 1000,
Id : 1000
}
Response: You would receive the response code as 201.
If we want to check the inserted record with Id = 1000 change the verb to Get and use the same url and click Execute.
As said earlier, the above url only allows reads (GET), we cannot read the updated data in real.
3) PUT:
PUT
is most-often utilized for update capabilities, PUT-ing to a known resource URI with the request body containing the newly-updated representation of the original resource.
Checking with Fiddler or PostMan: We can use Fiddler for checking the response. Open Fiddler and select the Compose tab. Specify the verb and url as shown below and click Execute to check the response.
Verb: PUT
url: http://jsonplaceholder.typicode.com/posts/1
Request Body:
data: {
title: 'foo',
body: 'bar',
userId: 1,
Id : 1
}
Response: On successful update it returns status 200 (or 204 if not returning any content in the body) from a PUT.
4) DELETE:
DELETE
is pretty easy to understand. It is used to delete a resource identified by a URI.
On successful deletion, return HTTP status 200 (OK) along with a response body, perhaps the representation of the deleted item (often demands too much bandwidth), or a wrapped response (see Return Values below). Either that or return HTTP status 204 (NO CONTENT) with no response body. In other words, a 204 status with no body, or the JSEND-style response and HTTP status 200 are the recommended responses.
Checking with Fiddler or PostMan: We can use Fiddler for checking the response. Open Fiddler and select the Compose tab. Specify the verb and url as shown below and click Execute to check the response.
Verb: DELETE
url: http://jsonplaceholder.typicode.com/posts/1
Response: On successful deletion it returns HTTP status 200 (OK) along with a response body.
Example between PUT and PATCH
PUT
If I had to change my first name then send PUT
request for Update:
{ "first": "Nazmul", "last": "hasan" }
So, here in order to update the first name we need to send all the parameters of the data again.
PATCH:
Patch request says that we would only send the data that we need to modify without modifying or effecting other parts of the data. Ex: if we need to update only the first name, we pass only the first name.
Please refer the below links for more information:

- 4,790
- 6
- 21
- 37

- 7,290
- 3
- 25
- 25
-
152PUT is not update. PUT is create or replace the entity at the given URI. Per the HTTP spec, PUT is idempotent. Yes, it can be used to update, but thinking of only as update is not correct. – Maladon Jan 11 '17 at 18:46
-
7i agree PUT is not update, it can be mapped with replace, because when you send PUT, it overrides the existing resource. But if we send PATCH, it will only replace specified entries. – Atul Chavan Sep 18 '17 at 09:18
-
1Because PUT can also be used to create, I'm not sure how your answer indicates which I should be using? – Rob P. Sep 23 '17 at 03:41
-
3This answer is much better, but doesn't compare with PATCH: https://stackoverflow.com/a/630475/2391795 – Vadorequest Feb 20 '18 at 00:40
-
This is not how you properly send a POST, please check: https://stackoverflow.com/questions/7075125/check-post-request-with-fiddler/7079092 – Shayan Sep 30 '20 at 10:23
-
You should specify Content-Type in headers, and RequestBody is like this: `title=foo&body=bar&userid=1000&id=1000` – Shayan Sep 30 '20 at 10:25
-
you said, post should return 201 as status code, but i am checking your link for post, it returns the 200 – Sunil Garg Nov 05 '20 at 06:12
-
@SunilGarg: may be you didnt change the http verb to post . 200 is for get. – Krishna Nov 10 '20 at 02:13
-
@Krishna, i have checked in the browesser, request type is post id response is of status 200 – Sunil Garg Nov 10 '20 at 05:37
-
@SunilGarg : oh okay, this is what i did.. i'm using postman by the way. In postman, go to File--> New. Select the http verb as Post in the dropdown, Request url as 'http://jsonplaceholder.typicode.com/posts/' and in the body paste 'data: { title: 'foo', body: 'bar', userId: 1000, Id : 1000 }' and then click on Send. I see the body as '{ "id": 101 } and Status: 201Created.. Let me know if u are following the same steps. – Krishna Nov 10 '20 at 06:47
-
I still don't get how PATCH behaves, because we can do a single update with PUT too – aj go Jul 01 '22 at 05:44
The below definition is from the real world example.
Example Overview
For every client data, we are storing an identifier to find that client data and we will send back that identifier to the client for reference.
POST
- If the client sends data without any identifier, then we will store the data and assign/generate a new identifier.
- If the client again sends the same data without any identifier, then we will store the data and assign/generate a new identifier.
- Note: Duplication is allowed here.
PUT
- If the client sends data with an identifier, then we will check whether that identifier exists. If the identifier exists, we will update the resource with the data, else we will create a resource with the data and assign/generate a new identifier.
PATCH
- If the client sends data with an identifier, then we will check whether that identifier exists. If the identifier exists, we will update the resource with the data, else we will throw an exception.
Note: On the PUT method, we are not throwing an exception if an identifier is not found. But in the PATCH method, we are throwing an exception if the identifier is not found.
Do let me know if you have any queries on the above.

- 10,690
- 10
- 65
- 102

- 1,461
- 1
- 6
- 5
-
Great explanation, but if that is what PUT and POST mean, then RFC authors deserve a smack on their head. It feels like they wanted things to rhyme things starting with 'P'. – nawfal Dec 20 '22 at 03:59
Here is a simple description of all:
- POST is always for creating a resource ( does not matter if it was duplicated )
- PUT is for checking if resource exists then update, else create new resource
- PATCH is always for updating a resource
-
5This is not entirely accurate. 'The POST method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics' is what the rfc states. 'Appending data to a resource's existing representation' is one of the rfc's supplied examples. https://tools.ietf.org/html/rfc7231#section-4.3.3 – Chomeh Feb 03 '21 at 06:33
-
1@Chomeh at what layer are those semantics/rfc defined? Is it a framework or language level config, or something specific to a particular part of the framework? Like, would node's POST/PUT/PATCH be different to ruby on rails' ? – stevec Jun 19 '21 at 16:04
-
2@stevec Application / API. For example, you could design an API that accepts a POST to /delete, but doesn't necessarily have the result of creating a new resource (e.g. /deletions/{id}). – Chomeh Jun 20 '21 at 23:55
-
In other words: POST: Create a new resource and direct the client to its representation, whether that be returning the representation at the end of the request or via redirect. – truefusion Oct 31 '22 at 22:44
PUT = replace the ENTIRE RESOURCE with the new representation provided
PATCH = replace parts of the source resource with the values provided AND|OR other parts of the resource are updated that you havent provided (timestamps) AND|OR updating the resource effects other resources (relationships)

- 1,577
- 1
- 12
- 24
-
3It seems like PUT means "update and overwrite". And seems like PATCH means "update and merge". I'm just trying to think of consistent and concise terms to describe what your answer nicely explains. – MikeyE May 19 '21 at 21:25
Simplest Explanation:
POST - Create NEW record
PUT - If the record exists, update else, create a new record
PATCH - update
GET - read
DELETE - delete

- 2,026
- 17
- 19

- 537
- 4
- 2
-
4How is this substantially different from [Kwame's answer](https://stackoverflow.com/a/59697524/1028230) posted about two weeks before yours? – ruffin Mar 05 '20 at 15:30
Think of it this way...
POST - create
PUT - replace
PATCH - update
GET - read
DELETE - delete

- 2,110
- 11
- 13
-
4I'd probably add [this distinction](https://stackoverflow.com/questions/630453/put-vs-post-in-rest#comment18665369_2590281): "_PUT if the client determines the resulting resource's address, POST if the server does it._" – ruffin Mar 05 '20 at 15:33
Request Types
- create - POST
- read - GET
- create or update - PUT
- delete - DELETE
- update - PATCH
GET/PUT is idempotent PATCH can be sometimes idempotent
What is idempotent - It means if we fire the query multiple times it should not afftect the result of it.(same output.Suppose a cow is pregnant and if we breed it again then it cannot be pregnent multiple times)
get
:-
simple get. Get the data from server and show it to user
{
id:1
name:parth
email:x@x.com
}
post
:-
create new resource at Database. It means it adds new data. Its not idempotent.
put
:-
Create new resource otherwise add to existing. Idempotent because it will update the same resource everytime and output will be the same. ex. - initial data
{
id:1
name:parth
email:x@x.com
}
- perform put-localhost/1 put email:ppp@ppp.com
{
id:1
email:ppp@ppp.com
}
patch
so now came patch request PATCH can be sometimes idempotent
id:1
name:parth
email:x@x.com
}
patch name:w
{
id:1
name:w
email:x@x.com
}
HTTP Method GET yes POST no PUT yes PATCH no* OPTIONS yes HEAD yes DELETE yes
Resources : Idempotent -- What is Idempotency?

- 361
- 3
- 4
-
What does "sometimes" idempotent really means? What determines idempotency? – Polv Mar 11 '20 at 07:03
-
***"Sometimes idempotent" === Not idempotent*** - it either is or is not idempotent, there is no in-between. – Jay Dadhania Mar 11 '21 at 04:50
-
I can read in the comments that PUT changes the resource but the whole set of attributes has to be sent So how come is it that you can do "put email:ppp@ppp.com"??? Wasn't it supposed to be put { id:1 name:parth email:ppp@ppp.com} ?? – arsene stein Apr 25 '22 at 09:21
Main Difference Between PUT and PATCH Requests:
Suppose we have a resource that holds the first name and last name of a person.
If we want to change the first name then we send a put request for Update
{ "first": "Michael", "last": "Angelo" }
Here, although we are only changing the first name, with PUT request we have to send both parameters first and last.
In other words, it is mandatory to send all values again, the full payload.
When we send a PATCH request, however, we only send the data which we want to update. In other words, we only send the first name to update, no need to send the last name.

- 1,543
- 2
- 17
- 29

- 305
- 3
- 16
Reference to RFC: https://www.rfc-editor.org/rfc/rfc9110.html#name-method-definitions
POST - creates new object
PUT - updates old object or creates new one if not exist
PATCH - updates/modify old object. Primarly intended for for modificaiton.
There is few interpritation of RFC like mentioned before, but if you read carefully then you can notice that PUT and PATCH methods came after POST witch is common old fashion way to create native HTML Forms.
Therefore if you try to support all methods (like PATCH or DELETE), it can be suggested that the most approapreate way to use all methods is to stick to CRUD model:
Create - PUT
Read - GET
Update - PATCH
Delete - DELETE
Old HTML native way:
Read - GET
Create/Update/Delete - POST
Good Luck Coders! ;-)

- 41
- 3
Quite logical the difference between PUT & PATCH w.r.t sending full & partial data for replacing/updating respectively. However, just couple of points as below
- Sometimes POST is considered as for updates w.r.t PUT for create
- Does HTTP mandates/checks for sending full vs partial data in PATCH? Otherwise, PATCH may be quite same as update as in PUT/POST

- 27
- 3
PUT: The PUT method replaces all current representations of the target resource with the request payload.
Use it for updating items. For example; create address ABC, overriding it, if it already exists.
POST: The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
Use it to create a new item. For example; create a new address.
PATCH: The PATCH method applies partial modifications to a resource.
Use it for updating items. For example; update the name on an address by providing the new name.
Other HTTP request methods
GET: The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
For example; get a single address.
DELETE: The DELETE method deletes the specified resource.
For example; delete address ABC from the database.
HEAD: The HEAD method asks for a response identical to a GET request, but without the response body.
CONNECT: The CONNECT method establishes a tunnel to the server identified by the target resource.
OPTIONS: The OPTIONS method describes the communication options for the target resource.
TRACE: The TRACE method performs a message loop-back test along the path to the target resource.

- 1,470
- 1
- 18
- 20
You may understand the restful HTTP methods as corresponding operations on the array in javascript (with index offset by 1).
See below examples:
Method | Url | Meaning |
---|---|---|
GET | /users | return users array |
GET | /users/1 | return users[1] object |
POST | /users | users.push(body) ; return last id or index |
PUT | /users | replace users array |
PUT | /users/1 | users[1] = body |
PATCH | /users/1 | users[1] = {...users[1], ...body } |
DELETE | /users/1 | delete users[1] |

- 1,058
- 10
- 17
POST
creates a resource. PUT
replaces a resource. PATCH
updates a resource.

- 57
- 7
-
1Don't copy existing answers: https://stackoverflow.com/a/59697524/ – General Grievance Aug 24 '23 at 12:56