1. Mint an API key
In the app, go to Settings → API and create a key. The plaintext is shown exactly once (there’s no re-display, only revoke-and-remint), so export it now:2. Find your project id
Threads live in projects, and the public API has no projects endpoint yet, so the id comes from the app: open any of your project’s pages and copy the whole route parameter after/project/ in the URL. Newly created projects use project_... ids; imported ones keep their original id.
capy/Unauthorized means the key is wrong or revoked; a capy/ProjectNotFound means the id is wrong or the project isn’t reachable from this key’s organization.
3. Create a thread
requestId is an idempotency token you mint: retries with the same id return the same thread instead of starting a second billable run.
Thread projection, the same shape every thread read returns:
4. Poll the status
status is what you poll on:
Poll every few seconds until the status leaves
active and waiting. Threads run for minutes, not seconds; a real coding task takes as long as the work does.
5. Read the messages
{ items, cursor } of Message entries: your messages (source: "user"), the agent’s replies (source: "assistant"), and one-line tool activity (source: "tool" with the tool name, never raw arguments or results). When the agent opens a pull request, the PR link arrives in its assistant reply text.
Page forward by passing the response’s cursor back as after; poll the same way to tail a live thread.
6. Reply
{ "id": "...", "deduped": false }: the message landed and the agent wakes. By default a message interrupts what the agent is doing; pass "delivery": "queue" to wait for the current work to finish first.