REST API
Scripts and other servers can create tasks, check on them, and send follow-ups over HTTP. These are the same endpoints the CoderFlow CLI uses. For agents and AI clients, the MCP Server offers the same actions as tools.
This page documents a small set of endpoints for integrations. Other routes the Web UI calls exist, but they are internal and may change between releases.
Authentication
Send a personal API key as a Bearer token on every request:
curl -H "Authorization: Bearer $CODER_API_KEY" "$CODERFLOW_URL/auth/me"
Requests run as the key's owner, with that user's permissions. For an integration on another server, create a key limited to what it needs:
- To follow up one existing task, choose Selected tasks only with that task ID, and Send follow-ups (plus Read the task if it should read the result).
- To monitor tasks, choose Read-only.
- To create tasks, a Full access key is needed. Give it an expiry.
See Restrict a Key. A request outside the key's
access returns 403 with "code": "api_key_scope_denied".
Request and response bodies are JSON. Errors return a non-2xx status with
error and usually message fields; some also have a machine-readable code
or errorCode.
Create a Task
POST /tasks
| Field | Notes |
|---|---|
environment | The environment name. Omit it to use your default environment. |
parameters.instructions | The instructions for the agent. |
task_type | Optional template name. Template parameters go in parameters. |
name | Optional task name. |
curl -X POST "$CODERFLOW_URL/tasks" \
-H "Authorization: Bearer $CODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"environment":"billing","parameters":{"instructions":"Add input validation to the invoice form."}}'
The response is 202 with the new task's taskId, status and environment.
A message says whether the task started or is queued for a free slot. This
needs the tasks:create permission in the environment and a full-access key.
Read a Task
GET /tasks/:id
Returns the task's details, including taskId, status, environment,
createdAt, finishedAt and exitCode. Poll it to see when a turn finishes.
GET /tasks/:id/results?include=latestResponse
Returns task, result and latestResponse, the agent's latest reply as text:
| Field | Notes |
|---|---|
latestResponse.displayText | The reply. Interactive choices are given as text, with how to answer. |
latestResponse.truncated | true when the text was shortened; totalChars gives the full length. |
latestResponse.followUpsSince | Follow-ups sent after this reply. Greater than 0 means the agent has not answered the latest one yet. |
latestResponse.timestamp | When the reply was written. |
latestResponse is null before the agent's first reply. Both endpoints need
view permission on the task.
Send a Follow-up
POST /tasks/:id/follow-up
| Field | Notes |
|---|---|
instructions | Required. The follow-up text. |
queueIfBusy | Optional. true queues the follow-up if the agent is still working; it is delivered when the current turn ends. Without it, a busy task returns 409. |
idempotencyKey | Optional, recommended. A unique string per follow-up, also accepted as an Idempotency-Key header. A retry with the same key returns the first outcome instead of sending the follow-up twice. |
deliverAt | Optional. An ISO 8601 date and time with a UTC offset, such as 2026-12-01T09:00:00-05:00, to schedule the follow-up up to 30 days ahead. See Schedule a Follow-up. |
curl -X POST "$CODERFLOW_URL/tasks/$TASK_ID/follow-up" \
-H "Authorization: Bearer $CODER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"instructions":"QA found a failing login test. See ticket QA-142 and fix it.",
"queueIfBusy":true,
"idempotencyKey":"qa-142-run-7"}'
The response is 200 when the follow-up was sent now, or 202 when it was
queued or scheduled; both include taskId and status. Other responses:
| Status | Meaning |
|---|---|
400 | instructions is missing or a field is invalid. |
403 | The user cannot change this task, or the key is not allowed to follow it up. |
404 | The task does not exist. |
409 | The agent is busy and queueIfBusy was not set, or another operation on the task is in progress. Retry, or send with queueIfBusy. |
To attach files, send the request as multipart/form-data with the same fields
and one or more attachments file parts.
This needs tasks:change on the task. A key limited to the task with Send
follow-ups is enough.