How do I monitor a JSON API endpoint?
Part of API endpoint monitoring — the full answer, the facts and the alternatives in one place.
Quick answer
How do I monitor a JSON API endpoint?
Send a scheduled HTTP request to the endpoint, assert that the status code is 2xx and the response body contains an expected JSON field (e.g. "status":"ok"), and alert when either check fails twice in a row.
- Use GET for read endpoints, POST with a small idempotent payload for write endpoints.
- Set a hard timeout (5–10 s) — an API that takes 30 s to answer is effectively down.
- Test authenticated endpoints with a scoped monitoring token, not a production admin key.
- Assert on JSON body content, not just HTTP status — 200 OK with an error payload is common.
Step-by-step
- 1Pick the endpoint
Choose a read endpoint that reflects downstream health (e.g. /api/health that pings the DB).
- 2Add auth if needed
Attach a scoped monitoring token via a custom header — never a production admin key.
- 3Define the assertion
Require HTTP 2xx AND a JSON body containing the expected field like "status":"ok".
- 4Set the timeout + confirmation
10-second hard timeout, alert only after 2 consecutive failures.