# HTTP 201 Created — Status Code Meaning & Examples

> The request created a new resource, usually identified by the Location header.

201 tells the client that something new now exists. The response should include a `Location` header pointing at the new resource's URL, and the body usually returns its representation — including server-assigned fields such as the id and timestamps — so the client doesn't need a second request.

- Class: 2xx Success
- Retry: Not applicable
- Cacheable by default: no
- Defined in: [RFC 9110 §15.3.2 — 201 Created](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.3.2)

## Example response

```http
HTTP/1.1 201 Created
Location: /users/42
Content-Type: application/json
```

## When you'll see it

- A POST to a collection created an item (`POST /users` → `/users/42`).
- A PUT created a resource at a URL that didn't exist before. Updating an existing one returns 200 or 204.

## How to use it well

1. Set `Location` to the new resource's URL.
2. Return the created object in the body — clients almost always need the generated id.
3. If creation is queued and happens later, use 202 Accepted instead.

## Send a 201 from your server

### Express

```
res.set("Location", "/users/42");
res.status(201).json(result);
```

### Next.js route handler

```
return Response.json(result, { status: 201, headers: { "Location": "/users/42" } });
```

### Flask

```
return result, 201, {"Location": "/users/42"}
```

### Go net/http

```
w.Header().Set("Location", "/users/42")
w.WriteHeader(http.StatusCreated)
```

### nginx

```
add_header Location "/users/42" always;
return 201;
```

## FAQ

### 201 or 200 for a POST?

201 when the POST created a resource you can address afterwards. 200 when it performed an action — sending an email, running a search — that didn't create anything.

### Is the Location header required?

Not strictly: RFC 9110 says the new resource is identified by Location if present, otherwise by the request URL. In practice, always send it.

## Related status codes

- [200 OK](https://www.devkult.com/http/200.md)
- [202 Accepted](https://www.devkult.com/http/202.md)
- [204 No Content](https://www.devkult.com/http/204.md)
- [409 Conflict](https://www.devkult.com/http/409.md)

Open the interactive page: https://www.devkult.com/http/201