200 200 OK
The request has succeeded and the server is returning the requested data.
What Is This?
The HTTP 200 OK status code is the standard success response. It indicates that the request has succeeded and the server is returning the requested data in the response body. The exact meaning depends on the HTTP method used: GET returns the resource, POST returns the action result, PUT returns the updated resource, and DELETE often returns a success message or empty body.
Common Causes & Solutions
Common Cause
Successful GET request returning a resource
Common Cause
Successful POST request creating or processing data
Common Cause
Successful PUT/PATCH request updating an existing resource
Common Cause
Successful DELETE request removing a resource
Structure 200 responses properly
Always include a meaningful response body with a 200 OK. For APIs, return the requested data or operation result in a consistent JSON format.
// Good 200 response structure
{
"success": true,
"data": {
"id": 123,
"name": "Example",
"createdAt": "2024-01-01T00:00:00Z"
}
}
// Node.js (Express) example
app.get('/api/users/:id', (req, res) => {
const user = findUser(req.params.id)
if (user) {
res.status(200).json({ success: true, data: user })
} else {
res.status(404).json({ success: false, error: 'User not found' })
}
})Cache 200 responses appropriately
Add Cache-Control headers to 200 responses for GET requests to improve performance. Use ETags for conditional requests to avoid sending unchanged data.
Cache-Control: public, max-age=3600 ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
Related Entries
More from this reference:
Frequently Asked Questions
What is the difference between 200 and 201?
200 OK means the request succeeded and the response contains data. 201 Created means the request succeeded and a new resource was created as a result, with the Location header pointing to the new resource URL.
Should I return 200 or 204 for DELETE?
204 No Content is preferred for DELETE operations since there is no body to return. However, 200 OK with a success message is also acceptable, especially when you want to confirm what was deleted.