Tasks
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
POST | |
POST | |
GET | |
GET | |
POST | |
POST | |
GET | |
PATCH | |
POST | |
GET |
Create tasks runs artifacts presign
Returns a temporary, signed URL that can be used to download a specific artifact.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Request parameters
- storage_pathstring
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /artifacts /presignExample response
Status 200 Presigned URL for the requested artifact
Status 400 Invalid request
Status 404 Artifact not found
Create tasks runs artifacts presign
Returns a temporary, signed URL that can be used to download a specific artifact.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Request parameters
- storage_pathstring
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /artifacts /presignExample response
Status 200 Presigned URL for the requested artifact
Status 400 Invalid request
Status 404 Artifact not found
Create tasks runs command
Queue user_message JSON-RPC commands through the task workflow and forward sandbox control commands to the agent server. Supports user_message, cancel, close, permission_response, and set_config_option commands.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- jsonrpc
- method
- paramsobject
- id
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /commandExample response
Status 200 Agent server response
Status 400 Invalid command or no active sandbox
Status 404 Task run not found
Status 502 Agent server unreachable
Create tasks runs command
Queue user_message JSON-RPC commands through the task workflow and forward sandbox control commands to the agent server. Supports user_message, cancel, close, permission_response, and set_config_option commands.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- jsonrpc
- method
- paramsobject
- id
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /commandExample response
Status 200 Agent server response
Status 400 Invalid command or no active sandbox
Status 404 Task run not found
Status 502 Agent server unreachable
Retrieve tasks runs connection token
Generate a JWT token for direct connection to the sandbox. Valid for 24 hours.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Response
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /connection_tokenExample response
Status 200 Connection token for direct sandbox connection
Status 404 Task run not found
Retrieve tasks runs connection token
Generate a JWT token for direct connection to the sandbox. Valid for 24 hours.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Response
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /connection_tokenExample response
Status 200 Connection token for direct sandbox connection
Status 404 Task run not found
Retrieve tasks runs logs
Fetch the logs for a task run as JSONL. If the run resumes from another (state.resume_from_run_id), each ancestor's log is concatenated first (oldest ancestor → ... → this run) so resume consumers see a single continuous history and can find the most recent git_checkpoint event regardless of which run emitted it.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /logsExample response
Status 200 Log content in JSONL format
Status 404 Task run not found
Retrieve tasks runs logs
Fetch the logs for a task run as JSONL. If the run resumes from another (state.resume_from_run_id), each ancestor's log is concatenated first (oldest ancestor → ... → this run) so resume consumers see a single continuous history and can find the most recent git_checkpoint event regardless of which run emitted it.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /logsExample response
Status 200 Log content in JSONL format
Status 404 Task run not found
Create tasks runs relay message
Queue a Slack relay workflow to post a run message into the mapped Slack thread.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- textstring
- text_partsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /relay_messageExample response
Status 200 Relay accepted
Status 404 Run not found
Create tasks runs relay message
Queue a Slack relay workflow to post a run message into the mapped Slack thread.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- textstring
- text_partsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /relay_messageExample response
Status 200 Relay accepted
Status 404 Run not found
Create tasks runs resume in cloud
Resume an existing task run in a cloud sandbox. Terminates any existing workflow and starts a new one.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /resume_in_cloudExample response
Status 200 Run resumed in cloud
Status 400 Run already active or workflow failed
Status 429 Team is over its posthog_code usage limit
Create tasks runs resume in cloud
Resume an existing task run in a cloud sandbox. Terminates any existing workflow and starts a new one.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /resume_in_cloudExample response
Status 200 Run resumed in cloud
Status 400 Run already active or workflow failed
Status 429 Team is over its posthog_code usage limit
Retrieve tasks runs session logs
Fetch session log entries for a task run with optional filtering by timestamp, event type, and limit.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- afterstring
- event_typesstring
- exclude_typesstring
- limitintegerDefault:
1000 - offsetintegerDefault:
0
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /session_logsExample response
Status 200 Filtered log events as JSON array
Status 404 Task run not found
Retrieve tasks runs session logs
Fetch session log entries for a task run with optional filtering by timestamp, event type, and limit.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- afterstring
- event_typesstring
- exclude_typesstring
- limitintegerDefault:
1000 - offsetintegerDefault:
0
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /session_logsExample response
Status 200 Filtered log events as JSON array
Status 404 Task run not found
Update tasks runs set output
Update the output field for a task run (e.g., PR URL, commit SHA, etc.)
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- output
Response
Example request
PATCH /api /projects /:project_id /tasks /:task_id /runs /:id /set_outputExample response
Status 200 Run with updated output
Status 404 Run not found
Update tasks runs set output
Update the output field for a task run (e.g., PR URL, commit SHA, etc.)
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- output
Response
Example request
PATCH /api /projects /:project_id /tasks /:task_id /runs /:id /set_outputExample response
Status 200 Run with updated output
Status 404 Run not found
Create tasks runs start
Start an existing cloud run after any initial run-scoped attachments have been uploaded.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- pending_user_messagestring
- pending_user_artifact_idsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /startExample response
Status 200 Task with updated latest run
Status 400 Invalid start payload
Status 404 Task run not found
Status 429 Team is over its posthog_code usage limit
Create tasks runs start
Start an existing cloud run after any initial run-scoped attachments have been uploaded.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- pending_user_messagestring
- pending_user_artifact_idsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /startExample response
Status 200 Task with updated latest run
Status 400 Invalid start payload
Status 404 Task run not found
Status 429 Team is over its posthog_code usage limit
Retrieve tasks runs stream
Server-Sent Events stream of task run events. Events carry an id: line (a Redis stream id) usable as a resume cursor.
The server caps each connection at 900 seconds: it emits event: end with data: {"type": "rotated"} and closes. This does NOT mean the run finished — reconnect with the Last-Event-ID header set to the last received event id to resume without gaps or duplicates. Only treat the stream as complete when the run itself reaches a terminal status.
?start=latest consumers must also carry Last-Event-ID across reconnects: reconnecting without it re-resolves to the then-current latest event, silently skipping anything published while disconnected.
SDK consumers: do not call the generated fetch wrapper for this path — it will buffer the entire stream. Use the URL builder (getTasksRunsStreamRetrieveUrl) with a streaming fetch/EventSource-style consumer and the Last-Event-ID header instead.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- startstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /streamExample response
Status 200
Retrieve tasks runs stream
Server-Sent Events stream of task run events. Events carry an id: line (a Redis stream id) usable as a resume cursor.
The server caps each connection at 900 seconds: it emits event: end with data: {"type": "rotated"} and closes. This does NOT mean the run finished — reconnect with the Last-Event-ID header set to the last received event id to resume without gaps or duplicates. Only treat the stream as complete when the run itself reaches a terminal status.
?start=latest consumers must also carry Last-Event-ID across reconnects: reconnecting without it re-resolves to the then-current latest event, silently skipping anything published while disconnected.
SDK consumers: do not call the generated fetch wrapper for this path — it will buffer the entire stream. Use the URL builder (getTasksRunsStreamRetrieveUrl) with a streaming fetch/EventSource-style consumer and the Last-Event-ID header instead.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- startstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /stream