Tasks

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

Endpoints

POST
POST
POST
POST
POST
POST
POST
POST
POST
GET

Create tasks runs artifacts dismiss

Hides artifacts from clients without deleting them from storage, so a file dismissed by mistake can be restored.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifact_ids
    array
  • dismissed
    boolean
    Default: true

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/dismiss
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/dismiss/\
-d artifact_ids="array"

Example response

Status 200 Run with updated artifact manifest
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 404 Artifact not found

Create tasks runs artifacts dismiss

Hides artifacts from clients without deleting them from storage, so a file dismissed by mistake can be restored.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifact_ids
    array
  • dismissed
    boolean
    Default: true

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/dismiss
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/dismiss/\
-d artifact_ids="array"

Example response

Status 200 Run with updated artifact manifest
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 404 Artifact not found

Create tasks runs artifacts download

Streams artifact content for a task run artifact after validating that it belongs to the run.

Required API key scopes

task:read

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • storage_path
    string

Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/download
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/download/\
-d storage_path="string"

Example response

Status 200 Artifact content
Status 400 Invalid request
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Artifact not found

Create tasks runs artifacts download

Streams artifact content for a task run artifact after validating that it belongs to the run.

Required API key scopes

task:read

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • storage_path
    string

Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/download
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/download/\
-d storage_path="string"

Example response

Status 200 Artifact content
Status 400 Invalid request
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Artifact not found

Create tasks runs artifacts finalize upload

Verify directly uploaded S3 objects and attach them to the run artifact manifest.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifacts
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/finalize_upload
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/finalize_upload/\
-d artifacts="array"

Example response

Status 200 Run with updated artifact manifest
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 400 Invalid artifact payload
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Run not found

Create tasks runs artifacts finalize upload

Verify directly uploaded S3 objects and attach them to the run artifact manifest.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifacts
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/finalize_upload
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/finalize_upload/\
-d artifacts="array"

Example response

Status 200 Run with updated artifact manifest
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 400 Invalid artifact payload
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Run not found

Create tasks runs artifacts prepare upload

Reserve S3 object keys for task artifacts and return presigned POST forms for direct uploads.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifacts
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/prepare_upload
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/prepare_upload/\
-d artifacts="array"

Example response

Status 200 Prepared uploads for the requested artifacts
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"expires_in": 0,
"presigned_post": {
"url": "http://example.com",
"fields": {
"property1": "string",
"property2": "string"
}
}
}
]
}
Status 400 Invalid artifact payload
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Run not found

Create tasks runs artifacts prepare upload

Reserve S3 object keys for task artifacts and return presigned POST forms for direct uploads.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • artifacts
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/prepare_upload
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/prepare_upload/\
-d artifacts="array"

Example response

Status 200 Prepared uploads for the requested artifacts
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"expires_in": 0,
"presigned_post": {
"url": "http://example.com",
"fields": {
"property1": "string",
"property2": "string"
}
}
}
]
}
Status 400 Invalid artifact payload
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Run 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:read

Path parameters

  • 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
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
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:read

Path parameters

  • 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
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Artifact not found

Create tasks runs artifacts references

Attach live PostHog object references to the run artifact manifest without uploading files.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • references
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/references
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/references/\
-d references="array"

Example response

Status 200 Run with updated reference artifacts
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 404 Run not found

Create tasks runs artifacts references

Attach live PostHog object references to the run artifact manifest without uploading files.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • references
    Click to open
    array

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/artifacts/references
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/references/\
-d references="array"

Example response

Status 200 Run with updated reference artifacts
RESPONSE
{
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
]
}
Status 404 Run not found

Create tasks runs cancel

Stop an active cloud run. Interrupts the agent, snapshots interactive sessions for later resume, tears down the sandbox, and marks the run cancelled. Idempotent: cancelling a finished run returns it unchanged.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • reason
    string | null
  • only_if_awaiting_first_message
    boolean
    Default: false

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/cancel
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/cancel/\
-d reason="string"

Example response

Status 200 Run already finished, or `only_if_awaiting_first_message` was set and the run has since received its first message; returned unchanged
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 202 Cancellation accepted
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 400 Run is not a cloud run
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 503 Cancellation could not be delivered; safe to retry
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

Create tasks runs cancel

Stop an active cloud run. Interrupts the agent, snapshots interactive sessions for later resume, tears down the sandbox, and marks the run cancelled. Idempotent: cancelling a finished run returns it unchanged.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Request parameters

  • reason
    string | null
  • only_if_awaiting_first_message
    boolean
    Default: false

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/cancel
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/cancel/\
-d reason="string"

Example response

Status 200 Run already finished, or `only_if_awaiting_first_message` was set and the run has since received its first message; returned unchanged
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 202 Cancellation accepted
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 400 Run is not a cloud run
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 503 Cancellation could not be delivered; safe to retry
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

Create tasks runs clear conversation

Record a /clear boundary in a finished run's log so the next run in the chain starts with an empty conversation. Its artifacts and visible history are unaffected. Only for a finished run: an active one has an agent that owns the clear, so send /clear to it as an ordinary message instead.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/clear_conversation
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/clear_conversation/

Example response

Status 200 Run with the boundary recorded
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 404 Run not found
Status 409 Run is still active; send /clear to its agent
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 Log is locked by another append; retry
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

Create tasks runs clear conversation

Record a /clear boundary in a finished run's log so the next run in the chain starts with an empty conversation. Its artifacts and visible history are unaffected. Only for a finished run: an active one has an agent that owns the clear, so send /clear to it as an ordinary message instead.

Required API key scopes

task:write

Path parameters

  • id
    string
  • task_id
    string

Response


Example request

POST /api/projects/:project_id/tasks/:task_id/runs/:id/clear_conversation
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/clear_conversation/

Example response

Status 200 Run with the boundary recorded
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task": "4879b8a6-fb3e-4a0d-aef8-b0ea469ac85c",
"stage": "string",
"branch": "string",
"status": "string",
"environment": "string",
"runtime_adapter": "claude",
"provider": "anthropic",
"model": "string",
"reasoning_effort": "off",
"log_url": "http://example.com",
"error_message": "string",
"output": {},
"task_summary": "string",
"task_tags": [
"string"
],
"state": {},
"artifacts": [
{
"id": "string",
"name": "string",
"type": "string",
"source": "string",
"size": 0,
"content_type": "string",
"metadata": {
"skill_name": "string",
"skill_source": "user",
"content_sha256": "string",
"bundle_format": "zip",
"schema_version": 1
},
"storage_path": "string",
"uploaded_at": "string",
"uploaded_by": "agent",
"uploaded_by_user_id": 0,
"dismissed_at": "string",
"url": "http://example.com"
}
],
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"completed_at": "2019-08-24T14:15:22Z",
"scheduled_at": "2019-08-24T14:15:22Z",
"preview_available": true
}
Status 404 Run not found
Status 409 Run is still active; send /clear to its agent
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 Log is locked by another append; retry
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

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, set_config_option, mcp_response, side_question, native Pi RPC commands, and Pi queue operations. Retry loop: a 503 is transient (sandbox_not_ready means the command arrived before the live run's command channel came up; agent_session_not_ready means an approval was rejected before execution while the agent starts) — retry it until the request you are answering expires. A 502 (agent server unreachable) or 504 (agent server timed out) means delivery is unknown; retry only when the command method is safe to retry. A 409 run_ended is final: the run is over and its sandbox is gone. HTTP 200 preserves JSON-RPC errors; permission acceptance requires result.resolved=true.

Required API key scopes

task:write

Path parameters

  • 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": null,
"error": {}
}
Status 400 Invalid command — fatal, do not retry. (Legacy exception: interactive PostHog Desktop grants still receive the transient `sandbox_not_ready` condition as a 400 for every method except `credential_response`, because shipped Desktop builds branch on that status; API callers always get it as a 503.)
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 403 PostHog Desktop access is required to message this run's agent
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 409 Final, do not retry. Task run workflow has ended; `permission_target_ended` for an ended approval target; `run_ended` when the run is completed, failed, or cancelled and its sandbox is cleaned up — unlike `sandbox_not_ready`, nothing will ever come up
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 429 Organization reached its PostHog Desktop usage limit
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 502 Agent server unreachable
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 Transient, retry after `Retry-After` until the request you are answering expires. Code `sandbox_not_ready`: the run is still live but its sandbox's command channel is not reachable yet — the usual answer to a command sent as soon as the run asks for one, such as a credential_response (a 409 `run_ended` ends that loop). Code `agent_session_not_ready`: approval rejected before execution while the agent starts. Or PostHog Desktop access could not be verified.
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

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, set_config_option, mcp_response, side_question, native Pi RPC commands, and Pi queue operations. Retry loop: a 503 is transient (sandbox_not_ready means the command arrived before the live run's command channel came up; agent_session_not_ready means an approval was rejected before execution while the agent starts) — retry it until the request you are answering expires. A 502 (agent server unreachable) or 504 (agent server timed out) means delivery is unknown; retry only when the command method is safe to retry. A 409 run_ended is final: the run is over and its sandbox is gone. HTTP 200 preserves JSON-RPC errors; permission acceptance requires result.resolved=true.

Required API key scopes

task:write

Path parameters

  • 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": null,
"error": {}
}
Status 400 Invalid command — fatal, do not retry. (Legacy exception: interactive PostHog Desktop grants still receive the transient `sandbox_not_ready` condition as a 400 for every method except `credential_response`, because shipped Desktop builds branch on that status; API callers always get it as a 503.)
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 403 PostHog Desktop access is required to message this run's agent
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 409 Final, do not retry. Task run workflow has ended; `permission_target_ended` for an ended approval target; `run_ended` when the run is completed, failed, or cancelled and its sandbox is cleaned up — unlike `sandbox_not_ready`, nothing will ever come up
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 429 Organization reached its PostHog Desktop usage limit
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 502 Agent server unreachable
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 Transient, retry after `Retry-After` until the request you are answering expires. Code `sandbox_not_ready`: the run is still live but its sandbox's command channel is not reachable yet — the usual answer to a command sent as soon as the run asks for one, such as a credential_response (a 409 `run_ended` ends that loop). Code `agent_session_not_ready`: approval rejected before execution while the agent starts. Or PostHog Desktop access could not be verified.
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

Retrieve tasks runs connection token

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

Required API key scopes

task:write

Path parameters

  • 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 403 PostHog Desktop access is required
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 429 Organization reached its PostHog Desktop usage limit
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 PostHog Desktop access could not be verified
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}

Retrieve tasks runs connection token

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

Required API key scopes

task:write

Path parameters

  • 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 403 PostHog Desktop access is required
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 404 Task run not found
Status 429 Organization reached its PostHog Desktop usage limit
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}
Status 503 PostHog Desktop access could not be verified
RESPONSE
{
"detail": "string",
"error": "string",
"type": "string",
"code": "string",
"retry_token": "string",
"reason": "startup_plan",
"attr": "string",
"missing_artifact_ids": [
"string"
],
"limit_type": "burst",
"reset_at": "string",
"is_pro": true
}