API 与自动化
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.
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.
- Open API keys in the dashboard and create a key with a descriptive name ("deploy pipeline", "inventory sync").
- 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.
- 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.
Send the key as a bearer token. Responses are JSON.
export FASTPING_KEY=fp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
curl -s -H "Authorization: Bearer $FASTPING_KEY" https://fastping.app/api/v1/monitorsEach key may make 120 requests per minute. Above that, the API answers 429 with a Retry-After header giving the seconds to wait.
| Request | Does |
|---|---|
GET /api/v1/monitors | Lists all monitors with status, last result and 24-hour uptime. |
GET /api/v1/monitors/:id | One monitor with uptime for 1, 7, 30 and 90 days, its latest 100 checks and last 20 incidents. |
POST /api/v1/monitors | Creates a monitor; it is attached to every alert channel. |
POST /api/v1/monitors/:id/pause | Pauses checks. |
POST /api/v1/monitors/:id/resume | Resumes checks and runs one immediately. |
DELETE /api/v1/monitors/:id | Deletes 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.
Create a website monitor
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
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_urlAdd many websites from a file
One URL per line in urls.txt; jq builds the JSON so that special characters are escaped correctly:
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.txtList monitors that are down
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
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/resumeErrors are JSON objects with an error message:
| Message | What it means | What to do |
|---|---|---|
401 Invalid or missing API key | No Authorization header, or the key was deleted. | Send Authorization: Bearer <key> with a current key. |
403 Your plan does not include API access | The REST API access add-on is not active. | Add it under Plan & billing. |
403 Plan limit of 22 monitors reached | The organisation has as many monitors as its plan allows (paused ones included). | Delete monitors or add capacity. |
400 Invalid or unsupported type | Unknown type key, or a type that cannot be created through the API. | Use a type key from the API documentation. |
400 port is required | This type needs a port. | Send port. |
404 Not found | No monitor with that ID in your organisation. | List monitors to get the right ID. |
429 Rate limit exceeded | More than 120 requests in a minute with this key. | Wait for the number of seconds in Retry-After. |