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.userIdstringNoUser ID.
action.thread.organizationIdstringNo—
action.thread.createdByUserIdstringNo—
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 | permission_asked | completed | failed | archived | cancelled | deletedNoCurrent lifecycle status.
action.thread.contextIdstringNo—
action.thread.contextNamestringNo—
action.thread.messageCountintegerNo—
action.thread.lastMessageAtstringNo—
action.thread.lastMessagePreviewstringNo—
action.thread.inputTokensintegerNo—
action.thread.outputTokensintegerNo—
action.thread.cacheTokensintegerNo—
action.thread.totalTokensintegerNo—
action.thread.agentCostnumberNo—
action.thread.agentCostUsdnumberNo—
action.thread.environmentCostnumberNo—
action.thread.environmentCostUsdnumberNo—
action.thread.totalCostnumberNo—
action.thread.totalCostUsdnumberNo—
action.thread.agentCTintegerNo—
action.thread.environmentCTintegerNo—
action.thread.totalCTintegerNo—
action.thread.environmentMinutesnumberNo—
action.thread.environmentStorageGBnumberNo—
action.thread.attachmentsobject[]No—
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.agentPhotoUrlstringNo—
action.thread.agentAvatarUrlstringNo—
action.thread.startedAtstringNoISO 8601 timestamp.
action.thread.completedAtstringNoISO 8601 timestamp.
action.thread.durationstringNo—
action.thread.queuedInBatchbooleanNo—
action.thread.batchJobIdstringNo—
action.thread.admissionReasonstringNo—
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