Tasks-2

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

POST
POST
GET
GET
POST
GET
PATCH
GET
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:read

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Request parameters

  • storage_path
    string

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/presign
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/presign/\
-d storage_path="string"

Example response

Status 200 Presigned URL for the requested artifact
RESPONSE
{
"url": "http://example.com",
"expires_in": 0
}
Status 400 Invalid request
RESPONSE
{
"error": "string"
}
Status 404 Artifact not found

Create tasks runs command

Forward a JSON-RPC command to the agent server running in the sandbox. Supports user_message, cancel, and close commands.

Required API key scopes

task:write

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Request parameters

  • jsonrpc
  • method
  • params
    object
  • id

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/command
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/command/\
-d jsonrpc=undefined,\
-d method=undefined

Example response

Status 200 Agent server response
RESPONSE
{
"jsonrpc": "string",
"id": null,
"result": {
"property1": null,
"property2": null
},
"error": {
"property1": null,
"property2": null
}
}
Status 400 Invalid command or no active sandbox
RESPONSE
{
"error": "string"
}
Status 404 Task run not found
Status 502 Agent server unreachable
RESPONSE
{
"error": "string"
}

Retrieve tasks runs connection token

Generate a JWT token for direct connection to the sandbox. Valid for 24 hours.

Required API key scopes

task:read

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Response


Example request

GET /api/projects/:project_id/tasks/:task_id/runs/:id/connection_token
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/connection_token/

Example response

Status 200 Connection token for direct sandbox connection
RESPONSE
{
"token": "string"
}
Status 404 Task run not found

Retrieve tasks runs logs

Fetch the logs for a task run. Returns JSONL formatted log entries.

Required API key scopes

task:read

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Example request

GET /api/projects/:project_id/tasks/:task_id/runs/:id/logs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/logs/

Example 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:write

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Request parameters

  • text
    string

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/relay_message
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/relay_message/\
-d text="string"

Example response

Status 200 Relay accepted
RESPONSE
{
"status": "string",
"relay_id": "string"
}
Status 404 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:read

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Query parameters

  • after
    string
  • event_types
    string
  • exclude_types
    string
  • limit
    integer
    Default: 1000

Example request

GET /api/projects/:project_id/tasks/:task_id/runs/:id/session_logs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/session_logs/

Example 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:write

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Response


Example request

PATCH /api/projects/:project_id/tasks/:task_id/runs/:id/set_output
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/set_output/

Example response

Status 200 Run with updated output
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "not_started",
"environment": "local",
"log_url": "string",
"error_message": "string",
"output": null,
"state": null,
"artifacts": [
{
"name": "string",
"type": "string",
"size": 0,
"content_type": "string",
"storage_path": "string",
"uploaded_at": "string"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z"
}
Status 404 Run not found

Retrieve tasks runs stream

API for managing task runs. Each run represents an execution of a task.

Required API key scopes

task:read

Path parameters

  • id
    string
  • project_id
    string
  • task_id
    string

Response


Example request

GET /api/projects/:project_id/tasks/:task_id/runs/:id/stream
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/:task_id/runs/:id/stream/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "not_started",
"environment": "local",
"log_url": "string",
"error_message": "string",
"output": null,
"state": null,
"artifacts": [
{
"name": "string",
"type": "string",
"size": 0,
"content_type": "string",
"storage_path": "string",
"uploaded_at": "string"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z"
}

Retrieve tasks repository readiness

Get autonomy readiness details for a specific repository in the current project.

Required API key scopes

task:read

Path parameters

  • project_id
    string

Query parameters

  • refresh
    boolean
    Default: false
  • repository
    string
  • window_days
    integer
    Default: 7

Response


Example request

GET /api/projects/:project_id/tasks/repository_readiness
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/repository_readiness/

Example response

Status 200 Repository readiness status
RESPONSE
{
"repository": "string",
"classification": "string",
"excluded": true,
"coreSuggestions": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"replayInsights": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"errorInsights": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"overall": "string",
"evidenceTaskCount": 0,
"windowDays": 0,
"generatedAt": "string",
"cacheAgeSeconds": 0,
"scan": {
"filesScanned": 0,
"detectedFilesCount": 0,
"eventNameCount": 0,
"foundPosthogInit": true,
"foundPosthogCapture": true,
"foundErrorSignal": true
}
}

Retrieve tasks repository readiness

Get autonomy readiness details for a specific repository in the current project.

Required API key scopes

task:read

Path parameters

  • project_id
    string

Query parameters

  • refresh
    boolean
    Default: false
  • repository
    string
  • window_days
    integer
    Default: 7

Response


Example request

GET /api/projects/:project_id/tasks/repository_readiness
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/tasks/repository_readiness/

Example response

Status 200 Repository readiness status
RESPONSE
{
"repository": "string",
"classification": "string",
"excluded": true,
"coreSuggestions": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"replayInsights": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"errorInsights": {
"state": "needs_setup",
"estimated": true,
"reason": "string",
"evidence": {
"property1": null,
"property2": null
}
},
"overall": "string",
"evidenceTaskCount": 0,
"windowDays": 0,
"generatedAt": "string",
"cacheAgeSeconds": 0,
"scan": {
"filesScanned": 0,
"detectedFilesCount": 0,
"eventNameCount": 0,
"foundPosthogInit": true,
"foundPosthogCapture": true,
"foundErrorSignal": true
}
}

Community questions

Questions about this page? or post a community question.