Skip to main content
POST
/
api
/
threads
curl -X POST https://your-worker.workers.dev/api/threads \
  -H "Content-Type: application/json" \
  -d '{
    "agentName": "support_agent",
    "userId": "user_abc123",
    "metadata": {
      "source": "web"
    }
  }'
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "agentName": "support_agent",
  "created_at": 1699900000000,
  "metadata": {
    "source": "web"
  }
}
Creates a new conversation thread with the specified agent.
agentName
string
required
The name of the agent to use for this thread. Must match an agent defined in agents/agents/.
userId
string
Optional user identifier for tracking and authorization.
metadata
object
Optional metadata object to store with the thread.
id
string
required
Unique thread identifier (UUID)
agentName
string
required
The agent name associated with this thread
created_at
number
required
Unix timestamp in milliseconds
metadata
object
Thread metadata object
curl -X POST https://your-worker.workers.dev/api/threads \
  -H "Content-Type: application/json" \
  -d '{
    "agentName": "support_agent",
    "userId": "user_abc123",
    "metadata": {
      "source": "web"
    }
  }'
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "agentName": "support_agent",
  "created_at": 1699900000000,
  "metadata": {
    "source": "web"
  }
}