Start an agent turn
const url = 'https://example.com/api/v1/ai/turns';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"context":"example","prompt":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/v1/ai/turns \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "context": "example", "prompt": "example" }'Start an agent turn for the caller. The request includes a prompt and optional calternal context. The prompt must name one supported agent. The response gives the turn ID and status. Route: /api/v1/ai/turns. Inputs: . Do not automatically replay this operation after an uncertain result.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Optional calternal context supplied by the calling editor.
User request containing exactly one whole-token @claude or @codex mention.
Examplegenerated
{ "context": "example", "prompt": "example"}Responses
Section titled “Responses”object
Files, Notes and Tasks writes made with this turn’s token, newest first.
One attributed write. The item ID is the stable identity for /f/<item-id>.
object
Previous path for a move.
Files change-feed operation: create, write, move or trash.
Home-relative path right after the change.
Stable failure or cancellation reason, for example credential_removed.
Unix time in milliseconds when the turn reached a final state.
The server-side turn policy. Ask turns get a token with a read-only scope.
The User’s request as it was sent, without the server’s framing.
The official coding Agent selected by a prompt mention.
queued, running, completed, failed, cancelled, undoing or undone.
Example
{ "kind": "agent", "provider": "claude"}The standard API error response: { "error": { ... } }.
object
Example
{ "error": { "code": "bad_request" }}The standard API error response: { "error": { ... } }.
object
Example
{ "error": { "code": "bad_request" }}The standard API error response: { "error": { ... } }.
object
Example
{ "error": { "code": "bad_request" }}The standard API error response: { "error": { ... } }.
object
Example
{ "error": { "code": "bad_request" }}The standard API error response: { "error": { ... } }.
object
Example
{ "error": { "code": "bad_request" }}