Monitor types

API (JSON) monitors

Monitor REST and health endpoints with custom methods, headers and bodies, then assert a value in the JSON response with a simple path.

Last updated: 3 min read

API type
api
You enter
URL
Runs at most every
Plan minimum
Needs
None

How it works

FastPing sends the request with your method, headers and body, applies the same status-code, redirect and timeout rules as a website monitor, and then, if you set a JSON path, parses the response as JSON and compares the value at that path with the expected value.

  • The body is sent for POST, PUT and PATCH requests only. When you send a body without a Content-Type header, application/json is used.
  • Headers are written one per line as Name: value.
  • Only the first 512 KB of the response are read, so very large responses cannot be parsed.

Settings

FieldAPI optionDefaultNotes
URLurlRequiredhttp:// or https:// address; https:// is added when you leave out the scheme
MethodmethodGETOne of: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS
Expected status codesexpectedStatusNoneUp to 60 characters
Timeout (seconds)timeout152 to 60
Warn if slower than (ms)maxMsNone0 to 60,000
Follow redirectsfollowRedirectsOn
Request headersheadersNoneUp to 4,000 characters. One per line, "Name: value".
Request bodybodyNoneUp to 10,000 characters
JSON path to checkjsonPathNoneUp to 200 characters
Expected valuejsonExpectedNoneUp to 200 characters
Check intervalintervalYour plan's minimumFrom your plan's minimum up to 24 hours

JSON path and expected value

The path is a list of keys separated by dots. Array elements are addressed by their position, starting at 0. There are no wildcards or filters, and the path does not start with $.

For this response:

JSON
{
  "status": "ok",
  "checks": { "database": "ok", "queue": { "lag": 3 } },
  "regions": [ { "name": "eu", "healthy": true } ]
}
PathValue
statusok
checks.databaseok
checks.queue.lag3
regions.0.healthytrue

The comparison is on the text form of the value, so the expected value true matches the boolean true and 3 matches the number 3. It is case-sensitive. Leave the expected value empty to check only that the response is valid JSON. A path that does not exist gives the value undefined and fails when an expected value is set.

Examples

Health endpoint with a dependency check

URL https://api.example.com/health, JSON path checks.database, expected value ok.

Authenticated endpoint

Request headers:

HTTP
Authorization: Bearer <read-only token>
Accept: application/json

Header values are stored with the monitor's configuration, are visible to your team and are included in data exports. Use a dedicated token with the least access possible.

GraphQL

Method POST, URL https://api.example.com/graphql, request body {"query":"{ __typename }"}, JSON path data.__typename, expected value Query.

Common errors

MessageWhat it meansWhat to do
Response is not valid JSONA JSON path is set but the body could not be parsed: an HTML error page, an empty body or a response larger than 512 KB.Open the URL with the same headers (for example with curl) and check what comes back.
checks.database = "degraded" (expected ok)The value at the path differs from the expected value.The service reports a problem; fix it, or adjust the expected value if the response format changed.
status = undefined (expected ok)The path does not exist in the response.Check the spelling and the nesting of the keys, and remember that arrays use positions (items.0.id).
HTTP 401The endpoint rejected the credentials.Check the Authorization header and whether the token expired.
HTTP 405The method is not allowed on this URL.Use the method the endpoint expects.

Connection and certificate errors are listed in Website (HTTP) monitors.

Still need help?

Write to us and a person will answer, usually within one business day.