> ## Documentation Index
> Fetch the complete documentation index at: https://docs.checkfu.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Checkfu is open source (https://github.com/checkfu/checkfu) and runs in the reader's own Cloudflare account. There is no shared hosted base URL: `checkfu deploy` prints the deployment's API URL (`https://<api-worker>.workers.dev` or the CHECKFU_API_DOMAIN hostname, exported as `CHECKFU_BASE_URL` for the CLI, SDK, and curl) and MCP URL (`.../mcp`). Local development serves the API on http://localhost:1337 and MCP on http://localhost:1338/mcp.
> Authenticated HTTP requests send the deployment's CHECKFU_API_KEY as `Authorization: Bearer $CHECKFU_API_KEY` (or `x-api-key`) and `Content-Type: application/json` for JSON bodies. Pass `Idempotency-Key` on retriable writes.
> Core workflow: create an Agent (`POST /v1/agents`) and an Environment (`POST /v1/environments`), create a Session that references both (`POST /v1/sessions`), send a `user.message` event (`POST /v1/sessions/{session_id}/events`), and follow `GET /v1/sessions/{session_id}/events/stream` until `session.status_idle`.
> Other resources: Memory stores (`/v1/memory_stores`), Files (`/v1/files`), Artifacts (`/v1/artifacts`), Vaults and credentials (`/v1/vaults`), Provider credentials (`/v1/provider_credentials`), Automations (`/v1/automations`), Inbound bindings (`/v1/inbound_bindings`), and Webhooks (`/v1/webhooks`). The deployment serves its OpenAPI 3.1 specification at `GET /openapi.json`.

# Webhooks

> Get a signed HTTPS request when a Session, Automation, Artifact, or other resource changes.

A Webhook is an HTTPS endpoint of yours that Checkfu calls when something happens, such as a Session going idle or a scheduled run failing. Requests are signed with the [Standard Webhooks](https://www.standardwebhooks.com/) scheme and retried on failure. For a complete Node.js receiver, see [Receive webhooks](https://docs.checkfu.com/guides/receive-webhooks.md).

Set `CHECKFU_BASE_URL` to the Checkfu deployment you want to register with. Configure the receiver URL, a stable registration key, and an operator-owned file excluded from source control. Reuse the deployment, receiver URL, key, and file when checking an uncertain result. Choose a separate receipt file for each deployment.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
export CHECKFU_WEBHOOK_URL="https://hooks.example.com/checkfu"
export CHECKFU_WEBHOOK_REGISTRATION_KEY="your-stable-registration-id"
export CHECKFU_WEBHOOK_RECEIPT=".checkfu/webhook-receipt.json"
```

```ts registration.ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { link, lstat, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"
import { dirname, join } from "node:path"
import { WebhookId } from "@checkfu/sdk"
import type Checkfu from "@checkfu/sdk"

const eventTypes = ["session.status_idled", "automation_run.failed"] as const

export class ReceiptError extends Error {}

type Registration = {
	id: WebhookId
	base_url: string
	key: string
	url: string
	secret_revision: number
	signing_secret: string
}

async function readReceipt(path: string): Promise<Registration | undefined> {
	try {
		const info = await lstat(path)
		if (!info.isFile() || (process.platform !== "win32" && (info.mode & 0o077) !== 0)) {
			throw new ReceiptError("The webhook receipt must be an owner-only file.")
		}
		const stored: Registration = JSON.parse(await readFile(path, "utf8"))
		if (
			typeof stored?.id !== "string" ||
			typeof stored.key !== "string" ||
			typeof stored.url !== "string" ||
			typeof stored.signing_secret !== "string" ||
			!Number.isSafeInteger(stored.secret_revision)
		) {
			throw new ReceiptError("The private receipt is invalid.")
		}
		if (typeof stored.base_url !== "string" || stored.base_url === "") {
			throw new ReceiptError(
				"The receipt does not identify a Checkfu deployment. Verify its origin before using the signing secret.",
			)
		}
		return { ...stored, id: WebhookId.make(stored.id) }
	} catch (error) {
		if ((error as NodeJS.ErrnoException).code === "ENOENT") return undefined
		throw error
	}
}

async function saveReceipt(path: string, receipt: Registration) {
	await mkdir(dirname(path), { recursive: true, mode: 0o700 })
	const directory = await mkdtemp(join(dirname(path), ".webhook-receipt-"))
	try {
		const staged = join(directory, "receipt.json")
		await writeFile(staged, JSON.stringify(receipt), { flag: "wx", mode: 0o600 })
		await link(staged, path)
	} finally {
		await rm(directory, { recursive: true, force: true })
	}
}

export async function register(
	client: Pick<Checkfu, "baseUrl" | "webhooks">,
	url: string,
	key: string,
	path: string,
) {
	if (key.trim() === "") throw new Error("Set a stable registration key.")
	let stored = await readReceipt(path)
	if (stored !== undefined && stored.base_url !== client.baseUrl) {
		throw new ReceiptError(
			"The receipt belongs to a different Checkfu deployment. Choose another private receipt file.",
		)
	}
	if (stored !== undefined && (stored.key !== key || stored.url !== url)) {
		throw new ReceiptError("The receipt already belongs to another registration.")
	}
	if (stored === undefined) {
		const created = await client.webhooks.create(
			{ url, event_types: eventTypes },
			{ idempotencyKey: key },
		)
		stored = {
			id: WebhookId.make(created.id),
			base_url: client.baseUrl,
			url,
			key,
			secret_revision: "secret_revision" in created ? created.secret_revision : 1,
			signing_secret: created.signing_secret,
		}
		try {
			await saveReceipt(path, stored)
		} catch {
			throw new ReceiptError(
				`Could not save the receipt for ${created.id}. Fix the private path and retry with the same registration key.`,
			)
		}
	}
	// The filtered listing confirms that the registration is visible.
	const listing = await client.webhooks.list({ id: stored.id, limit: 1 }).catch(() => undefined)
	const ready = listing?.data.find((webhook) => webhook.id === stored.id)

	if (ready === undefined)
		return { id: stored.id, next: "Receipt saved. Run this again to check visibility." }
	if (ready.secret_revision !== stored.secret_revision) {
		return {
			id: stored.id,
			next: "Receipt saved. The signing revision has moved. Reconcile the current secret before starting the receiver.",
		}
	}
	return { id: stored.id, next: "Receipt saved. Configure your receiver from the private file." }
}
```

```ts register-webhook.mts theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Checkfu from "@checkfu/sdk"
import { ReceiptError, register } from "./registration.ts"

const client = new Checkfu()
try {
	const url = process.env.CHECKFU_WEBHOOK_URL ?? ""
	const key = process.env.CHECKFU_WEBHOOK_REGISTRATION_KEY ?? ""
	const receipt = process.env.CHECKFU_WEBHOOK_RECEIPT ?? ".checkfu/webhook-receipt.json"
	const result = await register(client, url, key, receipt)
	console.log(result.id, result.next)
} catch (error) {
	console.error(
		error instanceof ReceiptError
			? error.message
			: "Registration could not finish. Preserve the operation key and check the private receipt path before retrying.",
	)
	process.exitCode = 1
} finally {
	await client.close()
}
```

Run `npx tsx register-webhook.mts`. The file is created with owner-only permissions on POSIX systems. Use an owner-only directory on Windows. Use its `signing_secret` as `CHECKFU_WEBHOOK_SECRET` in [Receive webhooks](https://docs.checkfu.com/guides/receive-webhooks.md). If visibility fails, keep the receipt and run the same command again.

> [!WARNING]
>
> Save the creation receipt privately before checking visibility. Reading a Webhook omits
> `signing_secret`.

The URL must be public HTTPS. A Webhook only receives events that happen after it is created.

## Events

Subscribe to specific event types, or `["*"]` to receive every event.

A wildcard subscription also receives new event types as they are added. Use the [receiver example](https://docs.checkfu.com/guides/receive-webhooks.md) to verify every delivery and dispatch the types you handle. If your code uses the SDK's typed decoder, list the event types it handles in `event_types`. You can update the event types of an existing Webhook in place.

* **Session:** `session.status_run_started`, `session.status_idled`, `session.status_terminated`, `session.outputs_recorded`
* **Automation:** `automation.created`, `automation.updated`, `automation.paused`, `automation.unpaused`, `automation.archived`
* **Automation run** (scheduled runs only): `automation_run.started`, `automation_run.succeeded`, `automation_run.failed`
* **Artifact:** `artifact.created`, `artifact.version_added`, `artifact.published`, `artifact.unpublished`, `artifact.deleted`
* **Agent:** `agent.created`, `agent.updated`, `agent.archived`
* **Environment:** `environment.created`, `environment.updated`, `environment.archived`, `environment.deleted`
* **Vault:** `vault.created`, `vault.archived`, `vault.deleted`
* **Vault credential:** `vault_credential.created`, `vault_credential.archived`, `vault_credential.deleted`
* **Memory store:** `memory_store.created`, `memory_store.archived`, `memory_store.deleted`
* **Webhook:** `webhook.test` (sent only by the test endpoint)

`automation_run.succeeded` means the scheduled run opened a Session. A `session.status_idled` notification signals either a pause for input or the end of a turn. Read the Session's `session.status_idle` events to check `turn` and `stop_reason`. A `requires_action` stop waits for a tool response or approval. An `end_turn` stop records normal completion. See [Handle tool calls](https://docs.checkfu.com/guides/add-an-agent-to-your-app.md#handle-tool-calls) for how to resume a paused turn.

Webhooks can arrive out of order. Read the turn number from the Session history. For work that depends on a particular turn completing, find its `end_turn` event and record the Session ID and turn so you can process it once.

An endpoint must be active and subscribed at the event's recorded timestamp. If several subscription changes share a timestamp, the latest change in that endpoint's history takes effect. Before posting, Checkfu reads the current subscription again and skips pending attempts for endpoints that are paused or unsubscribed.

A `session.outputs_recorded` notification means an [output capture](https://docs.checkfu.com/concepts/files.md#files-from-session-outputs) was saved or skipped. Use the event ID for deduplication and the Session ID in `data.id` to refresh the latest record. A delayed delivery can arrive after a newer capture. Check `turn` and `status`, and use output history to find an earlier capture.

Each payload identifies what happened and which resource changed. Nested resources also carry their parent ID, including `automation_id` on `automation_run.*` and `vault_id` on `vault_credential.*`. Fetch the resource from the API for full details.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
	"type": "event",
	"id": "evt_session_sess_..._42",
	"created_at": "2026-11-28T09:00:00.000Z",
	"data": { "type": "session.status_idled", "id": "sess_..." }
}
```

## Delivery

Checkfu waits 10 seconds for a response, and any `2xx` counts as delivered. Failed deliveries get up to 6 attempts spread over about 5 hours. For both direct and proxied delivery, the first retry is scheduled about 30 seconds after the response. An HTTP `429` follows the same schedule regardless of the receiver's `Retry-After` header. Redirects (`3xx`) are never followed and disable the Webhook immediately.

Completed deliveries are retained for up to 14 days (up to 500 per Webhook), so you can inspect and replay them:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu webhooks test --webhook-id "$WEBHOOK_ID"
checkfu webhooks:deliveries list --webhook-id "$WEBHOOK_ID"
checkfu webhooks:deliveries redeliver --webhook-id "$WEBHOOK_ID" --delivery-id "$DELIVERY_ID"
```

## Rotate the signing secret

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu webhooks rotate-secret --webhook-id "$WEBHOOK_ID"
```

For the next 24 hours, Checkfu signs every delivery with both secrets so receivers using either key keep working while you roll out the new one. See [Create a webhook](https://docs.checkfu.com/api-reference/webhooks/create-a-webhook.md) for pause/resume and update options.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.