Why this matters
Correct semantics enable clients and monitors to react properly.
Return 2xx only on success; use 4xx for client errors and 5xx for server errors, with a minimal JSON error body.
Correct semantics enable clients and monitors to react properly.
Side-by-side examples engineers can pattern-match during review.
http_response_code(200);
echo json_encode(['error'=>'failed']);http_response_code(400);
header('Content-Type: application/json');
echo json_encode(['error'=>'invalid_request']);200 + error body400 + {"error":"..."}From the same buckets as this rule.