Skip to content
Docs

API checks

Run up to 5 HTTP requests in order, pass values from one response to the next, and get alerted when any step fails.

Some things can't be tested with one request. To check that users can log in and load their account, you need to log in first, take the token from the response, and use it in the next request. An API check does exactly that.

How it works

  • An API check has 1 to 5 steps. Opush runs them in order on each check.
  • Each step is one HTTP request with its own checks.
  • A step can save values from its JSON response. Later steps use them with {{name}}.
  • If any step fails, Opush stops there. The check counts as failed.
  • The response time is the total for all steps.

API checks follow the same rules as other monitors: two failures in a row plus a second-location check before they're down. See Monitoring.

Add an API check

In the app, open Following, tap Add, choose Monitor, then Website, and pick API check. In the web console, go to Monitors, click Add monitor, and choose API check.

Step settings

Prop

Type

Each request waits up to 10 seconds. Redirects work like on website monitors: followed, unless you expect a 3xx status.

Save and reuse values

Give each value a name and a path into the JSON response.

ResponsePathValue
{"data":{"token":"abc"}}data.tokenabc
{"items":[{"id":42}]}items[0].id or items.0.id42
{"ok":true}oktrue
  • Paths use dots for keys and [n] (or .n) for list items. A leading $. is allowed.
  • The value must be text, a number, or true/false. An object, a list, or an empty value doesn't count.
  • Use short names with lowercase letters and digits, like token or userid. These work everywhere, including the iPhone app.

Write {{name}} in a later step's URL, header values, or body. Opush replaces it with the saved value.

If the response isn't JSON, or a path finds nothing, the step fails with Couldn't read the JSON value.

Example: log in, then load the account

Step 1: log in

SettingValue
MethodPOST
URLhttps://api.example.com/login
HeadersContent-Type: application/json
Body{"email":"monitor@example.com","password":"…"}
Expected status200
Save valuestoken = data.token

Step 2: load the account

SettingValue
MethodGET
URLhttps://api.example.com/me
HeadersAuthorization: Bearer {{token}}
Expected status200
Must containmonitor@example.com

Use a test account

Request bodies are stored as you type them and aren't hidden. Create a separate account with no real data or permissions for monitoring.

Example: a value in the URL

This checks that the latest release of a GitHub repo can be loaded:

StepURLSave values
1https://api.github.com/repos/OWNER/REPOname = full_name
2https://api.github.com/repos/{{name}}/releases/latest—

The same check as JSON

If you work with the API, steps look like this:

{
  "type": "api",
  "name": "Login flow",
  "interval": 5,
  "steps": [
    {
      "method": "POST",
      "url": "https://api.example.com/login",
      "headers": [{ "name": "Content-Type", "value": "application/json" }],
      "body": "{\"email\":\"monitor@example.com\",\"password\":\"…\"}",
      "expect_status": "200",
      "extract": { "token": "data.token" }
    },
    {
      "url": "https://api.example.com/me",
      "headers": [{ "name": "Authorization", "value": "Bearer {{token}}" }],
      "expect_status": "200",
      "contains": "monitor@example.com"
    }
  ]
}

When a step fails

The push says which step failed and why:

Login flow
Down
Step 2 · HTTP 401 · confirmed from Western Europe

In the app and the web console, the monitor shows the failed step too.

Edit steps

You can add, remove, and change steps anytime. Saving replaces the whole list of steps. API checks don't get domain and certificate expiry reminders. Add a website monitor for that.