What is the difference between HTTP status codes 200, 201, and 204?
Quick answer
All three codes indicate success, but they communicate different outcomes. Use 200 OK for a successful request when response content is returned; it does not, by itself, mean a resource was created. Use 201 Created when the request created a resource. Use 204 No Content when the request succeeded and returns no content—the response must not contain a body. [S1] [S2] [S3]
The question, the details, the next step.
A practical checklist
Confirm that the request succeeded before choosing among these success codes.
If the request created a resource, consider 201 and ensure the resource is locatable.
If returning response content without creating a resource, consider 200.
If returning no content, consider 204 and send no response body.
Check the endpoint contract and apply status meanings consistently.
A few more useful answers
Does a POST request always use 201?
Can a 201 response have an empty body?
It may include the created resource or a description and link. The key meaning is that a resource was created and must be locatable by the request URL or a URL in Location. [S2]
Can a 204 response include a message in its body?
No. A 204 indicates success with no response content, and its response must not contain content. [S3]
Sources
References used for this guide.
- [S1] 200 OK — HTTP | MDN developer.mozilla.org · Checked
- [S2] 201 Created — HTTP | MDN developer.mozilla.org · Checked
- [S3] 204 No Content — HTTP | MDN developer.mozilla.org · Checked
