Definition
The expected status code is the HTTP response code your monitor considers a success. Most healthy endpoints return 200 (OK), but some health checks return 204 (No Content) or other codes. Whatever you set, a response that doesn't match marks the check as failed.
Setting this correctly is what makes "up" mean genuinely working. Without it, a monitor might accept any response — including 500 errors or redirects — as healthy, defeating the purpose of monitoring.
Why It Matters
The expected status code is how monitoring distinguishes a working endpoint from a broken one. An endpoint returning 500 is down for users; if your monitor accepts it as fine, you'll never get alerted. Matching the expected code to your endpoint's real healthy response makes alerts trustworthy.
How It Works
You configure the code (or codes) that count as healthy for each monitor. On every check, the monitor compares the actual response code to the expected one: a match passes, a mismatch fails. This runs after the response arrives within the timeout, so both timing and correctness are validated.
Real-World Example
A health endpoint returns 204 No Content when healthy. The team sets the expected status code to 204. Later a bug makes it return 500; because 500 ≠ 204, the check fails and alerts fire — exactly the behavior you want.
Best Practices
- Set the expected code to match what your endpoint returns when healthy
- Use 200 for most pages and APIs, 204 for empty health responses
- Don't accept broad ranges that would let error codes pass
- Update the expected code if your endpoint's healthy response changes
- Pair status-code checks with response-time thresholds for full coverage
Common Mistakes
- Leaving the expected code so loose that 500s count as healthy
- Expecting 200 from an endpoint that returns 204 or a redirect
- Treating redirects (3xx) as success when they shouldn't be
- Not updating the expected code after changing the endpoint
- Relying on status code alone without checking response time
In Monitoristic
In Monitoristic you set the expected status code per monitor (for example 200 or 204). Any other code marks the check as down, so your alerts reflect real failures rather than just whether something responded.