Skip to content

Start an agent turn

POST
/api/v1/ai/turns
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.

Media typeapplication/json
object
context

Optional calternal context supplied by the calling editor.

string
prompt
required

User request containing exactly one whole-token @claude or @codex mention.

string
Examplegenerated
{
"context": "example",
"prompt": "example"
}
Media typeapplication/json
object
changes
required

Files, Notes and Tasks writes made with this turn’s token, newest first.

Array<object>

One attributed write. The item ID is the stable identity for /f/<item-id>.

object
item_id
required
string
old_path

Previous path for a move.

string | null
operation
required

Files change-feed operation: create, write, move or trash.

string
path
required

Home-relative path right after the change.

string
created_ms
required
integer format: int64
error_code

Stable failure or cancellation reason, for example credential_removed.

string | null
finished_ms

Unix time in milliseconds when the turn reached a final state.

integer | null format: int64
id
required
string
kind
required

The server-side turn policy. Ask turns get a token with a read-only scope.

string
Allowed values: agent ask
prompt
required

The User’s request as it was sent, without the server’s framing.

string
provider
required

The official coding Agent selected by a prompt mention.

string
Allowed values: claude codex
status
required

queued, running, completed, failed, cancelled, undoing or undone.

string
Example
{
"kind": "agent",
"provider": "claude"
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}
Media typeapplication/json

The standard API error response: { "error": { ... } }.

object
error
required

Error details.

object
code
required

Stable machine-readable code.

string
Allowed values: bad_request unauthorized forbidden not_found conflict name_conflict_case name_too_long push_endpoint_rejected too_many_requests internal service_unavailable
details
One of:

Optional field or operation details.

object
key
additional properties
string
message
required

Safe text for logs or a user-facing error message.

string
Example
{
"error": {
"code": "bad_request"
}
}