201 Created

HTTP response status code 201 Created is returned by the server to indicate that a resource was successfully created by the HTTP request.

Usage

When the 201 Created status code is received, it is in response to an operation using the POST method, and indicates that the resource was uploaded for the first time. The HTTP response will optionally contain the Location HTTP header field to indicate where the resource was created. If the Location HTTP header is not included then it is the path originally specified by the HTTP request.

Example

In the example, the client uploads XML data to the server and specifies /incoming/xml as the destination path. The server responds by acknowledging that the data was accepted and a file named article_1.xml was created.

Request

POST /incoming/xml HTTP/1.1
Host: www.example.re
Content-Type: application/xml
Content-Length: 104
<?xml version="1.0">
<article>
  <title>Test XML article</title>
  <author>Anonymous</author>
</article>

Response

HTTP/1.1 201 Created
Location: /incoming/xml/article_1.xml
Content-Type: application/json
Content-Length: 19

{“success":"true"}

Code references

.NET

HttpStatusCode.Created

Rust

http::StatusCode::CREATED

Rails

:created

Go

http.StatusCreated

Symfony

Response::HTTP_CREATED

Python3.5+

http.HTTPStatus.CREATED

Java

java.net.HttpURLConnection.HTTP_CREATED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_CREATED

Angular

@angular/common/http/HttpStatusCode.Created

Takeaway

HTTP response status code 201 Created indicates that data was received and saved as a new resource on the server, and that the HTTP request did not overwrite or update existing data on the server.

See also

Last updated: August 2, 2023