Execute a context action
POST
/v1/threads/{threadId}/context/actionsRun thread context actions such as compact, clear, fork, or btw.
How to call this endpoint
Every ACP API request uses bearer authentication. The examples here show the actual request path, auth header, and body shape that the platform expects.
Path, query, and header parameters
These parameters control which ACP object the endpoint acts on and how the request is processed.
Path parameters
| Name | Location | Type | Required | Description |
|---|---|---|---|---|
| threadId | path | string | Yes | Thread ID |
Query parameters
None.
Body schema
Content type: application/json · Required
| Field | Type | Required | Description |
|---|---|---|---|
| action | compact | clear | fork | btw | Yes | Context-management action to execute. |
| prompt | string | No | Optional prompt used for actions like `btw`. |
| title | string | No | Optional title for the forked thread. |
What the API returns
Each response code below includes the documented payload shape for the ACP API.
200Context action completedapplication/json
| Field | Type | Required | Description |
|---|---|---|---|
| action | object | No | — |
| action.type | compact | clear | fork | btw | No | — |
| action.threadId | string | No | Thread ID. |
| action.sessionId | string | No | Session ID. |
| action.message | string | No | Message text. |
| action.responseText | string | No | — |
| action.thread | object | No | — |
| action.thread.id | string | No | Unique identifier. |
| action.thread.projectId | string | No | Project ID. |
| action.thread.environmentId | string | No | Computer ID. |
| action.thread.agentId | string | No | Agent ID. |
| action.thread.title | string | No | Display title. |
| action.thread.task | string | No | — |
| action.thread.appId | string | No | — |
| action.thread.status | active | running | completed | failed | cancelled | No | Current lifecycle status. |
| action.thread.messageCount | integer | No | — |
| action.thread.lastMessageAt | string | No | — |
| action.thread.lastMessagePreview | string | No | — |
| action.thread.inputTokens | integer | No | — |
| action.thread.outputTokens | integer | No | — |
| action.thread.totalCost | number | No | — |
| action.thread.environmentMinutes | number | No | — |
| action.thread.metadata | object | No | Free-form metadata object. |
| action.thread.teamExecution | object | No | — |
| action.thread.teamExecution.mode | team | No | — |
| action.thread.teamExecution.teamAgentId | string | No | — |
| action.thread.teamExecution.teamAgentName | string | No | — |
| action.thread.teamExecution.orchestrator | object | No | — |
| action.thread.teamExecution.orchestrator.agentId | string | No | Agent ID. |
| action.thread.teamExecution.orchestrator.agentName | string | No | — |
| action.thread.teamExecution.orchestrator.claudeAgentName | string | No | — |
| action.thread.teamExecution.subagents | object[] | No | — |
| action.thread.teamExecution.subagents[].agentId | string | No | Agent ID. |
| action.thread.teamExecution.subagents[].agentName | string | No | — |
| action.thread.teamExecution.subagents[].claudeAgentName | string | No | — |
| action.thread.subagentActivity | object[] | No | — |
| action.thread.subagentActivity[].agentId | string | No | Agent ID. |
| action.thread.subagentActivity[].agentName | string | No | — |
| action.thread.subagentActivity[].claudeAgentName | string | No | — |
| action.thread.subagentActivity[].eventCount | integer | No | — |
| action.thread.subagentActivity[].lastActiveAt | string | No | — |
| action.thread.subagentActivity[].teamAgentId | string | No | — |
| action.thread.subagentActivity[].teamAgentName | string | No | — |
| action.thread.environmentName | string | No | — |
| action.thread.agentName | string | No | — |
| action.thread.createdAt | string | No | ISO 8601 timestamp. |
| action.thread.updatedAt | string | No | ISO 8601 timestamp. |
409Thread is currently running
None.