Skip to main content
POST
/
api
/
threads
/
{threadId}
/
messages
curl -X POST https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000/messages \
  -H "Content-Type: application/json" \
  -d '{
    "role": "user",
    "content": "Hello, I need help with my order",
    "context": {
      "orderId": "ORD-12345"
    },
    "userId": "user_abc123"
  }'
{
  "success": true,
  "messageId": "msg_550e8400-e29b-41d4-a716-446655440000"
}
Sends a message to a thread and triggers an agent response.
This endpoint queues the message and returns immediately. To receive the agent’s response in real-time, use the WebSocket stream.
threadId
string
required
The unique thread identifier (UUID)
role
string
required
Message role: "user", "system", or "assistant"
content
string
required
The message content
context
object
Optional context data passed to the agent’s FlowState. Available in tools and hooks via flow.context.
userId
string
Optional user identifier for tracking
success
boolean
required
Whether the message was successfully queued
messageId
string
required
The unique identifier for the created message
curl -X POST https://your-worker.workers.dev/api/threads/550e8400-e29b-41d4-a716-446655440000/messages \
  -H "Content-Type: application/json" \
  -d '{
    "role": "user",
    "content": "Hello, I need help with my order",
    "context": {
      "orderId": "ORD-12345"
    },
    "userId": "user_abc123"
  }'
{
  "success": true,
  "messageId": "msg_550e8400-e29b-41d4-a716-446655440000"
}