📚 Quick Definition
The request has succeeded. For GET requests, the response contains the requested resource. For POST, it contains the result of the action. This is the most common HTTP status code and indicates that everything worked as expected.
⏱ When It Occurs
A 200 OK response is returned whenever the server successfully processes a client's request and has content to deliver. It is the default success response for most HTTP operations, meaning the server understood the request, accepted it, and returned the appropriate result.
🛠 Common Use Cases
- Standard response for successful GET, POST, PUT, or PATCH requests
- API returning requested data (e.g., fetching a user profile)
- Web page loading successfully in the browser
- Form submission processed and result returned
- Resource updated via PUT or PATCH with confirmation data
✅ Best Practices
- Always return appropriate content with a 200 response - the body should match what the client expects
- Use the correct Content-Type header (application/json for APIs, text/html for pages)
- Consider returning 201 Created instead when a new resource is created by the request
- Consider returning 204 No Content when the action succeeds but there is no body to return
- Use meaningful, well-structured response bodies for API endpoints
📡 HTTP Example
Request
GET /api/users/123 HTTP/1.1 Host: api.example.com Accept: application/json
Response
HTTP/1.1 200 OK Content-Type: application/json Content-Length: 85 { "id": 123, "name": "Jane Doe", "email": "jane@example.com", "role": "admin" }
❓ Frequently Asked Questions
When should I use 200 vs 201?
+
Use 200 OK when the request succeeds and you are returning existing data or the result of a general action. Use 201 Created specifically when a new resource has been created as a result of the request, such as after a POST that creates a new database record. The 201 response should also include a Location header pointing to the newly created resource.
Can a 200 response have an empty body?
+
Yes, a 200 response can technically have an empty body, but it is not recommended. If the server has successfully fulfilled the request and there is no additional content to send, a 204 No Content status code is more semantically appropriate. Using 204 clearly communicates to the client that the operation succeeded and no body should be expected.