Example HTTP Response
HTTP/1.1 200 OK
Content-Type: application/json
{"status": "success"}- Successful GET request returning data
- Successful POST request completing action
- Any successful HTTP operation
What does this mean?
Everything is awesome! Your request was perfect and here's exactly what you asked for.
Technical Definition
The request succeeded. The meaning of success depends on the HTTP method used.
RFC Says
"The 200 (OK) status code indicates that the request has succeeded. The payload sent in a 200 response depends on the request method."
Plain English:
200 means 'success!' The exact meaning depends on what type of request you made - GET returns the data you asked for, POST confirms your action was processed, etc.
Common Misinterpretation
Some developers mistakenly use 200 for all responses, even errors. If an operation failed, use a 4xx or 5xx status code, not 200 with an error message in the body.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(200).json({
error: 'OK',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'OK',
message: 'Your error message here'
}));
}).listen(3000);