2xx Success

HTTP 201 Created

The request has been fulfilled, resulting in the creation of a new resource.

When is 201 used?

  • POST requests creating a new user, post, or resource
  • RESTful API resource creation endpoints

How to handle a 201 response

No error handling is needed. Check that the response body and headers match what your client expects — for example, a 204 response has no body.

Check the status code a URL returns from the command line:

curl -s -o /dev/null -w "%{http_code}\n" https://example.com

How to return 201 from your server

Node.js (Express)

res.status(201).json({ message: 'Created' });

Python (Flask)

return {"message": "Created"}, 201

Go (net/http)

w.WriteHeader(201)

Frequently Asked Questions

What does HTTP 201 mean?

201 Created: The request has been fulfilled, resulting in the creation of a new resource.

Is 201 an error?

No. 201 is in the 2xx Success class. Success: the request was received, understood, and accepted.