HTTPfy

201 Created

The request succeeded and created a new resource, usually identified by the Location header.

201 at a glance

Code
201
Name
Created
Class
2xx Successful
Status
IANA-registered standard code
Defined in
RFC 9110, Section 15.3.2
Cacheable by default
No by default. Caches store it only when the response carries explicit freshness (Cache-Control max-age, s-maxage or Expires).

What 201 means

201 Created tells the client a new resource now exists. The Location header should point to it (otherwise the target URI is the new resource), and the body typically describes it. REST APIs return 201 for successful POST, and PUT returns 201 when it creates rather than replaces.

What typically causes a 201

  • A successful POST to a collection, such as creating a user or order.
  • A PUT to a URL that did not exist yet, e.g. uploading a new file over WebDAV.

Fix it on the server

  • Include Location with the URL of the new resource; clients and API tooling rely on it.
  • If creation is queued rather than done, return 202 Accepted instead.
  • Return an ETag if clients may update the resource conditionally later.

Fix it as a client or visitor

  • Read the Location header rather than building the new URL yourself.
  • Do not blindly retry a POST that timed out: it may already have produced a 201. Use idempotency keys where the API offers them.

Headers that go with 201

HeaderRole
LocationURL of the created resource.
ETagValidator of the new resource, for later If-Match updates.

Example response

HTTP/1.1 201 Created
Location: /api/orders/8841
Content-Type: application/json

{"id": 8841, "status": "pending"}

Opens the HTTP headers tool with your URL filled in; it shows the status line and headers of every redirect hop.