Skip to main content
POST
/
api
/
chats
/
{chatId}
/
messages
curl --request POST \
  --url https://api.yourdomain.com/api/chats/chat_123abc/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123abc",
    "role": "user",
    "parts": [
      {
        "type": "text",
        "text": "Hello, how can you help me today?"
      }
    ],
    "attachments": [],
    "metadata": {
      "source": "web"
    }
  }'
{
  "success": true,
  "message": "Message created successfully",
  "data": {
    "id": "msg_456def",
    "chatId": "chat_123abc",
    "role": "user",
    "parts": [
      {
        "type": "text",
        "text": "Hello, how can you help me today?"
      }
    ],
    "attachments": [],
    "metadata": {
      "source": "web"
    },
    "createdAt": "2024-01-17T10:30:00Z"
  }
}

Path Parameters

chatId
string
required
Chat ID where the message will be created

Body Parameters

id
string
Optional message ID
chatId
string
required
Chat ID (must match path parameter)
role
string
required
Message role (e.g., “user”, “assistant”, “system”)
parts
array
required
Array of message parts
attachments
array
Array of attachment IDs (strings)
metadata
object
Additional metadata for the message

Response

success
boolean
Indicates if the message was created successfully
message
string
Success or error message
data
object
The created message object
curl --request POST \
  --url https://api.yourdomain.com/api/chats/chat_123abc/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "chatId": "chat_123abc",
    "role": "user",
    "parts": [
      {
        "type": "text",
        "text": "Hello, how can you help me today?"
      }
    ],
    "attachments": [],
    "metadata": {
      "source": "web"
    }
  }'
{
  "success": true,
  "message": "Message created successfully",
  "data": {
    "id": "msg_456def",
    "chatId": "chat_123abc",
    "role": "user",
    "parts": [
      {
        "type": "text",
        "text": "Hello, how can you help me today?"
      }
    ],
    "attachments": [],
    "metadata": {
      "source": "web"
    },
    "createdAt": "2024-01-17T10:30:00Z"
  }
}