API Design · Junior · Question 15 of 75
When should an API return 5xx codes?
- 1Never; errors should always be 200
- ✓Correct answer: When the failure is on the server side (bugs, unavailable dependencies), not because of the client's request
- 3When the client sends invalid data
Explanation
Clients and monitoring treat 4xx as client errors and 5xx as server errors. Returning 200 with an error body hides failures from both.