mosoodocs

Create a Thread for an Agent API Endpoint

Creates a Thread and the backing AgentSession. If input is present, Mosoo also queues the initial Run.

POST/agents/{agentId}/threads

Creates a Thread and the backing AgentSession. If input is present, Mosoo also queues the initial Run. If input is omitted, the Thread is immediately visible with IDLE status and no run. API token callers are attributed to the API token owner.

Authorization

publicApiBearer
AuthorizationBearer <token>

Use Authorization: Bearer mst_... . API tokens identify an account and do not carry scopes.

In: header

Path Parameters

agentId*string

Agent API Endpoint ID from the Agent's API Access panel. v1 IDs are bare ULIDs.

Match^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$
Formatulid

Header Parameters

Idempotency-Key?string

Optional key for retry-safe create-thread and send-events calls. Reusing the same key with the same request returns the original response. Reusing the key while the original request is still processing returns 409.

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request body for creating a Thread. All fields are optional: omit input to create an empty IDLE Thread, or include it to queue the initial Run.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/agents/01J00000000000000000000001/threads" \  -H "Idempotency-Key: thread-20260528-linear-eng-123" \  -H "Content-Type: application/json" \  -d '{    "client_external_ref": "draft-empty-thread"  }'
{  "links": {    "thread": "string"  },  "run": {    "completedAt": "2019-08-24T14:15:22Z",    "createdAt": "2019-08-24T14:15:22Z",    "error": {      "code": "string",      "message": "string",      "retryable": true    },    "finalOutput": {      "text": "string"    },    "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "startedAt": "2019-08-24T14:15:22Z",    "status": "queued",    "trigger": "user_prompt",    "updatedAt": "2019-08-24T14:15:22Z"  },  "thread": {    "agent_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "attributed_user": {      "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV"    },    "client_external_ref": "string",    "created_at": "2019-08-24T14:15:22Z",    "created_by": {      "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",      "kind": "access_token"    },    "id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "kind": "pet",    "last_run_id": "01ARZ3NDEKTSV4RRFFQ69G5FAV",    "source": "api",    "status": "IDLE",    "title": "string",    "updated_at": "2019-08-24T14:15:22Z"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}
{  "error": {    "code": "agent_not_published",    "message": "string"  }}