201 Created
The 201 Created status code indicates that the request has been fulfilled with one or more new resources being created. The primary created resource is identified by the Location header if it exists, otherwise it is the request URI that was created. The response body is a document describing the results of the action, including links to other created resources.
Writing responses (servers)
If the request was successful and resulted in the creation of one or more resources, use the 201 (Created) status code.
If the request was a POST request or similar request that created a resource different than the request-URI, put the URI of the created resource in the Location header. If the request created more than one resource, pick a primary resource to use in the Location header, a resource that contains links to the other created resources.
If the request was a PUT, PATCH, or similar request that created the request URI, the Location header may be omitted; the created resource is understood to be the request URI.
Use the ETag and Last-Modified headers to send the metadata of the newly created resource (the resource in the Location header, if present, or the request target otherwise).
Reading responses (clients)
201 Created
indicates the operation resulted in the creation of a new resource.
If the request method was PUT or PATCH without a Location header, the request target was created to fill the request.
If the request method was POST or a similar method on an existing resource, and contains a Location header, then one or more resources were created; read the document at the Location header for information.
It is cachable, however 201 will not typically be sent in response to cachable methods.
If the response includes ETag or Last-Modified headers, this refers to the metadata of the primary resource created by the request. They may be used to populate conditional request headers in subsequent requests to that resource.
The response body may be empty, or a document that describes the result of the operation. There is no standardized format, so it may be a simple HTML document, or application-specific JSON document.
Overview table
- Name
- 201
- Message
- 201 Created
- Description
- One or more resources were created.
- Specification
- RFC 7231: HTTP/1.1 Semantics and Content ยง6.3.2. 201 Created
Example
HTTP/1.1 201 Created