Skip to content
HTTP 201 Created — What It Means & How to Debug

HTTP 201 Created — What It Means & How to Debug

DodaTech Updated Jun 20, 2025 4 min read

HTTP 201 Created is the success response for resource creation — the server accepted the request and created a new resource, typically in REST APIs.

What It Means

The HTTP 201 Created status code indicates that a request has been fulfilled and resulted in one or more new resources being created. Unlike the generic 200 OK, 201 Created carries a specific semantic meaning: the primary action performed by the request was the creation of a resource on the server.

The response should include a Location header pointing to the URL of the newly created resource. The response body typically contains a representation of the created resource, allowing the client to immediately access the new entity without making an additional request.

When It’s Sent

  • POST requests to create a new user, order, or record
  • PUT requests that create a resource at a new URL (less common)
  • Bulk creation endpoints where multiple resources are created in a single request
  • File upload endpoints that create a new file resource on the server
  • Registration forms where submitting the form creates a new account

Real Example

curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"John Smith","email":"john@example.com"}' \
  -v

Expected response:

> POST /users HTTP/1.1
> Host: api.example.com
> Content-Type: application/json
>
< HTTP/1.1 201 Created
< Location: /users/42
< Content-Type: application/json
< Content-Length: 85
<
{"id":42,"name":"John Smith","email":"john@example.com","createdAt":"2025-06-20T12:00:00Z"}

Notice the Location header tells the client exactly where the new resource lives: /users/42.

How to Debug

Browser DevTools

  1. Open the Network tab
  2. Trigger the creation action (submit a form, click “Create”)
  3. Find the POST request in the list
  4. Click it and check the Status column — it should show 201 Created
  5. Verify the Location header in the Response Headers section
  6. Inspect the response body to confirm the created resource data

curl

curl -s -o /dev/null -w "%{http_code}\n%{redirect_url}" \
  -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name":"Test","email":"test@example.com"}'

The first line of output is the status code (201), the second is the Location URL if any.

Postman

Send the POST request with the body and headers. The status badge shows 201 Created in green. Check the Headers tab for the Location field and the Body tab for the created resource representation.

How to Fix

If you’re not receiving 201 Created when you expect it:

  • Server-side: Ensure the route handler explicitly sets 201 as the status code — for example, res.status(201).json(data) in Express or return Response(status=201) in Django REST Framework
  • Response body: Make sure the response includes a representation of the created resource, not just a success message
  • Location header: Include the Location header pointing to the new resource URL — this is a convention that many API clients rely on
  • Client-side: Verify the request method is POST (not GET or PUT) and that the Content-Type header matches what the server expects

Common Causes

ScenarioWhat HappensWhy It Matters
User registrationServer creates account and returns 201 CreatedClient knows the user was created and can redirect to the profile
Order placementServer creates order record with 201 CreatedShopping cart can be cleared and order confirmation shown
File uploadServer stores file and returns 201 CreatedUpload progress indicator can show completion
Blog post creationCMS creates post and returns 201 CreatedEditor can redirect to the new post URL
API resource creationBackend creates a database recordClient can use the Location header to fetch the full resource

FAQ

Should I return 200 or 201 for a POST request?
Return 201 Created if the POST request results in a new resource being created. Return 200 OK if the POST request performs an action (like processing data) without creating a new identifiable resource. The Location header is expected with 201 but not with 200.
What if the resource already exists? Should I still return 201?
No. If the resource already exists and no new resource was created, return 200 OK or 409 Conflict. The 201 Created status code specifically indicates that a new resource was brought into existence by the request.
Is the Location header required with 201 Created?
The HTTP specification says the Location header SHOULD be present in a 201 Created response. While it’s not strictly required, including it is a best practice that makes your API more discoverable and easier to consume, especially for REST clients that auto-navigate to created resources.

Related Codes

  • HTTP 200 OK — general success response
  • HTTP 204 No Content — success with no body, often used for DELETE
  • HTTP 400 Bad Request — the request body was invalid
  • HTTP 409 Conflict — resource already exists or state conflict

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro