201 Created
A new resource was created (usually after POST); Location points to it.
Common causes
- A POST / PUT successfully created a new record (user, order…)
How to fix
- Return a Location header pointing to the new resource
- If nothing new was created, use 200 or 204 instead of 201
Detailed reference (MDN) ↗RFC 9110 §15.3.2 ↗
Which code should I use?
- 200 / 201 / 204: 200: success with content. 201: a new resource was created (with Location). 204: success with no body (common for DELETE / PUT).
