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

# Agents as code

> Keep Agents, Environments, Automations, Memory Stores, and Vaults in files with checkfu apply.

Keep Agents, Environments, Automations, Memory Stores, and Vaults in git and sync them with `checkfu apply`. The CLI must be [connected to your deployment](https://docs.checkfu.com/reference/cli.md#connect-to-a-deployment).

```md agents/support.md theme={"theme":{"light":"github-light","dark":"github-dark"}}
---
name: Support
model: claude-sonnet-5-5
---

Answer support questions and cite the source you used.
```

```yaml environments/cloud.yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
name: Cloud
```

```yaml memory_stores/reports.yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
name: Report notes
description: Findings from previous reports
metadata:
  team: support
```

```yaml vaults/support.yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
display_name: Support credentials
```

```yaml automations/report.yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
# yaml-language-server: $schema=https://your-api.workers.dev/schemas/apply/automation.json
type: automation
name: Weekday report
agent: ../agents/support.md
environment_id: ../environments/cloud.yaml
vault_ids:
  - ../vaults/support.yaml
resources:
  - type: memory_store
    memory_store_id: ../memory_stores/reports.yaml
    access: read_only
initial_events:
  - type: user.message
    content: [{ type: text, text: Write the daily support report. }]
schedule: { type: cron, expression: "0 9 * * 1-5", timezone: America/New_York }
```

Preview the plan, then apply it:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu apply . --dry-run
checkfu apply . --yes
```

The first apply creates the resources and writes `checkfu-lock.json`. Commit the lock file so later runs update those same resources instead of creating duplicates.

Omit `schedule` for an on-demand Automation.

An Automation can reference an Agent or Environment by ID or by a file path relative to the Automation definition. A local path can be longer than a resource ID. To pin a local Agent version, use `agent: { path: ../agents/support.md, version: 2 }`.

## Files

Each file describes one resource. The schemas follow the create requests for Agents, Environments, Automations, Memory Stores, and Vaults. Apply rejects unknown fields.

In Markdown files, YAML frontmatter holds the structured fields. The Markdown body fills `system` for an Agent, `description` for an Environment, or a single `user.message` in `initial_events` for an Automation.

`checkfu apply` identifies each file's kind from a `type` field, its parent directory (`agents/`, `environments/`, `automations/`, `memory_stores/`, or `vaults/`), or its kind prefix in the filename. Unclassified files such as `README.md` are skipped.

## References

An Automation file can reference local files in place of resource IDs. `agent: ../agents/support.md` points at the version this apply creates or confirms. Editing the agent moves the Automation to the new version on the next apply. To pin a specific version, write `{ path: ../agents/support.md, version: 3 }`.

An Automation can mount a Memory Store and attach a Vault by relative path, as shown above. The paths resolve to the IDs recorded by apply. Use the [Vault credential API](https://docs.checkfu.com/concepts/vaults.md) to add or rotate tokens. Project files and locks carry resource configuration and IDs.

For Memory Stores and Vaults, the file describes the desired metadata map. Removing a key removes it from the resource. Omit the map or supply `{}` to clear it. Direct API updates treat metadata as a patch. Omission preserves it, a null value removes a key, and a null map clears all metadata.

The lock tracks each resource's ID and a configuration fingerprint. Apply checks that configuration again before changing a Memory Store or Vault. If the server configuration changed, the operation reports a conflict. Review the current resource and rerun the preview. Archive these resources explicitly when they are no longer needed.

## Validate and edit

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
checkfu agent info agents/support.md
```

`agent info` validates a single agent file offline and prints what `apply` would send. Editors with `yaml-language-server` can load the JSON Schema served by your deployment at `$CHECKFU_BASE_URL/schemas/apply/agent.json`, `environment.json`, `automation.json`, `memory_store.json`, or `vault.json`, as shown in the comment above.

## Flags

| Flag | Effect |
| :- | :- |
| `--dry-run` | Print the plan without writing anything. |
| `--yes`, `-y` | Skip the confirmation prompt. Required in non-interactive shells and CI. |
| `--force` | Overwrite remote edits, or recreate a resource that was archived or deleted. |
| `--prune` | Archive Agents, Environments, and Automations whose files were removed. Refused while an Automation uses them. |

To archive a Memory Store or Vault, use its archive command. After it is archived, `apply --prune` removes the missing file's lock entry.

If someone edits a resource outside git (for example, in the Dashboard) after the last apply, `checkfu apply` refuses to overwrite it with `Remote configuration changed`. Copy the change into your file, or pass `--force` to replace it.

Each lock file is tied to one `base_url`. To target a second deployment, pass a separate lock file with `--lock-file checkfu-lock.staging.json`.

## Check synchronization in CI

Run this with a POSIX shell and `jq` from the project root, using its committed lock file and the intended deployment connection. The job passes when the preview contains at least one row and every row is `unchanged`.

```sh project-drift.sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
set -eu
preview=$(mktemp "${TMPDIR:-/tmp}/checkfu-project-drift.XXXXXX")
trap 'rm -f "$preview"' EXIT
checkfu --format json apply . --dry-run > "$preview" || exit "$?"

if ! jq -se 'length == 1 and (.[0] | type == "array" and length > 0 and
  all(.[]; type == "object" and (.file | type == "string" and length > 0) and
  (.action == "unchanged" or .action == "create" or .action == "update" or
   .action == "blocked" or .action == "skipped" or .action == "archive" or .action == "forget")))' \
  "$preview" > /dev/null 2>&1; then
  echo "Expected a nonempty Checkfu project preview." >&2
  exit 1
fi

if jq -e 'all(.[]; .action == "unchanged")' "$preview" > /dev/null; then
  exit 0
fi
jq -ac '.[] | select(.action != "unchanged") | {action, file}' "$preview" >&2
exit 1
```

The preview reflects the deployment at the time of the check. `create` and `update` identify pending changes. Changed rows are printed as JSON with their action and file. Review `blocked` rows before applying. `skipped` can indicate a tracked source file missing from the checkout. A failed preview keeps the original CLI exit status.

## Export from the Dashboard

In the [Dashboard](https://docs.checkfu.com/dashboard.md), open an Agent and click **Export as code**. The download contains `agents/<name>.md` and a `checkfu-lock.json` already linked to that Agent:

```sh theme={"theme":{"light":"github-light","dark":"github-dark"}}
unzip support.zip -d support-bot && cd support-bot
checkfu apply . --dry-run   # shows the agent as unchanged
```


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