200 OK
The request worked. The response body holds the result, such as the page, file or JSON data the client asked for.
What 200 OK means
200 is the standard success code. What the body contains depends on the method: for GET it is the resource, for POST it is usually the result of the action, and for HEAD there is no body, only the headers a GET would return.
If a successful response has nothing to send back, 204 No Content is clearer. If the request created something, 201 Created tells the client where the new item lives.
A 200 only means the HTTP exchange succeeded. A page that says "not found" but returns 200 is a soft 404, and Google Search Console reports it as an error, so send real error codes for real errors.
Example response
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
200 OKHow to check for a 200 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 200) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 200:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 200 {
fmt.Println(res.Status)
}Specification
200 OK is defined in RFC 9110, section 15.3.1.
Related status codes
- 201
The request worked and created a new resource. The Location header usually points to the URL of the new item.
- 204
The request worked and there is nothing to send back. The response has no body, and the browser stays on the current page.
- 304
The cached copy is still valid, so the server sends no body and the client loads the resource from its own cache.