201 Created

The request succeeded and created something new, usually named in the Location header.

Code
201
Reason phrase
Created
Class
2xx Success
Defined in
RFC 9110 section 15.3.2
Cacheable by default
No

What it means

Success: the request was received, understood and accepted.

When a server should send it. When a POST or PUT has created a new resource. Name it in a Location header so the client knows where it lives, and return a representation of it or a short description in the body.

Common causes. A POST or PUT to an API that creates a record.

What to do. Read the Location header for the address of the new resource.

How clients and crawlers treat it

Browsers and HTTP clients. Browsers treat it like 200 and render any body. API clients read the Location header for the new record; fetch() reports it with response.ok true.

Google Search. Googlebot waits a limited time for the content, then passes on whatever it received for indexing. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.

Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.

Example response

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

{"status": 201, "title": "Created"}

How to send 201

nginx
location /example {
    add_header Location '/api/orders/1042' always;
    return 201 'Created';
}
PHP
header('Location: /api/orders/1042');
http_response_code(201);
echo 'Created';
exit;
Node.js
res.writeHead(201, { 'Location': '/api/orders/1042', 'Content-Type': 'text/plain' });
res.end('Created');
Python (Flask)
# in a view function
return 'Created', 201, {'Location': '/api/orders/1042'}

Change the paths to suit. In nginx, add_header needs always to apply to error responses.

Related codes

All status codes · All 2xx codes

Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.