Drive a thread end to end
Create with a caller-mintedrequestId so a timed-out create can be retried without starting a second run:
pending_user means the agent asked you something; ready_for_review means it delivered. Either way, the answer is in the transcript:
after set to the response’s cursor until it’s null.
Reply, and the loop starts again:
"delivery": "queue" to let the current work finish first, and the receipt’s id is what you’d pass to POST $API/threads/$THREAD_ID/messages/{id}/cancel if you change your mind while it’s still waiting.
Inspect a thread’s task tree
Agents fan work out to task subagents, which either share the parent’s machine or run on a fresh one. The task endpoints are read-only observation: a task is driven through its thread, so if you want a task to change course, message the thread. List the tree; pages walk depth-first, so parents always precede children and every page prefix is a coherent subtree:taskPath is the dotted address from the thread root: 1.2 is the second task under the first task. status is the run state: working, waiting, idle, done, or failed. Each task’s usage is its own subtree’s spend, so you can see where the credits went.
Read one task and its transcript with the same Message shape threads use:
Start a review on a pull request
POST /reviews starts a Capy review round on any PR in a repository your organization’s GitHub installation covers:
adopted: true and runs nothing new. Push a commit and the next call opens a fresh round. Omit idempotencyKey and this scope keying is the whole dedup; pass forceRefresh: true for a confirmed manual re-run of an already-completed round.
If one of your threads should hear the verdict, pass its id as sourceThreadId: the round’s outcome lands in that thread as an ordinary input and wakes it, instead of you polling. The response’s sourceRecorded tells you whether that notification was actually recorded (false when the adopted round already reports elsewhere or already finished; read the findings in the app instead of waiting).
A closed or draft PR, or a PR GitHub won’t let Capy read, answers capy/ReviewRefused (422) with the reason.
Trigger an automation webhook
An automation with an incoming-webhook trigger exposes a capability URL. Note this one is not under/api/v1 and takes no bearer header, because the URL itself is the credential:
Idempotency-Key is your retry safety: deliveries with the same key start one run, so your alerting system can fire the hook at-least-once without fanning out runs. A 202 body of accepted means a run was admitted, duplicate means your key already ran, and no-match means the automation’s trigger filters rejected this body: a valid delivery that starts no run, so don’t retry it. 404 means the URL is wrong or the automation is disabled, deliberately indistinguishable.
The body reaches the agent as quoted, untrusted event context under the automation’s stored prompt: send data for the agent to act on, not instructions.