An API can answer quickly with the wrong thing: an error object with status 200, an empty list or a login page. A Website or API monitor with response checks catches those cases.
Create the monitor
- Open Monitors, choose New monitor and pick Website or API.
- Enter the endpoint URL and choose how often to check under Check every.
- In the Request and response card, choose Keyword, headers and more.
The request
- Method: GET, HEAD, POST, PUT, PATCH, DELETE or OPTIONS.
- Request headers: one per line as
Name: value, such as an API key orAccept: application/json. - Request body, for example JSON for a POST.
- Follow redirects, Verify TLS certificate and Timeout (s).
The response
- Expected status codes: codes or ranges, such as
200-299, 301. Any other status counts as down. - Keyword: text the response must, or must not, contain. It is case-sensitive.
- Response checks: JSON fields and headers, such as
$.statusequalsok. Up to 10, and all must hold.
Use Test request to see the response before you save.
Slow responses and timing
Set Alert when slower than (ms), for example 2000. When three checks in a row are slower than that, the monitor turns slow and your channels get a slow alert; slow time doesn’t count as downtime. Each check’s response time is split into DNS, connect, TLS, server and download, so you can see where the time goes. See alerts for slow responses.
APIs with several steps
When one call depends on another, such as logging in to get a token, use a multi-step flow instead.
Use a dedicated health endpoint where you can; see how to build a health check endpoint and the API monitoring checklist. More on API monitoring.