When a POST request creates a resource, HTTP 201 Created tells the client the job is done. The response may point to the new resource with a Location header and include its details in the body. It’s a small protocol signal that keeps APIs clear and predictable.

Multiple Choice

What HTTP status code indicates a successful POST creating a resource?

When a POST creates a new resource, the server uses a 201 Created response to signal that the resource was successfully created. This status code explicitly conveys creation, and it's common for the response to include the URL of the new resource in the Location header, with a representation of the resource in the body. This distinguishes creation from other kinds of success. Other codes described here don’t fit the scenario: 101 is Switching Protocols, which is about changing the communication protocol; 301 is Redirect, guiding the client to a different URL; and 401 is Unauthorized, indicating authentication is required. While there are other success responses (like 204 No Content if nothing is returned), 201 is the standard when a new resource is created.

Why HTTP Uses 201 Created When a POST Adds a Resource

When a client sends data to a server and the server creates a new resource from it, HTTP has a status code for that moment: 201 Created. It’s a small number with a clear message. The request succeeded, and something new now exists on the server.

That distinction matters more than it might seem. A response can say that a request worked without saying how it worked. HTTP status codes add that context, helping browsers, apps, developers, and monitoring tools understand what happened without guessing.

A success response with a specific meaning

A status code beginning with 2 signals that the server successfully handled the request. But the codes in that group aren’t interchangeable. 200 OK, for instance, is a broad success response. It often means the server processed a request and returned a representation, such as a page or a list of records.

201 Created is more specific. It tells the client that the request succeeded by creating a resource. That might be a new account, a saved document, an order, or a comment. The status works like a receipt: the operation wasn’t merely accepted or processed; it resulted in a new thing.

Imagine sending a request to an online bookstore to create an order. If the server returns 201, the client can understand that the order now exists. The response may also include details about it, such as an order number or its current status. No cryptic guesswork needed.

How POST fits into the picture

HTTP defines several methods, each with a general role. POST is commonly used when a client sends data for a server to process. One common result is the creation of a new resource.

For example, an application might send a request to:


POST /orders

Content-Type: application/json

{

"item": "notebook",

"quantity": 2

}

The server could create an order and respond like this:


HTTP/1.1 201 Created

Location: /orders/8472

Content-Type: application/json

{

"id": 8472,

"item": "notebook",

"quantity": 2,

"status": "received"

}

Here, the status code reports the outcome. The Location header points to the new order, while the response body gives the client a useful description of it.

The exact URL and response format depend on the API. Some services return a full representation; others include only a few fields. The key idea stays the same: the server created a resource and tells the client where it can be found.

The Location header points the way

A response with 201 often includes a Location header. This header provides a URI for the newly created resource. In the example above, /orders/8472 identifies the particular order, rather than the general collection at /orders.

That small pointer can make an API easier to use. After creating an order, a client may need to retrieve it, update it, or check its status. The Location header gives the client a direct route, much like a tracking number printed on a shipping receipt.

The header is common, but its presence isn’t the whole definition of 201. The central meaning is that the request led to the creation of a resource. The response body may also describe that resource, though HTTP does not require every service to return a detailed representation.

Why not just send 200 OK?

A server could sometimes use 200 for a successful POST, depending on what the request did and what the API intends to report. HTTP allows different success responses because not every successful request has the same result.

If a POST creates a new resource, 201 communicates that outcome more clearly. If the server processes a request but doesn’t create a new resource, another success code may fit better. For example, a server might return 204 No Content when it has completed an operation but has no response body to send.

The difference is useful for both people and software. A developer reading server logs can quickly spot resource creation. An application can respond differently when it sees a new record than when it receives a general success message. Clear status codes reduce ambiguity, especially as an API grows and many teams rely on it.

A few nearby codes—and why they mean something else

Several HTTP codes can appear in the same conversations, but they describe different events.

  • 101 Switching Protocols means the server is agreeing to change the communication protocol, such as during a WebSocket connection upgrade. It isn’t a signal that a resource was created.

  • 301 Moved Permanently tells a client that a resource has a new permanent location. The response points elsewhere; it doesn’t report the creation of a new resource.

  • 401 Unauthorized means the request lacks valid authentication credentials or needs proper authentication. Despite the name, it generally concerns authentication, not permission to create something.

These codes serve different parts of the web’s communication system. One concerns a protocol change, another a move, and another authentication. HTTP’s status line is compact, but each code carries a distinct bit of meaning.

Creation isn’t the same as acceptance

There’s another useful comparison: 202 Accepted. It means the server has accepted a request for processing, but the work may not be finished yet. This often happens with long-running tasks, such as generating a large report or processing a batch of files.

By contrast, 201 says the resource has been created. The distinction is a little like placing an order versus receiving confirmation that the order record exists. A job may be in a queue before its result is ready; a created resource is already there, even if it can change later.

Choosing the right response helps clients set sensible expectations. A client receiving 202 might check back for progress. A client receiving 201 can often follow the Location URI to view the new resource.

A note about repeated requests

POST is generally not considered idempotent. In plain language, sending the same POST request twice may create two resources rather than one. If a mobile app loses its connection after sending an order request, it may be unclear whether the server received it. Retrying could then produce a duplicate order.

That behavior isn’t a flaw in 201; it’s a reminder that status codes and request methods work together. API designers may use an idempotency key or another safeguard when duplicate creation would cause trouble. The details vary by service, but the goal is straightforward: help the server recognize when a retry refers to the same intended operation.

Clear responses make better APIs

A well-designed API gives clients more than a vague sign that “something worked.” It reports what happened in a way that software can interpret and people can troubleshoot. When a POST creates a resource, 201 Created provides that clear signal. A Location header can then point to the new resource, and a response body can share useful details.

HTTP’s codes may look like tiny labels, but they shape how systems cooperate. Use 201 for creation, and the response tells a concise story: the request succeeded, a new resource exists, and here’s where to find it.