HTTP 201 Created — What It Means & How to Debug
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"}' \
-vExpected 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
- Open the Network tab
- Trigger the creation action (submit a form, click “Create”)
- Find the POST request in the list
- Click it and check the Status column — it should show
201 Created - Verify the
Locationheader in the Response Headers section - 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
201as the status code — for example,res.status(201).json(data)in Express orreturn 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
Locationheader pointing to the new resource URL — this is a convention that many API clients rely on - Client-side: Verify the request method is
POST(notGETorPUT) and that theContent-Typeheader matches what the server expects
Common Causes
| Scenario | What Happens | Why It Matters |
|---|---|---|
| User registration | Server creates account and returns 201 Created | Client knows the user was created and can redirect to the profile |
| Order placement | Server creates order record with 201 Created | Shopping cart can be cleared and order confirmation shown |
| File upload | Server stores file and returns 201 Created | Upload progress indicator can show completion |
| Blog post creation | CMS creates post and returns 201 Created | Editor can redirect to the new post URL |
| API resource creation | Backend creates a database record | Client can use the Location header to fetch the full resource |
FAQ
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