201 Created
2xx Successful
RFC 9110
Done — something new exists in the world because of your request.
What 201 Created means {#what}
The request succeeded and a new resource was created as a result. The server should include a Location header pointing to the new resource. Typically the response to a POST or PUT that creates something.
When you’ll see a 201 {#when}
POST /users→ user createdPUT /posts/42→ post created at that ID
When to use 201 {#use}
- Always include a
Locationheader with the URL of the new resource - Return the created resource in the body for convenience