201 Created
The request worked and created a new resource. The Location header usually points to the URL of the new item.
What 201 Created means
Servers send 201 after a request creates something, most often a POST to a collection (POST /users) or a PUT to a URL that did not exist yet.
The response should include a Location header with the new resource's URL. Many APIs also return the created object in the body, which saves the client a second request.
If the work has only been queued and the resource does not exist yet, use 202 Accepted instead.
Headers that go with it
LocationETag
Example response
HTTP/1.1 201 Created
Location: https://example.com/new-page
ETag: "33a64df5"
Content-Type: text/plain; charset=utf-8
201 CreatedHow to check for a 201 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 201) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 201:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 201 {
fmt.Println(res.Status)
}Specification
201 Created is defined in RFC 9110, section 15.3.2.
Related status codes
- 200
The request worked. The response body holds the result, such as the page, file or JSON data the client asked for.
- 202
The server accepted the request for processing, but the work has not finished yet and may still fail later.
- 303
The server redirects the client to another URL that it must fetch with GET, typically after a form submission or other POST.