Skip to content

HTTP API reference

Every endpoint the Agent Factory daemon serves over its local Unix socket, generated from the daemon's route catalog (the same table the af api command prints). This page is regenerated by scripts/gen-docs.sh and verified in CI — do not edit it by hand.

For the transport, socket path, authentication model, response envelope, and status codes, see the HTTP API guide. Run af api to print this catalog with a ready-to-run curl example for each route and the resolved socket path for your machine.

Ordinary daemon HTTP errors include optional boolean error.daemon_rejected: true. An unmarked 5xx or unfamiliar error envelope leaves a mutation's outcome uncertain; check its state before retrying. Only boolean true counts; the web client also treats 502/504 as uncertain even with a marker. The existing error.code: "mutation_committed" takes precedence over that boolean and means the mutation must not be retried. See the response envelope contract for details.

Session snapshot tabs[] records include web_proxied for web tabs: true means use the daemon proxy, false means the daemon will not proxy the target. Before direct navigation, clients must also check browser URL canonicalization: a target that still resolves to loopback must be blocked, not opened on the viewer’s machine. It is derived by session.IsLoopbackWebTarget, the same predicate the proxy checks; clients should use this decision rather than classify the URL themselves. Non-web tabs omit it, and clients of older daemons may fall back when it is absent.

CreateSession.force_remote remains accepted for compatibility with older clients. It selects the hook backend when backend is empty; an explicit backend takes precedence. New clients should use backend (for example, "hook"), as the TUI creation form does.

Endpoints

Request fields are the JSON keys of each route's request body; a — means the route takes no body (or an empty {}).

Method Path Request fields Description
GET /v1/health — Lifecycle health probe (alias for Ping): version, boot/transaction identity, phase, and bound listeners; answers before readiness.
POST /v1/CreateSession title, title_base, repo_path, program, account, prompt, in_place, force_remote, validate_first, backend, host Create a new session (git worktree + agent) in a repo.
POST /v1/ListBackends repo_path List the runtimes a session in this repo can be created on, whether the repo's config supports each, and the backend an unspecified create defaults to.
POST /v1/CheckHost host Probe a listed host (or every listed host) for the tools a sandbox session needs and record its readiness. Refuses a name outside the global host list.
POST /v1/ListPrograms repo_path List the agent programs a session can be created with, and the program an unspecified create defaults to.
POST /v1/SuggestSessionName — Suggest a random, readable session name (adjective-noun) not used by any live session, for the create form's autocreate placeholder.
POST /v1/Snapshot repo_id, live, statuses, created_after, limit, lazy_archive, newest_first, before, project_path, ids List sessions from the daemon's authoritative in-memory state, with optional live/status, created-after, and limit filters applied before transfer (empty repo_id = all repos).
POST /v1/PreviewSession id, lines Read the last lines (1-40, default 40) of a session's agent tab, by stable id, as plain text with escapes and control characters removed; read only.
POST /v1/KillSession title, repo_id, id Tear down a session: kill its tmux/agent and remove its worktree and record.
POST /v1/ArchiveSession title, repo_id, id, push Archive a session: tear down tmux and relocate its worktree to the archive dir, keeping the record; refused before mutation when enabled tasks target it.
POST /v1/RestoreArchived title, repo_id, id Restore an archived session: move its worktree back next to the repo and re-spawn the agent.
POST /v1/PruneSessions repo_id, all, older_than, apply, only af sessions prune: without apply, a strictly read-only listing of the old archived sessions a reclaim would remove and the allocated bytes each would free; with apply, deletes the worktrees that same verdict lists (optionally bound to a confirmed plan by session id), keeps each branch and leaves a pruned tombstone row.
POST /v1/RestoreSession title, repo_id, id, expected_daemon_boot_id, force_reap Restore an archived, Lost, or Dead session; an optional expected daemon boot ID refuses before admission if the process changed.
POST /v1/SendPrompt title, repo_id, prompt, id Send a prompt to an existing session's agent.
POST /v1/ResumeFromLimit title, repo_id, id Resume a usage-limit-blocked session, or explicitly retry an inspected handoff whose mission delivery was ambiguous.
POST /v1/ConfirmHandoffDelivery title, repo_id, id Retire a pending handoff mission on the operator's attestation that it already landed — settles the replacement fence and startup-unknown flag without resending.
POST /v1/SetConversation title, repo_id, id, conversation_id Record a provider conversation id on a session's Agent tab after proving it against the session's own conversation store — the repair for an unrecorded or stale recorded conversation.
POST /v1/HandoffSession title, repo_id, id, to, account, brief Continue a session in place under a different agent (to), another account for the same agent (account), or both (to and account). Keep its worktree and branch, and deliver a mission brief with the goal and existing work to the replacement conversation. Omit to to keep the current agent.
POST /v1/DeleteProject repo_path, repo_id Delete a project (a repo's session grouping): archive its live sessions (restorable), tear down in-place ones, and drop its root_agents opt-in — the real git repo is untouched.
POST /v1/RegisterProject path, url Register a git checkout as a durable, sessionless project by path (expand ~, resolve the git root, validate, persist to the registry) — resolved on the daemon's filesystem, idempotent for a known checkout.
POST /v1/RebindProject id, path, expected_root, expected_checkout_id Move a registered project's stable identity (id, a prj_… registry id) to the checkout at path — the repair after that checkout was moved or recloned elsewhere. Path resolves on the daemon's filesystem; the rebind refuses a root another project already owns. With expected_root and expected_checkout_id (the pair the caller last saw the project bound to — a same-path reclone changes the checkout half while the root spelling stays), it applies only if the registry still records both, and otherwise answers 409 project_rebound; omitted, last writer wins.
POST /v1/SetAttention id, title, repo_id, reason, clear, set_at Set (with an optional reason) or clear a session's attention request — the agent's explicit ask for the user. It clears when the user submits a line in the agent pane, dismisses it in the web UI, or when the agent starts work again after it went idle.
POST /v1/SetProjectColor id, color Set or clear (empty color) the display color of a registered project (id, a prj_… registry id) — a hex color such as #2f5fd8 that web clients use for the session frame and the favicon.
POST /v1/RebindProjectGuarded id, path, expected_root, expected_checkout_id Guarded twin of RebindProject: requires expected_root or expected_checkout_id and exists only on daemons that enforce the pair — a daemon predating it answers the marked 404, which clients map to an upgrade refusal rather than letting the precondition drop silently.
POST /v1/ListProjects — List every durable project in the daemon's registry (id, last-known root, path_exists) — the read a web/TUI client unions with its derived project list.
POST /v1/ListDirectory path List the child DIRECTORIES of one directory on the daemon's filesystem, marking which are git checkouts — the read behind an Add-project picker. Resolves ~ and symlinks and answers with canonical paths; an unreadable directory is an error, never an empty list.
POST /v1/DeliverPrompt title, repo_path, program, prompt, host, defer_while_attached Deliver a prompt to a session, auto-creating it if it does not exist yet.
POST /v1/CreateTab title, repo_id, command, name, shell, kind, url, port, proposal, id Spawn a tab in a session: a process tab (command) or shell tab in the worktree, a web tab (kind=web) that iframes a url/port (localhost is daemon-proxied, external is direct), or a VS Code tab (kind=vscode) serving the session's worktree in a daemon-managed code-server (no url/port: the worktree is the target).
POST /v1/CloseTab title, repo_id, tab_name, tab_index, id, tab_id Close a non-agent tab of a session (the agent tab cannot be closed). Address the tab by tab_id (its stable id) when you have one: it wins over tab_name/tab_index, which name a tab that may since have been closed and had its name or slot reused. A tab_id that no longer resolves is refused rather than falling back — closing is destructive, so a misroute kills the wrong tab's session.
POST /v1/RenameTab title, repo_id, tab_name, tab_index, new_name, id, tab_id Rename a tab of a session. Only web, process, VS Code and docs tabs can be renamed — agent and shell tabs render fixed labels. The name is sanitized and made unique, so the resolved name is returned. Address the tab by tab_id (its stable id) when you have one: it wins over tab_name/tab_index, which name a tab that may since have been closed and had its name or slot reused. A tab_id that no longer resolves is refused rather than falling back.
POST /v1/ReorderTab title, repo_id, tab_name, tab_index, new_index, id, tab_id Move a tab within a session's roster. Index 0 is reserved for the agent tab, so only slots 1..n-1 can be moved or targeted. Address the tab by tab_id (its stable id) when you have one — see RenameTab; it matters most here, since a reorder is what invalidates every other client's tab_index.
POST /v1/ListAccounts agent, repo_path List the agent accounts registered in the daemon host's agent-factory home, each with its logged-in state (read from the presence of the agent's own credential file, never its contents), plus the agents an account can be registered for.
POST /v1/RegisterAccount agent, name Create an agent account's credential directory on the daemon host without logging in — idempotent, and the register half of the accounts UI. Log in to it with AccountLogin.
POST /v1/AccountLogin agent, name Open an agent's OWN login flow (claude auth login / codex login / gemini) in a bare tmux session scoped to one registered account: the account's credential directory injected, every ambient identity variable removed. Registers the account if it does not exist. Returns the tmux session and socket to attach to, and the account's logged-in state read from the agent's own credential file. af never reads, stores, or forwards the credential.
POST /v1/QuotaReport — Report per-agent provider quota (what the provider exposes — today "not reported" everywhere) alongside what af's own sessions have observed: running counts, sessions parked at a usage limit, and the earliest recorded reset.
POST /v1/HandoffStatus — Report the auto-handoff rails: the resolved mode, whether the engine is observing, the durable halt record, refusal backoffs, and the recent-move ledger the switch-loop rail and move credits count.
POST /v1/HandoffReset record, session_key Clear one named auto-handoff rail record — halt, backoff, or moves — optionally scoped to one stable session identity.
POST /v1/GetConfig repo_path List every user-facing global config key with its purpose, type, default, and current value. Pass repo_path to show a project's effective values instead, with a scope marker and the global value on each overridden key.
POST /v1/ExplainConfig key, repo_path Explain one config key's provenance: every source candidate with its value, location, and the reason it won, was shadowed, was absent, or is disallowed. Global by default; pass repo_path to explain it in a project.
POST /v1/SetConfigValue key, value, hosts_edit Set one global config key, exactly as af config set does (validated, locked, atomic).
POST /v1/UnsetConfigValue key Clear one migrated global setting — a network.* key (listen_addr, preview_listen_addr, editor_origin_ports, require_token, require_loopback_token, allow_unauthenticated_network, cors_allowed_origins, allowed_hosts) or a backend key (docker.mount_agent_credentials, ssh.host_key_verification, sandbox.ssh, sandbox.binary) — exactly as af config unset does (both alias spellings, atomically).
POST /v1/ListProposals session_id, repo_id, repo_path List a project's proposals, newest edit first. Name the project with exactly one of session_id, repo_id or repo_path (a path on the daemon host).
POST /v1/GetProposal session_id, repo_id, repo_path, slug Describe one proposal for the Proposal tab: head commit, docs, unused templates, open question count, and attached sessions.
POST /v1/StartProposal session_id, slug, docs, deliver_rules Create a proposal from templates, attach the session to it, open its Proposal tab, and return the rules for the agent. deliver_rules additionally delivers the rules to the agent as a prompt (reported in rules_delivery).
POST /v1/AttachProposal session_id, slug, deliver_rules Attach the session to a proposal (or, with no slug, report its current one), open its Proposal tab, and return the rules. deliver_rules additionally delivers the rules to the agent as a prompt (reported in rules_delivery).
POST /v1/DetachProposal session_id Remove the session's proposal attachment and cursor, and close its Proposal tab.
POST /v1/AddProposalDoc session_id, repo_id, repo_path, slug, name, author Add a doc to a proposal from a template, or blank, and commit it as the given author.
POST /v1/RemoveProposalDoc session_id, repo_id, repo_path, slug, doc, author Remove a doc from a proposal and commit the deletion as the given author; the doc stays in the proposal's history.
POST /v1/ReadProposalDoc session_id, repo_id, repo_path, slug, doc Read a proposal doc and the commit it is at, after committing its uncommitted edits as external.
POST /v1/SaveProposalDoc session_id, repo_id, repo_path, slug, doc, text, base, writer, seq Save a proposal doc as a human edit against a base commit; merges with git merge-file, and answers 409 proposal_conflict with ours/theirs/base when the edits conflict. A save with writer and seq is refused with 409 proposal_stale_save when the daemon has already seen that seq or a later one from the writer for the doc.
POST /v1/WriteProposalDoc session_id, repo_id, repo_path, slug, doc, text, author Replace a proposal doc and commit it as the given author, with no merge.
POST /v1/PullProposalChanges session_id Return the edits to the session's proposal that it has not seen, then move its cursor.
POST /v1/CheckpointProposal session_id Commit the session's edits to its proposal as its own and move its cursor past them.
POST /v1/ListOnComplete — List task spawned-session lifecycle choices and consequences, least destructive first.
POST /v1/ListTasks — List every task across all repos.
POST /v1/AddTask task, actor, validate_path Append a new task and re-arm the scheduler; an enabled archived/archiving target_session is refused before commit.
POST /v1/UpdateTask id, update, expect, actor, validate_path Apply a field-level patch to a task (only the fields in update are changed), preserving every unspecified field and the scheduler-owned fields; an enabled archived/archiving target_session is refused before commit.
POST /v1/RemoveTask id, expect Remove a task by ID.
POST /v1/RestartTask id, expect Stop and replace one enabled watch task without overlapping its process tree.
POST /v1/TriggerTask id, expect, actor Fire a cron task now through the daemon's scheduler path (refuses disabled and watch tasks).

Nested request payloads

The Request fields column above lists each body's TOP-LEVEL keys. Where one of those is an object, its own keys are listed here as dotted paths, so a request can be constructed from this page alone.

Path Nested fields
/v1/Snapshot before.created_at, before.id
/v1/SetConfigValue hosts_edit.op, hosts_edit.name, hosts_edit.host, hosts_edit.host.host, hosts_edit.host.user, hosts_edit.host.port, hosts_edit.host.identity_file, hosts_edit.host.workspace_root, hosts_edit.host.host_key_verification, hosts_edit.host.use_ssh_config, hosts_edit.clear_default
/v1/AddTask task.id, task.name, task.prompt, task.cron_expr, task.watch_cmd, task.target_session, task.max_concurrent_runs, task.on_complete, task.host, task.project_path, task.repo_id, task.sandbox_owner, task.program, task.enabled, task.created_at, task.last_run_at, task.last_run_status, task.last_run_target, task.last_run_id, task.last_run_started_at, task.dropped_events, task.audit, task.overdue, task.missed_occurrences, task.missed_occurrences_capped, task.unschedulable, task.unschedulable_reason, task.unassessable, task.next_run_at, task.next_run_far, task.arming, task.ordinal, task.store_generation
/v1/UpdateTask update.name, update.prompt, update.cron_expr, update.watch_cmd, update.target_session, update.max_concurrent_runs, update.on_complete, update.host, update.project_path, update.program, update.enabled, expect.enforce, expect.project_path
/v1/RemoveTask expect.enforce, expect.project_path
/v1/RestartTask expect.enforce, expect.project_path
/v1/TriggerTask expect.enforce, expect.project_path