> ## 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`.

# Sessions

> Run a conversation with an Agent, mount resources into it, and collect what it saves.

A Session is one conversation with an Agent. It pins an Agent version, runs in an Environment, and keeps its event log and `/workspace` files across turns.

```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import Checkfu from "@checkfu/sdk"

const client = new Checkfu()

const session = await client.waitForPending(
	await client.sessions.create({
		agent: process.env.AGENT_ID!,
		environment_id: process.env.ENVIRONMENT_ID!,
	}),
)
await client.sessions.events.send(session.id, {
	events: [
		{ type: "user.message", content: [{ type: "text", text: "Summarize the open ticket." }] },
	],
})
for await (const event of await client.sessions.events.stream(session.id)) {
	if (event.type === "agent.message") console.log(event.content.map((block) => block.text).join(""))
	if (event.type === "session.status_idle" || event.type === "session.status_terminated") break
}
```

```sh CLI theme={"theme":{"light":"github-light","dark":"github-dark"}}
SESSION_ID=$(checkfu sessions create --agent "$AGENT_ID" --environment-id "$ENVIRONMENT_ID" --transform id -r)
checkfu sessions connect "$SESSION_ID"
```

Passing an Agent ID pins its latest version at creation time. Later edits to the Agent don't change the Session.

## Turns

A `user.message` starts a turn. Each turn ends with a `session.status_idle` event whose `stop_reason` explains why: the agent finished, you interrupted it, or it is paused waiting for tool answers (`requires_action`). See [Tools](https://docs.checkfu.com/concepts/tools.md#answer-a-paused-turn) and [Session events](https://docs.checkfu.com/reference/events.md).

Send `user.interrupt` to stop a running turn. Every event carries a monotonic `seq` you can use to [resume a stream](https://docs.checkfu.com/guides/resume-a-stream.md).

## Change harness or model

Select the next turn's harness and model on an idle Session. A Session that is waiting for approval or a custom tool result returns HTTP 409. The Session keeps its pinned Agent version, Environment, mounts, and published events. The newly selected runtime starts with the most recent published user and assistant exchanges.

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
await client.sessions.selectRuntime(session.id, {
	harness: "codex",
	model: "gpt-5.4",
})
```

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu sessions select-runtime --session-id "$SESSION_ID" --harness codex --model gpt-5.4
```

## Filesystem

| Path | Contents |
| :- | :- |
| `/workspace` | Working files and cloned repositories |
| `/mnt/session/outputs` | Files to save back after each turn |
| `/mnt/memory/<store>` | [Memory stores](https://docs.checkfu.com/concepts/memory-stores.md) |
| `/mnt/artifacts/<name>` | [Artifact](https://docs.checkfu.com/concepts/artifacts.md) versions |
| `/mnt/session/uploads/<path>` | [Files](https://docs.checkfu.com/concepts/files.md) |
| `/mnt/skills/<name>` | Skills (`SKILL.md` and supporting files) |

The agent's file tools can read every mount path. `bash` sees only `/workspace` and `/mnt/session/outputs`.

## List Sessions

Sessions are listed by creation time, newest first by default. Pass `next_page` or `prev_page` from a response as the next request's `page` value. A cursor keeps its original order. You can change the page size and filters, and a creation-time filter must still include the cursor's position.

Filter by Agent ID, Agent version, Automation, mounted Memory Store, status, or creation time. Supply an Agent ID when filtering by Agent version. A request with only `agent_version` returns a 400 error. Creation-time filters (`created_at[gt]`, `created_at[gte]`, `created_at[lt]`, `created_at[lte]`) accept ISO 8601 timestamps with a time zone and up to millisecond precision. Follow `next_page` when present, even if the status filter leaves the current page empty.

## Resources

Attach resources when you create the Session; they cannot be added later (see [Create a session](https://docs.checkfu.com/api-reference/sessions/create-a-session.md) and [Limits](https://docs.checkfu.com/reference/limits.md#sessions) for counts and options).

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
	"agent": "agent_...",
	"environment_id": "env_...",
	"resources": [
		{
			"type": "github_repository",
			"url": "https://github.com/acme/api",
			"authorization_token": "ghp_..."
		},
		{ "type": "memory_store", "memory_store_id": "memstore_...", "access": "read_only" },
		{ "type": "file", "file_id": "file_..." },
		{ "type": "skill", "artifact_id": "art_..." }
	]
}
```

A Skill is an [Artifact](https://docs.checkfu.com/concepts/artifacts.md) with a `SKILL.md` at its root (plus any files it references), mounted read-only at `/mnt/skills/<name>`. For GitHub repositories, see [Work on a GitHub repository](https://docs.checkfu.com/guides/work-on-a-github-repo.md).

## Outputs

When a turn ends with `end_turn`, `budget_reached`, or `refusal`, Checkfu saves the files in `/mnt/session/outputs` as [Files](https://docs.checkfu.com/concepts/files.md):

```ts theme={"theme":{"light":"github-light","dark":"github-dark"}}
const outputs = await client.sessions.outputs.retrieve(session.id)
```

## Usage

The Session's `usage` totals reflect token counts reported by its harness. `GET /v1/sessions/{session_id}/usage` summarizes the model requests Checkfu recorded, and `/v1/sessions/{session_id}/usage/requests` lists the individual receipts. Built-in harnesses and custom harnesses using Checkfu-managed models write these receipts. A custom harness can also report token usage for its own provider calls. Those calls have no Checkfu request receipt.

`known_cost_micro_usd` is null until a settled request has a known cost.

## Archive

Archiving stops any running turn. The event history and saved outputs remain readable.

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu sessions archive --session-id "$SESSION_ID"
```

> [!WARNING]
>
> Archiving discards `/workspace`, the Linux machine, and any stored repository tokens. Push or save
> what you need first.


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