PUT vs POST in REST API

tags: #public

PUT and POST are not equalent to create and update.

Use PUT when you know the URL of the resource you are trying to create or update.

PUT /posts/existing-post-title/
Host: diff.blog
PUT /posts/new-post-title/
Host: diff.blog

The requests are idempotent. Making the same request again, would result in the same state.

POST can be used for creating a resource which you don’t know the URL yet.

POST /posts/
Host: diff.blog

You can also use it for updating an existing resource.

POST /posts/existing-post-title
Host: diff.blog

Backlinks