This section outlines some of the most common status codes in use in HTTP APIs, their meaning, and some notes about when they can be used.
Code | Meaning | Notes |
---|---|---|
|
Continue |
For a large request, a client can send just the headers and |
|
OK |
This is good news; everything worked as expected. |
|
Created |
A new resource was created. This is often accompanied by a |
|
Accepted |
This is useful if something is taken to be actioned later, such as being placed on a queue for asynchronous processing. |
|
No Content |
The request was successful, but there is nothing to return. Perhaps this is the result of a |
|
Moved Permanently |
The content is at a new location, and this is a permanent change. Links to the old URL must be updated, and this change will often be cached for long periods. |
|
Found |
This is much like a |
|
Not Modified |
This is sent in response to a request that included information such as an |
|
Bad Request |
This is the general “something went wrong” status. Sometimes there may be no more detail to offer; at other times, you may choose not to transmit anything more. |
|
Unauthorized |
Credentials are needed in order to access this resource. |
|
Forbidden |
This contrasts with |
|
Not Found |
A request was made for something the server doesn’t have or doesn’t know how to provide. Alternatively, a request was made for a resource that isn’t available to this user and the 404 doesn’t leak information about the potential existence of such a resource. |
|
Method Not Allowed |
The verb used to access this URL isn’t supported—this is useful if, for example, you don’t allow updates to a resource but a |
|
Not Acceptable |
The server cannot generate a response in accordance with the |
|
Conflict |
There is a mismatch between versions of resources, such as an incoming update when the resource has changed in the meantime. |
|
Gone |
A resource did exist, but doesn’t any more. Many services will simply return a |
|
Unsupported Media Type |
The media type specified in the |
|
Too Many Requests |
Usually used with rate-limiting schemes, although Twitter uses |
|
Internal Server Error |
An unhandled error occurred, and is the fault of the server rather than the client. In PHP applications, PHP has usually segfaulted, leaving the web server unable to return any useful information. |
|
Not Implemented |
The server can’t handle this request; it may also indicate that a documented feature is currently still under construction. |
|
Bad Gateway |
This indicates that a proxy server of some sort has failed, such as a load balancer. |
|
Service Unavailable |
This is usually seen when a server is temporarily offline, such as during a planned maintenance window. Often, it really means “try again later” but it also discourages caching, and is particularly useful to stop search engines from finding and caching your temporary holding page. |
For a full list of status codes, there is an excellent reference on Wikipedia.