Skip to main content

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
FieldNotes
environmentThe environment name. Omit it to use your default environment.
parameters.instructionsThe instructions for the agent.
task_typeOptional template name. Template parameters go in parameters.
nameOptional 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:

FieldNotes
latestResponse.displayTextThe reply. Interactive choices are given as text, with how to answer.
latestResponse.truncatedtrue when the text was shortened; totalChars gives the full length.
latestResponse.followUpsSinceFollow-ups sent after this reply. Greater than 0 means the agent has not answered the latest one yet.
latestResponse.timestampWhen 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
FieldNotes
instructionsRequired. The follow-up text.
queueIfBusyOptional. 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.
idempotencyKeyOptional, 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.
deliverAtOptional. 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:

StatusMeaning
400instructions is missing or a field is invalid.
403The user cannot change this task, or the key is not allowed to follow it up.
404The task does not exist.
409The 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.