REST API
Everything in Keybeat is available through a JSON REST API at https://api.keybeat.dev. The CLI, the MCP server and the dashboard all use it.
The complete reference, with every endpoint, parameter and schema, is the OpenAPI 3.1 document at api.keybeat.dev/openapi.json. Load it into your favourite API client, or give it to your agent. This page explains the conventions and walks through the main flows.
Authentication
Send an API key as a bearer token:
curl https://api.keybeat.dev/v1/me \
-H "Authorization: Bearer $KEYBEAT_API_KEY"API keys start with kb_ and belong to one organization. Create them in the dashboard, or get one through npx keybeat login. A key is shown only once, so store it somewhere safe. Keys have full access to their organization except managing members and API keys, which need a logged in user in the dashboard.
Requests and responses
- Request and response bodies are JSON. Send
Content-Type: application/jsonwith a body. - Timestamps are ISO 8601 strings in UTC.
- Ids are UUIDs. Endpoints that take a monitor
:idalso accept the monitor's slug.
Errors
Errors use a consistent shape with an HTTP status code:
{
"error": {
"code": "validation_error",
"message": "interval_seconds must be one of 3600, 900, 300, 60",
"details": {}
}
}Use code in your logic. It is a stable snake_case string. message is meant for humans and may change. details carries extra structured information when there is any.
| Status | When |
|---|---|
| 400 | The request is invalid. |
| 401 | The API key is missing, revoked or invalid. |
| 402 | The change needs a paid plan. See Payment required. |
| 403 | The key or user is not allowed to do this. |
| 404 | The resource does not exist in your organization. |
| 409 | The change conflicts with existing data, for example a duplicate slug. |
| 429 | Rate limit or monthly cap reached. |
| 5xx | Something went wrong on Keybeat's side. Retry with backoff. |
Pagination
List endpoints return a page of results and a cursor:
{ "data": [ ... ], "next_cursor": "eyJpZCI6..." }Pass ?limit= to set the page size and ?cursor= with the previous next_cursor to get the next page. When next_cursor is null there are no more results.
curl "https://api.keybeat.dev/v1/monitors/checkout/runs?limit=50&cursor=eyJpZCI6..." \
-H "Authorization: Bearer $KEYBEAT_API_KEY"Rate limits
Each API key can make 120 requests per minute. Over the limit, the API returns HTTP 429. Wait and retry.
Payment required
Creating a monitor that needs a paid plan (any interval faster than 60 minutes, or a second monitor) on a free organization returns HTTP 402 with a Stripe Checkout URL. A human opens it to subscribe. After that, the same request succeeds.
On a paid organization, changes that add add-ons succeed at once and update the subscription with proration. The response then includes a billing_change object. items is a list, because one change (for example moving a monitor from 15 minutes to 5 minutes) can touch two add-ons. billing_change is null when nothing changed.
{
"billing_change": {
"items": [
{ "item": "monitor_5m", "quantity": 2, "previous_quantity": 1, "amount_delta_cents": 500 }
],
"amount_delta_cents": 500,
"interval": "month"
}
}Main flows
The examples use $KEYBEAT_API_KEY from your environment and jq to build JSON bodies.
Check your identity, plan and limits
curl https://api.keybeat.dev/v1/me -H "Authorization: Bearer $KEYBEAT_API_KEY"Validate a script
Static checks only: the script parses, contains a test and is within 100 KB.
jq -n --rawfile script keybeat/login.spec.ts '{ script: $script }' |
curl -X POST https://api.keybeat.dev/v1/monitors/validate \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d @-Create or update a monitor
PUT /v1/monitors/:slug is an idempotent upsert by slug. This is what keybeat deploy uses.
jq -n --rawfile script keybeat/login.spec.ts \
'{ name: "Login works", script: $script, interval_seconds: 900, enabled: false }' |
curl -X PUT https://api.keybeat.dev/v1/monitors/login \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d @-interval_seconds is 3600, 900, 300 or 60. POST /v1/monitors also creates a monitor and takes the slug in the body. You can include env with initial secrets, alert_channel_ids to send this monitor's alerts to specific channels (omit for all channels), and on_status_page.
Set secrets and enable
curl -X PUT https://api.keybeat.dev/v1/monitors/login/env \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "set": { "LOGIN_EMAIL": "[email protected]", "LOGIN_PASSWORD": "s3cret" } }'
curl -X PATCH https://api.keybeat.dev/v1/monitors/login \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "enabled": true }'GET /v1/monitors/login/env returns names only.
Run a monitor now and wait for the result
curl -X POST "https://api.keybeat.dev/v1/monitors/login/runs?wait=true" \
-H "Authorization: Bearer $KEYBEAT_API_KEY"With wait=true the request blocks for up to 90 seconds and returns the finished run. Without it, it returns the run at once with status starting, and you can poll GET /v1/runs/:id. On-demand runs count towards your monthly cap and never alert.
Read failures
# Recent failed runs of a monitor
curl "https://api.keybeat.dev/v1/monitors/login/runs?status=failed" \
-H "Authorization: Bearer $KEYBEAT_API_KEY"
# Full detail: steps, error message, logs
curl https://api.keybeat.dev/v1/runs/$RUN_ID -H "Authorization: Bearer $KEYBEAT_API_KEY"
# Short-lived signed URLs for the trace and screenshot (failed runs only)
curl https://api.keybeat.dev/v1/runs/$RUN_ID/artifacts -H "Authorization: Bearer $KEYBEAT_API_KEY"A run includes trigger (schedule, retry or manual), region, status, duration_ms, error_message and a steps array:
{
"steps": [
{ "title": "checkout reaches payment > open product page", "duration_ms": 1830, "status": "passed", "error": null },
{ "title": "checkout reaches payment > add to cart", "duration_ms": 5012, "status": "failed", "error": "Timed out 5000ms waiting for expect(locator).toHaveText(expected)" }
]
}The artifacts response is { "trace_url": "...", "screenshot_url": "..." }. Download the trace promptly, because the URLs expire.
Uptime and performance
curl "https://api.keybeat.dev/v1/monitors/login/stats?days=30" -H "Authorization: Bearer $KEYBEAT_API_KEY"
curl "https://api.keybeat.dev/v1/incidents?open=true" -H "Authorization: Bearer $KEYBEAT_API_KEY"Stats include uptime percentage and p50 and p95 durations per day and per region.
Pause, resume and delete
curl -X POST https://api.keybeat.dev/v1/monitors/login/pause -H "Authorization: Bearer $KEYBEAT_API_KEY"
curl -X POST https://api.keybeat.dev/v1/monitors/login/resume -H "Authorization: Bearer $KEYBEAT_API_KEY"
curl -X DELETE https://api.keybeat.dev/v1/monitors/login -H "Authorization: Bearer $KEYBEAT_API_KEY"Alert channels
curl -X POST https://api.keybeat.dev/v1/alert-channels \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "type": "webhook", "target": "https://example.com/hooks/keybeat" }'
curl -X POST https://api.keybeat.dev/v1/alert-channels/$CHANNEL_ID/test -H "Authorization: Bearer $KEYBEAT_API_KEY"Status page
curl -X PUT https://api.keybeat.dev/v1/status-page \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "slug": "acme", "title": "Acme status", "enabled": true, "monitor_ids": ["<monitor id>", "<monitor id>"] }'monitor_ids lists the monitors shown on the page, in order. See Status pages.
Billing
curl https://api.keybeat.dev/v1/billing -H "Authorization: Bearer $KEYBEAT_API_KEY"
# Start a subscription: returns { "url": "https://checkout.stripe.com/..." } for a human to open
curl -X POST https://api.keybeat.dev/v1/billing/checkout \
-H "Authorization: Bearer $KEYBEAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "interval": "month" }'POST /v1/billing/portal returns a Stripe Customer Portal URL. POST /v1/billing/cancel cancels at the end of the period and POST /v1/billing/resume undoes that.
Endpoint overview
| Area | Endpoints |
|---|---|
| Identity | GET /v1/me, GET /v1/orgs, PATCH /v1/org, GET /v1/org/members |
| Allowlisting | POST /v1/org/allowlist-token/rotate |
| Monitors | GET /v1/monitors, POST /v1/monitors, GET, PATCH, DELETE /v1/monitors/:id, PUT /v1/monitors/:slug, POST /v1/monitors/:id/pause, POST /v1/monitors/:id/resume, POST /v1/monitors/validate |
| Secrets | GET /v1/monitors/:id/env, PUT /v1/monitors/:id/env |
| Runs | POST /v1/monitors/:id/runs, GET /v1/monitors/:id/runs, GET /v1/runs/:id, GET /v1/runs/:id/artifacts |
| Stats | GET /v1/monitors/:id/stats, GET /v1/incidents |
| Alerts | GET, POST /v1/alert-channels, PATCH, DELETE /v1/alert-channels/:id, POST /v1/alert-channels/:id/test |
| Status page | GET, PUT /v1/status-page, GET /v1/public/status/:slug (no auth) |
| Billing | GET /v1/billing, POST /v1/billing/checkout, POST /v1/billing/portal, POST /v1/billing/cancel, POST /v1/billing/resume |
See openapi.json for request and response schemas.