Tasks
For instructions on how to authenticate to use this endpoint, see API overview.
Endpoints
GET | |
GET | |
POST | |
GET | |
POST | |
POST | |
GET | |
PATCH | |
PATCH | |
POST |
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. A resumed Pi run includes the earlier runs of its task session the same way, each preceded by a pi_run_started entry that names its run. For a live presence-gated run, the request marks the stream as watched before it reads the log, so events after the snapshot reach the live stream. Pass tail_bytes to read only the latest turns first, add before to page back through older turns, or add start to read every entry after the ones a client holds. X-Log-Origin names the first run of the chain: indexes from responses with different origins do not match. A Pi run returns its full log without the X-Log headers.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- beforeinteger
- startinteger
- tail_bytesinteger
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. A resumed Pi run includes the earlier runs of its task session the same way, each preceded by a pi_run_started entry that names its run. For a live presence-gated run, the request marks the stream as watched before it reads the log, so events after the snapshot reach the live stream. Pass tail_bytes to read only the latest turns first, add before to page back through older turns, or add start to read every entry after the ones a client holds. X-Log-Origin names the first run of the chain: indexes from responses with different origins do not match. A Pi run returns its full log without the X-Log headers.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Query parameters
- beforeinteger
- startinteger
- tail_bytesinteger
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 peers
Agent runs this run may send messages to: cloud Pi runs of tasks created by the same user, currently in progress or queued. Discovery and send validation share one visibility policy, so a run can only message what it can list; the per-entry sendable flag is the liveness contract.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Response
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /peersExample response
Status 200 Active agent runs this run may message
Status 403 Peer messaging is disabled or the task is not on the Pi runtime
Status 404 Run not found
Retrieve tasks runs peers
Agent runs this run may send messages to: cloud Pi runs of tasks created by the same user, currently in progress or queued. Discovery and send validation share one visibility policy, so a run can only message what it can list; the per-entry sendable flag is the liveness contract.
Required API key scopes
task:readPath parameters
- idstring
- task_idstring
Response
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /peersExample response
Status 200 Active agent runs this run may message
Status 403 Peer messaging is disabled or the task is not on the Pi runtime
Status 404 Run not found
Create tasks runs peers message
Relay a message from this run to a peer agent run. The body is delivered below a server-composed provenance envelope as a queued (non-steer) turn; attachments are copied into the target run's own artifact storage. accepted means queued for delivery, never delivered — the sandbox handoff happens later inside the target's workflow.
Required API key scopes
task:writePath parameters
- idstring
- target_run_idstring
- task_idstring
Request parameters
- contentstring
- artifact_idsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /peers /:target_run_id /messageExample response
Status 200 Synchronous send result (accepted / target_finished / rejected)
Status 400 Invalid message payload
Status 403 Peer messaging is disabled or the task is not on the Pi runtime
Status 404 Run not found
Create tasks runs peers message
Relay a message from this run to a peer agent run. The body is delivered below a server-composed provenance envelope as a queued (non-steer) turn; attachments are copied into the target run's own artifact storage. accepted means queued for delivery, never delivered — the sandbox handoff happens later inside the target's workflow.
Required API key scopes
task:writePath parameters
- idstring
- target_run_idstring
- task_idstring
Request parameters
- contentstring
- artifact_idsarray
Response
Example request
POST /api /projects /:project_id /tasks /:task_id /runs /:id /peers /:target_run_id /messageExample response
Status 200 Synchronous send result (accepted / target_finished / rejected)
Status 400 Invalid message payload
Status 403 Peer messaging is disabled or the task is not on the Pi runtime
Status 404 Run not found
Retrieve tasks runs preview
Redirects to the PostHog dev stack running inside this run's sandbox. A fresh sandbox access token is minted on every request and carried only in the redirect target, so it is never persisted or returned in a response body. When the run has no preview, or its sandbox has stopped, this renders a short HTML page instead.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /previewExample response
Status 200 HTML page explaining that the preview is not ready yet or has ended
Status 302 Redirect to the sandbox preview with a freshly minted access token
Status 403 Refused during read-only impersonation
Status 404 Task run not found
Retrieve tasks runs preview
Redirects to the PostHog dev stack running inside this run's sandbox. A fresh sandbox access token is minted on every request and carried only in the redirect target, so it is never persisted or returned in a response body. When the run has no preview, or its sandbox has stopped, this renders a short HTML page instead.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Example request
GET /api /projects /:project_id /tasks /:task_id /runs /:id /previewExample response
Status 200 HTML page explaining that the preview is not ready yet or has ended
Status 302 Redirect to the sandbox preview with a freshly minted access token
Status 403 Refused during read-only impersonation
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
- message_idstring | null
- text_partsarray
- trace_idstring | null
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
- message_idstring | null
- text_partsarray
- trace_idstring | null
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 403 PostHog Desktop access is required, or Pi cloud runtime is disabled
Status 429 Team is over its posthog_code usage limit
Status 503 PostHog Desktop access could not be verified
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 403 PostHog Desktop access is required, or Pi cloud runtime is disabled
Status 429 Team is over its posthog_code usage limit
Status 503 PostHog Desktop access could not be verified
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
Update tasks runs set summary
Replace the running summary for a task run, and optionally its slug tags.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- summarystring
- tagsarray
Response
Example request
PATCH /api /projects /:project_id /tasks /:task_id /runs /:id /set_summaryExample response
Status 200 Run with updated task summary
Status 404 Run not found
Update tasks runs set summary
Replace the running summary for a task run, and optionally its slug tags.
Required API key scopes
task:writePath parameters
- idstring
- task_idstring
Request parameters
- summarystring
- tagsarray
Response
Example request
PATCH /api /projects /:project_id /tasks /:task_id /runs /:id /set_summaryExample response
Status 200 Run with updated task summary
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 403 PostHog Desktop access is required, or Pi cloud runtime is disabled
Status 404 Task run not found
Status 429 Team is over its posthog_code usage limit
Status 503 PostHog Desktop access could not be verified
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 /start










