Quickstart
Create an alert, wait for the answer, and watch a job, in five minutes.
You need an organization, one team with an escalation policy, and a person whose phone is verified. The dashboard walks you through it ("Finish setting up" on the Alerts page). Then:
#1. Get an API key
In the dashboard open Integrations → API keys and create a key. Scopes are not a ladder:
| Scope | Can |
|---|---|
alert | create, acknowledge, close and read alerts; ping heartbeats. This is what a service should carry. |
read | read everything, change nothing |
admin | everything, including configuration |
The key is shown once. Export it:
export TREASON_API_KEY=trk_xxxxxxxx_...
export TREASON_API_URL=https://api.treason.app # or http://localhost:3100 in development#2. Send an alert
curl -X POST $TREASON_API_URL/v1/alerts \
-H "Authorization: Bearer $TREASON_API_KEY" \
-H "Idempotency-Key: quickstart-1" \
-H "Content-Type: application/json" \
-d '{"message":"API error rate above 5%","alias":"api-errors","priority":"P1"}'import { Treason } from "@treason/sdk";
const treason = new Treason(); // reads TREASON_API_KEY and TREASON_API_URL
const { alert } = await treason.alerts.create({
message: "API error rate above 5%",
alias: "api-errors",
priority: "P1",
});
console.log(alert.tinyId, alert.status); // 4821 "open"treason alert create "API error rate above 5%" --alias api-errors --priority P1The answer is 202 with the alert. Whoever is on call for your team now gets a push, then a text after two minutes, then a call after five, unless they acknowledge first.
Send it again: the response says "deduplicated": true and nobody is paged twice.
#3. Acknowledge it
From your phone, or from code:
treason alert ack <id>Escalation stops. GET /v1/alerts/{id} now shows the acknowledgement and every notification we attempted.
#4. Wait for a human
The same call, but your code waits for the answer:
const { acknowledged } = await treason.page({
message: "Deploy v42 to production needs approval",
alias: "deploy-v42",
wait: { timeoutMs: 10 * 60_000 },
});
if (!acknowledged) process.exit(1);treason alert create "Deploy v42 needs approval" --alias deploy-v42 --wait 10m
echo $? # 0 = acknowledged, 2 = nobody answered in timeMore in Wait for a human.
#5. Watch a job
Create a heartbeat once (needs an admin key), then have the job ping it:
treason heartbeat set nightly-backup --every 1d --grace 15m --priority P1
treason run --heartbeat nightly-backup -- ./backup.shIf a day and fifteen minutes pass without a ping, an alert opens and pages the team. The next ping closes it. More in Heartbeats.
#Install the SDK and CLI
npm install @treason/sdk # the library
npx treason --help # the command lineNote.
@treason/sdklives in this repository underpackages/sdkand is not published to npm yet. Until it is:npm run sdk:buildat the repository root, thennpm install ./packages/sdkin your project.