Create thread

POST/v1/sessions/{id}/threads

Authorization

header

Authorization: Bearer <token>

An access token from Settings → Access tokens, with the scopes this call needs. Authentication

Path parameters

idstringrequired
TypeID with prefix "asess_".

Request body

application/json · required
eventsarray<TextSubmitted | Stopped | SessionSuggestionResolved | ...>
Items
1 to 100
idempotencyKeystring | null
Optional creation idempotency key, scoped to the caller and session for 48 hours. Retrying create or fork with the same key returns the first thread without consuming capacity, even without events. The first label, model, fork source, and kickoff events win. Omit for a new thread on every call.
Length
1 to 512
labelstring
Length
1 to 255
modelConfigobject
deliveryIdstring | null
Deprecated alias for idempotencyKey, accepted for one release. idempotencyKey wins when both are present.
Length
1 to 512

Responses

ThreadResultapplication/json

threadIdintegerrequired
Range
0 to 9007199254740991
kickoffstring | null
Present when kickoff events were supplied. A failed kickoff still returns the created thread. Retry create or fork with the same idempotencyKey to reuse this thread and retry kickoff, or retry only its events with this threadId. A repeated key returns duplicate.
Value in
"accepted" | "duplicate" | "failed"