Monitoring API examples
Use a scoped project key to check failed Workflow activity. This example follows every returned cursor within a fixed time window and reports failures of the monitor separately from failures of an automation.
It does not check every aspect of team health. A scoped key cannot read Source configuration, Instant channel inventory, channel alerts, Workflow definitions, or full run details. The earlier example that queried /sources/channels and /sources/channel-alerts with a project key is not supported by the current access policy.
Prepare the caller
An owner opens Settings → API keys → Create key and selects Read (control:read). Execute and Tunnel are unnecessary for this check. Store the one-time key in the scheduler's secret manager.
| Variable | Purpose |
|---|---|
| FASTHOOK_API_KEY | Scoped key with Read access for the monitored team. |
| FASTHOOK_TEAM_ID | The same team that owns the key. |
| FASTHOOK_WINDOW_FROM | Optional ISO timestamp at which to start. Defaults to 15 minutes before the check starts. |
The public API base is https://api.fasthook.io/v1. Changing a team header does not extend the key's access. See Workflow API access and Secrets and rotation.
Run a bounded, read-only check
Save this as fasthook-health-check.mjs and run it with a supported Node.js release that provides built-in fetch and AbortSignal.timeout. The script makes only GET requests to Workflow activity. It does not retry a Workflow, test an Action, or send an external notification.
const API_KEY = process.env.FASTHOOK_API_KEY;
const TEAM_ID = process.env.FASTHOOK_TEAM_ID;
const MAX_PAGES = 100;
const DEADLINE_MS = 60_000;
class MonitorError extends Error {}
async function main() {
if (!API_KEY || !TEAM_ID) throw new MonitorError("missing_configuration");
const to = new Date().toISOString();
const from = process.env.FASTHOOK_WINDOW_FROM
|| new Date(Date.parse(to) - 15 * 60_000).toISOString();
if (!/^\d{4}-\d{2}-\d{2}T/.test(from)
|| !Number.isFinite(Date.parse(from)) || Date.parse(from) > Date.parse(to)) {
throw new MonitorError("invalid_window");
}
const deadline = Date.now() + DEADLINE_MS;
const seenCursors = new Set();
const runIds = new Set();
let cursor = null;
let pages = 0;
do {
if (pages >= MAX_PAGES) throw new MonitorError("page_limit_exceeded");
const remaining = deadline - Date.now();
if (remaining <= 0) throw new MonitorError("deadline_exceeded");
const query = new URLSearchParams({ status: "failed", from, to, limit: "100" });
if (cursor) query.set("cursor", cursor);
const response = await fetch(`https://api.fasthook.io/v1/workflow-activity?${query}`, {
headers: {
authorization: `Bearer ${API_KEY}`,
"x-team-id": TEAM_ID,
accept: "application/json"
},
redirect: "error",
signal: AbortSignal.timeout(Math.min(15_000, remaining))
});
if (!response.ok) throw new MonitorError(`http_${response.status}`);
const data = await response.json();
if (!data || !Array.isArray(data.models) || data.models.length > 100
|| data.count !== data.models.length
|| !(data.next_cursor === null || (typeof data.next_cursor === "string"
&& data.next_cursor.length > 0 && data.next_cursor.length <= 1024))) {
throw new MonitorError("invalid_response");
}
for (const run of data.models) {
if (!run || typeof run.id !== "string" || !run.id.startsWith("wfr_")
|| run.status !== "failed") throw new MonitorError("invalid_run_summary");
runIds.add(run.id);
}
pages += 1;
cursor = data.next_cursor;
if (cursor) {
if (seenCursors.has(cursor)) throw new MonitorError("repeated_cursor");
seenCursors.add(cursor);
}
} while (cursor);
console.log(JSON.stringify({
schema_version: 2,
generated_at: new Date().toISOString(),
window: { from, to },
status: runIds.size ? "failed_runs_detected" : "no_failures_observed",
pages,
failed_runs: runIds.size,
sample_run_ids: [...runIds].sort().slice(0, 20)
}));
process.exitCode = runIds.size ? 2 : 0;
}
await main().catch((error) => {
// Never print the raw response, provider error, request headers, or network error.
console.error(JSON.stringify({
schema_version: 2,
generated_at: new Date().toISOString(),
status: "monitor_error",
code: error instanceof MonitorError ? error.message : "request_failed"
}));
process.exitCode = 3;
});The script processes at most 100 pages within a 60-second request budget. An exceeded limit, repeated cursor, malformed response, network error, or rejected credential produces exit code 3, rather than a success report based on partial results. A scheduler should also impose an overall process timeout.
| Exit code | Meaning |
|---|---|
| 0 | No failed runs were observed in the checked activity window. |
| 2 | Failed runs were observed. Review the run identifiers in Run history. |
| 3 | The monitor did not complete. Do not treat the automation as healthy. |
The report excludes payloads, Step outputs, provider error text, and credentials. Run IDs still identify internal operational records; keep scheduler logs and alert destinations private.
Keep the window and pagination consistent
Run the check on your scheduler, for example every five minutes with a 15-minute lookback. Prevent overlapping processes and alert separately on exit codes 2 and 3. Overlapping windows can report the same run repeatedly; deduplicate by run ID in the receiver rather than initiating automatic recovery.
Use the returned next_cursor as the next request's cursor, preserving the original absolute from, to, status, and Source filters. Stop when next_cursor is null. The maximum page size is 100. total and count describe the response; a large total alone is not a reason to discard cursor pagination or stop after the first page.
This is a changing activity view, not a transactional snapshot. Statuses can change during a scan, and the window filters run creation time. A run created earlier can fail after a short window has passed. Use a suitable longer lookback or periodic reconciliation for long-running automations; a check that observes no failures does not prove that every business outcome succeeded.
Inspect a failure window manually
This Bash example needs the same Read key. It returns only the first page; inspect next_cursor before concluding the query is complete:
curl --fail-with-body --silent --show-error \
-H "Authorization: Bearer $FASTHOOK_API_KEY" \
-H "x-team-id: $FASTHOOK_TEAM_ID" \
"https://api.fasthook.io/v1/workflow-activity?status=failed&source_id=src_example&from=now-1h&to=now&limit=100"For multiple pages, resolve relative times to absolute ISO timestamps once, as the script does. Reusing to=now across requests moves the window. Use a real Source ID for the selected team, or omit source_id to inspect all returned team activity.
Check Instant Trigger health in the dashboard
Use Run history, its Source-failure evidence, and the affected Trigger's Setup for channel errors, fallback, or account repair. A team session can read the corresponding /sources/channels and /sources/channel-alerts references; the scoped Read key cannot. Do not put a personal session into CI to bypass that restriction.
For an API error, distinguish invalid credentials (401), a team/scope/resource restriction (403), rate limiting (429, respect Retry-After), and unavailable key-policy storage (503). An absent scope and an excluded resource are different problems; adding Execute will not unlock Source reads.
Investigate before recovery: a failed run can already have successful external effects. Continue with Run history, Trigger health recovery, Incident response, and Reconciliation reports.