// http 2xx · success

HTTP 201 Created

The request succeeded and a new resource was created.

What HTTP 201 Created means

201 Created means the request succeeded and a new resource was created as a result — typically the response to a POST or PUT that adds something. The response usually includes a `Location` header pointing to the new resource's URL.

Which category is it?

201 is a 2xx code — Success. 2xx means the request was received, understood, and accepted — everything worked.

Example 201 response

POST /api/users HTTP/1.1
Content-Type: application/json

{"name":"Ada"}

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

{"id":42,"name":"Ada"}

How to check a 201

  1. Check the Location header: a good 201 points to the URL of the newly created resource.
  2. Confirm the response body (if any) describes the created resource, including its server-assigned id.
  3. Make sure creation really happened: a GET on the Location URL should return the new resource.
  4. If creation is asynchronous and not finished, 202 Accepted is the more accurate status.

201 compared with similar codes

  • 200: 200 means the request succeeded and returns a result. 201 specifically signals that a new resource now exists.
  • 202: 202 means the request was accepted but processing is not complete. 201 means the resource has already been created.
  • 204: 204 is success with no body, often for updates and deletes, and does not announce a new resource.

201 Created: common questions

Should a POST return 200 or 201?

Use 201 when the POST creates a new resource, and include a Location header. Use 200 (or 204) when it performs an action that does not create an addressable resource.

Does 201 require a response body?

No, but returning a representation of the created resource saves the client a second request.

Other success (2xx) codes