API & automation

REST API quick start

Create an API key, authenticate with a bearer token and manage monitors from scripts and CI: endpoints, limits, errors and copy-paste examples.

Last updated: 3 min read

Requirements

The API is part of the REST API access add-on ($5 a month), which the Pro and Business presets include. The complete reference is the API documentation; this article shows how to use it in practice.

Create an API key

  1. Open API keys in the dashboard and create a key with a descriptive name ("deploy pipeline", "inventory sync").
  2. Copy the key immediately: it is shown only once. FastPing stores only a hash of it; the list shows the first characters so you can tell keys apart.
  3. Store it in a secret manager or your CI system's secrets, never in a repository.

A key gives full access to the organisation's monitors. Use one key per integration so that you can delete a single key if it leaks without breaking the others.

Authenticate

Send the key as a bearer token. Responses are JSON.

Shell
export FASTPING_KEY=fp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
curl -s -H "Authorization: Bearer $FASTPING_KEY" https://fastping.app/api/v1/monitors

Each key may make 120 requests per minute. Above that, the API answers 429 with a Retry-After header giving the seconds to wait.

Endpoints

RequestDoes
GET /api/v1/monitorsLists all monitors with status, last result and 24-hour uptime.
GET /api/v1/monitors/:idOne monitor with uptime for 1, 7, 30 and 90 days, its latest 100 checks and last 20 incidents.
POST /api/v1/monitorsCreates a monitor; it is attached to every alert channel.
POST /api/v1/monitors/:id/pausePauses checks.
POST /api/v1/monitors/:id/resumeResumes checks and runs one immediately.
DELETE /api/v1/monitors/:idDeletes a monitor and its history.

To create a monitor, send type, name, url (website, keyword and API types) or host (other types), port where the type uses one, interval in seconds and an options object. Option names are listed in the API option column of each monitor type's settings table in this help centre. An interval below your plan's minimum is raised to it. Security scan monitors cannot be created through the API.

Examples

Create a website monitor

Shell
curl -s -X POST https://fastping.app/api/v1/monitors \
  -H "Authorization: Bearer $FASTPING_KEY" -H "Content-Type: application/json" \
  -d '{"type":"http","name":"Shop","url":"https://shop.example.com","interval":60,"options":{"maxMs":1500}}'

Create a heartbeat and get its URL

Shell
curl -s -X POST https://fastping.app/api/v1/monitors \
  -H "Authorization: Bearer $FASTPING_KEY" -H "Content-Type: application/json" \
  -d '{"type":"heartbeat","name":"Nightly backup","interval":86400,"options":{"grace":3600}}' \
  | jq -r .heartbeat_url

Add many websites from a file

One URL per line in urls.txt; jq builds the JSON so that special characters are escaped correctly:

Shell
while read -r url; do
  jq -n --arg url "$url" '{type: "http", name: $url, url: $url}' |
    curl -fsS -X POST https://fastping.app/api/v1/monitors \
      -H "Authorization: Bearer $FASTPING_KEY" -H "Content-Type: application/json" \
      --data-binary @- > /dev/null && echo "added $url"
done < urls.txt

List monitors that are down

Shell
curl -s -H "Authorization: Bearer $FASTPING_KEY" https://fastping.app/api/v1/monitors \
  | jq -r '.monitors[] | select(.status == "down") | "\(.name)\t\(.last_message)"'

Pause a monitor during a deployment

Shell
curl -fsS -X POST -H "Authorization: Bearer $FASTPING_KEY" https://fastping.app/api/v1/monitors/12/pause
./deploy.sh
curl -fsS -X POST -H "Authorization: Bearer $FASTPING_KEY" https://fastping.app/api/v1/monitors/12/resume

Errors

Errors are JSON objects with an error message:

MessageWhat it meansWhat to do
401 Invalid or missing API keyNo Authorization header, or the key was deleted.Send Authorization: Bearer <key> with a current key.
403 Your plan does not include API accessThe REST API access add-on is not active.Add it under Plan & billing.
403 Plan limit of 22 monitors reachedThe organisation has as many monitors as its plan allows (paused ones included).Delete monitors or add capacity.
400 Invalid or unsupported typeUnknown type key, or a type that cannot be created through the API.Use a type key from the API documentation.
400 port is requiredThis type needs a port.Send port.
404 Not foundNo monitor with that ID in your organisation.List monitors to get the right ID.
429 Rate limit exceededMore than 120 requests in a minute with this key.Wait for the number of seconds in Retry-After.

Still need help?

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