A 201 status code is an HTTP response status code indicating that a request has been successfully fulfilled and that a new resource has been created. It is the standard response for an HTTP POST request that results in a creation.
How Can You Use a 201 Status Code?
A 201 status code indicates that a request has been fulfilled and a new resource has been created. When a client sends an HTTP POST request to a server, the server will typically respond with a 201 status code if the request has been successfully processed and a new resource has been created.
Common Uses
The 201 status code is commonly used whenever a new resource is created. This could be when a user registers for an account, creates a blog post, or adds a product to a shopping cart. It can also be used when a client sends a POST request to update an existing resource.
Format of the Response
When a server responds with a 201 status code, it should include a Location header that contains the URL of the newly created resource. This allows the client to easily access the newly created resource.
Example Usage
To illustrate how the 201 status code can be used, let’s look at an example. Suppose a user is creating an account on a website. The client would send a POST request containing the user’s information to the server. If the request is successful, the server would respond with a 201 status code, along with a Location header containing the URL of the user’s profile page.
The 201 status code is an HTTP response status code indicating that a request has been successfully fulfilled and that a new resource has been created. It is the standard response for an HTTP POST request that results in a creation. When a server responds with a 201 status code, it should include a Location header containing the URL of the newly created resource. The 201 status code is commonly used whenever a new resource is created or an existing resource is updated.