200 OK
The request succeeded and the response body carries the result. What "the result" is depends on the method you used.
What 200 means for each method
200 is the plain success code, but the body means something different for each method:
| Method | Body of a 200 response |
|---|---|
| GET | A representation of the resource you asked for |
| HEAD | Nothing: the same headers as GET, without the data |
| POST | The status of the action, or the results it produced |
| PUT, DELETE | The status of the action |
| OPTIONS | The communication options for the resource |
A 200 is expected to have content. If the server has nothing to say, 204 No Content is the code for that, and a 200 with an empty body should at least carry Content-Length: 0.
A 200 answer to a GET can be cached without any Cache-Control header: the specification lets caches estimate a lifetime for it. Responses to POST are only cacheable when they carry explicit freshness information.
When a different 2xx or 3xx code is more precise
- The request created something: send 201 Created with a
Locationheader. - The work is queued and not finished: 202 Accepted.
- You are returning only part of a file in answer to a
Rangeheader: 206 Partial Content. - The client sent
If-None-MatchorIf-Modified-Sinceand its copy is still current: 304 Not Modified, with no body.
An empty search result or an empty list is still a 200. The request worked; the answer happens to be [].
The 200 that is really an error
The most damaging misuse of 200 is sending it with a failure inside the body.
- Soft 404. A "page not found" message, or a nearly empty page, delivered with status 200. Google Search Console reports these as soft 404s because the status says one thing and the content another. Single-page apps cause it when the web server answers every unknown path with
index.html. - API errors in a 200. A body such as
{"success":false}behind a 200 defeats everything that reads the status line:response.okinfetchis true, retry logic does not fire, monitoring counts a success and a CDN may cache the failure. - Login pages and captive portals. You asked for JSON and received an HTML sign-in form with status 200, because a proxy or session filter answered in place of the API.
If the request failed, say so in the status: 400, 401, 404, 500 or whichever code fits.
Checking what a 200 actually delivered
As a client, do not treat the status as proof that the body is what you wanted:
- Check
Content-Typebefore parsing. HTML where you expected JSON nearly always means a login page, an SPA fallback or an error page from a proxy. - Look at the
Ageheader. A non-zero value means a cache answered, and the content may be older than you think. - Use
curl -ito see the status line, headers and body together, without a browser cache in the way.
As a site owner:
- Make error handlers set the status as well as render the page. Test with
curl -I https://example.com/no-such-page; it must not say 200. - Point health checks at an endpoint that verifies its dependencies, and have the monitor check the body, not only the code.
- Set
Cache-Controlon purpose. Without it, caches are free to guess how long a 200 stays fresh.
200 compared with 201, 204 and 304
| Code | Body | Typical use |
|---|---|---|
| 200 OK | The result | GET, and POST or PUT that return data |
| 201 Created | Usually the new resource | POST or PUT that created something |
| 204 No Content | None allowed | DELETE, or an update with nothing to return |
| 304 Not Modified | None allowed | A conditional GET whose cached copy is still valid |
Example 200 response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 40
Cache-Control: max-age=60
ETag: "8123-v4"
{"id":8123,"status":"shipped","items":2}Cache-Control states how long the answer may be reused, and the ETag lets the client revalidate it later with If-None-Match and get a 304 if nothing changed.
Defined in RFC 9110, section 15.3.1.
Questions
Does 200 OK mean everything worked?
It means the server handled the HTTP request successfully. It cannot tell you that the body is what you expected: a soft 404, a login page or an error object can all arrive with status 200. Check the content type and the body as well.
Should an API return 200 with an error message in the body?
No. Clients, proxies, caches and monitoring all act on the status code, so an error hidden in a 200 is retried wrongly, cached and counted as a success. Use a 4xx or 5xx status and put the detail in the body.
Is a 200 response cached?
It can be. A 200 answer to a GET is cacheable by default, so without a Cache-Control header a browser or CDN may store it and estimate how long to keep it. Send Cache-Control to decide that yourself, for example no-store for private data.
Should DELETE or PUT return 200 or 204?
Either is correct. Use 200 when the response has a body, such as the updated record or a status message, and 204 when there is nothing to send back.