201Status code
2xxSuccess
NoCacheable by default
RFC 9110 §15.3.2Defined in
Common causes
- POST to a collection endpoint such as
/users - PUT that created a resource that did not exist
What to do
Return the new resource or its URL so the client does not need a second request.
Example response
HTTP/1.1 201 Created
Location: /users/42
Content-Type: application/json
{"id":42}
Returning 201 in code
Express res.status(201).json({ … });
Flask return jsonify(…), 201
PHP http_response_code(201);
Go w.WriteHeader(201)