Skip to content

200 OK — Meaning, Common Causes & How to Fix

200 2xx Success RFC 9110 §15.3.1

200 OK means: The request succeeded and the response carries the representation or result the client asked for. It is the default success code for GET, and for POST/PUT when the server returns a meaningful body describing the outcome. Success 2xx codes confirm the request was received, understood and accepted. The family distinguishes what kind of success happened — content returned, resource created, work queued, or nothing to return — and choosing the precise code is part of a well-designed API contract that clients and caches can rely on. In practice you will meet 200 when a get request retrieves a resource successfully; a post performs an action and returns a result document; an api returns data with no more specific success code applicable. On the client side, nothing to fix — parse the body according to Content-Type. Do not assume 200 means 'created' or 'accepted'; check the payload semantics. On the server side, return 200 with correct Content-Type and caching headers; prefer more specific codes (201, 202, 204) when they describe the outcome better.

Advertisement
Ad slot · ref-top

When 200 happens

  • A GET request retrieves a resource successfully
  • A POST performs an action and returns a result document
  • An API returns data with no more specific success code applicable

How to fix it

On the client

Nothing to fix — parse the body according to Content-Type. Do not assume 200 means 'created' or 'accepted'; check the payload semantics.

On the server

Return 200 with correct Content-Type and caching headers; prefer more specific codes (201, 202, 204) when they describe the outcome better.

Should you retry?

Success — nothing to retry.

Debugging steps

When 200 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Success codes rarely need debugging, but verify the body semantics match the code — a 200 wrapping an error payload is an API design bug, not a transport problem. For this code specifically, check whether the most common trigger applies to your situation: a get request retrieves a resource successfully. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.

Notes & gotchas

200 is heuristically cacheable when Last-Modified is present, so always set explicit Cache-Control on API responses; otherwise browsers and proxies may cache data you intended to be fresh.

Examples

Raw HTTP
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 70

{
  "id": 12345,
  "status": "ok",
  "message": "OK example payload"
}
curl
curl -i https://api.example.com/v1/resource   # observe the 200 response and its headers
JavaScript (fetch)
const res = await fetch("https://api.example.com/v1/resource");
if (res.ok) {
  const data = await res.json(); // 200 OK
  return data;
}
Python (requests)
import requests

res = requests.get("https://api.example.com/v1/resource", timeout=10)
res.raise_for_status()
data = res.json()  # 200 OK

Frequently asked questions

Should every successful API call return 200?

No. Use 201 for resource creation, 204 for success without a body, and 202 for async acceptance. 200 is the general-purpose success code.

Can a 200 response contain an error?

Technically yes — some APIs wrap errors in a 200 body. That is an anti-pattern: clients and caches rely on status codes, so use real 4xx/5xx for failures.

Which 2xx code should my API return?

200 for a normal result, 201 when a resource was created (with Location), 202 when work is queued, 204 when there is nothing to return. Precision here makes clients, caches and monitors behave correctly.

Can I treat any 2xx as interchangeable success?

For 'did it work' yes, but the distinctions matter operationally: 201 means a resource exists, 202 means work is still pending, 204 means there is no body to parse. Code that ignores them breaks.

Advertisement
Ad slot · ref-in-article

Try the JSON Validator

Check JSON syntax and locate errors by line and column.

Open tool →