200 OK

HTTP response status code 200 OK is returned by the server to indicate success. The meaning of success and the accompanying message body vary based on the HTTP request that was sent.

The HTTP headers and message body are cacheable by default. If the default behavior needs to be overridden then the HTTP response must include the appropriate HTTP caching headers.

Usage

The 200 OK HTTP response always has a message body, although the server can optionally specify that it is of zero length. Depending on the server, this is expected behavior when submitting a PUT, DELETE, or OPTIONS HTTP request.

In cases where the server does not want to include an empty message body, the 204 No Content response status code will be returned. In the special case of a HTTP request, such as the POST method that is creating content, a 201 Created response status code will be returned.

GET

The HTTP GET response will contain the message body of the resource that has been requested.

Response

HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 10000

<message body will contain the requested PDF document>

The HTTP HEAD response will contain the HTTP headers but there will not be a message body.

Response

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8

POST

The HTTP POST response will typically contain information about the results of the action, or an indication of the progress status.

Response

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

{“success":"true"}

PUT

The HTTP PUT response will typically contain information about the results of the action, or an indication of the progress status.

Response

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 102

<html>
  <head>
    <title>Success</title>
  </head>
  <body>
    <p>Thank you!</p>
  </body>
</html>

TRACE

The HTTP TRACE response will contain the message body with the HTTP request message as it was received by the server.

DELETE

The HTTP DELETE response will include an indication of the progress status.

Response

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

{“deleted":"true"}

OPTIONS

The HTTP OPTIONS response will include a list of the HTTP request methods that are allowed by the server. These will be specified by the Allow HTTP header. Optionally, the server can specify further information in the message body about what is allowed.

Response

HTTP/1.1 200 OK
Allow: GET,HEAD,PUT,OPTIONS
Content-Type: text/plain;charset=UTF-8

Code references

.NET

HttpStatusCode.OK

Rust

http::StatusCode::OK

Rails

:ok

Go

http.StatusOK

Symfony

Response::HTTP_OK

Python3.5+

http.HTTPStatus.OK

Java

java.net.HttpURLConnection.HTTP_OK

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_OK

Angular

@angular/common/http/HttpStatusCode.Ok

Takeaway

HTTP response status code 200 OK indicates that the HTTP request was successful. Depending on the HTTP request, details and/or resources will be included in the message body.

See also

Last updated: June 29, 2022