Execute a context action

POST/v1/threads/{threadId}/context/actions

Run 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
NameLocationTypeRequiredDescription
threadIdpathstringYesThread ID
Query parameters
None.

Body schema

Content type: application/json · Required

FieldTypeRequiredDescription
actioncompact | clear | fork | btwYesContext-management action to execute.
promptstringNoOptional prompt used for actions like `btw`.
titlestringNoOptional 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
FieldTypeRequiredDescription
actionobjectNo
action.typecompact | clear | fork | btwNo
action.threadIdstringNoThread ID.
action.sessionIdstringNoSession ID.
action.messagestringNoMessage text.
action.responseTextstringNo
action.threadobjectNo
action.thread.idstringNoUnique identifier.
action.thread.projectIdstringNoProject ID.
action.thread.environmentIdstringNoComputer ID.
action.thread.agentIdstringNoAgent ID.
action.thread.titlestringNoDisplay title.
action.thread.taskstringNo
action.thread.appIdstringNo
action.thread.statusactive | running | completed | failed | cancelledNoCurrent lifecycle status.
action.thread.messageCountintegerNo
action.thread.lastMessageAtstringNo
action.thread.lastMessagePreviewstringNo
action.thread.inputTokensintegerNo
action.thread.outputTokensintegerNo
action.thread.totalCostnumberNo
action.thread.environmentMinutesnumberNo
action.thread.metadataobjectNoFree-form metadata object.
action.thread.teamExecutionobjectNo
action.thread.teamExecution.modeteamNo
action.thread.teamExecution.teamAgentIdstringNo
action.thread.teamExecution.teamAgentNamestringNo
action.thread.teamExecution.orchestratorobjectNo
action.thread.teamExecution.orchestrator.agentIdstringNoAgent ID.
action.thread.teamExecution.orchestrator.agentNamestringNo
action.thread.teamExecution.orchestrator.claudeAgentNamestringNo
action.thread.teamExecution.subagentsobject[]No
action.thread.teamExecution.subagents[].agentIdstringNoAgent ID.
action.thread.teamExecution.subagents[].agentNamestringNo
action.thread.teamExecution.subagents[].claudeAgentNamestringNo
action.thread.subagentActivityobject[]No
action.thread.subagentActivity[].agentIdstringNoAgent ID.
action.thread.subagentActivity[].agentNamestringNo
action.thread.subagentActivity[].claudeAgentNamestringNo
action.thread.subagentActivity[].eventCountintegerNo
action.thread.subagentActivity[].lastActiveAtstringNo
action.thread.subagentActivity[].teamAgentIdstringNo
action.thread.subagentActivity[].teamAgentNamestringNo
action.thread.environmentNamestringNo
action.thread.agentNamestringNo
action.thread.createdAtstringNoISO 8601 timestamp.
action.thread.updatedAtstringNoISO 8601 timestamp.
409Thread is currently running
None.
Execute a context action
Loading...
Response 200
Loading...
See the ACP quickstart and SDK flow