Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. HTTP response status codes
  5. 201 Created

201 Created

The HTTP201 Createdsuccessful response status code indicates that the HTTP request has led to the creation of a resource.This status code is commonly sent as the result of aPOST request.

The new resource, or a description and link to the new resource, is created before the response is returned.The newly-created items can be returned in the body of the response message, but must be locatable by theURL of the initiating request or by the URL in the value of theLocation header provided with the response.

Status

http
201 Created

Examples

Receiving a response indicating user creation

Let's assume there's a REST API for managing users with an endpoint athttp://example.com/users. In this example, we send aPOST request with the following body to create a user:

http
POST /users HTTP/1.1Host: example.comContent-Type: application/json{  "firstName": "Brian",  "lastName": "Smith",  "email": "brian.smith@example.com"}

After successful user creation, the201 Created response will look like this:

http
HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://example.com/users/123{  "message": "New user created",  "user": {    "id": 123,    "firstName": "Brian",    "lastName": "Smith",    "email": "brian.smith@example.com"  }}

Specifications

Specification
HTTP Semantics
# status.201

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp