Base URL
All requests go to the versioned production base URL:/v1 is the API version. Prepend the base URL to every
endpoint path shown in this reference.
Authentication
Authenticate with a secret key. Create one in the dashboard under Settings > Secret keys. Secret keys are organization-scoped and grant read/write access to the API, so keep them server-side only. Send the key as a bearer token:401.
Errors
Errors return a non-2xx HTTP status and a JSON body with the error fields at the top level. Thecode field carries a stable machine-readable code, and
operationId names the endpoint that failed:
reason (a machine-readable sub-code) and, on
429, retryAfterSeconds. missingContext lists any required context that
was absent from the request. A 400 whose message is Input validation failed also carries issues, one entry per rejected field, so you can tell
which field to change:
Branch on the top-level
code field rather than parsing message; messages
are for humans and can change.
Rate limits
The API enforces per-organization and per-key request rate limits. When you exceed one, the API returns429 with code TOO_MANY_REQUESTS. Back off and
retry. For the shape of these limits, see Limits.
Pagination
The API uses two pagination strategies. Check each endpoint’s generated schema to see which one it uses. Cursor-based (most list endpoints). The response carries anextCursor;
pass it back as the cursor query parameter to fetch the next page. A null
nextCursor means there are no more results.
/v1/search/threads, /v1/search/messages, and
/v1/billing/transactions take a one-based page query parameter and return a
pagination object with page, limit, totalPages, and a total count
(totalResults for search, total for billing transactions). Increment
page until you reach totalPages.
Streaming
Agent runs and threads stream events over Server-Sent Events. See Streaming.In this section
Browse every operation by resource in the sidebar, or start from a resource group below:Streaming
Stream agent run and thread events over Server-Sent Events.