Skip to main content
POST
/
api
/
v1
/
chat-history
/
chats
/
{chat_id}
/
messages
Create Message
curl --request POST \
  --url https://api.mor.org/api/v1/chat-history/chats/{chat_id}/messages \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "role": "<string>",
  "content": "<string>",
  "tokens": 123
}'
{
  "id": "<string>",
  "role": "<string>",
  "content": "<string>",
  "sequence": 123,
  "created_at": "<string>",
  "tokens": 123
}
Add a message to a chat. Store user or assistant messages in a chat conversation. This allows you to build a complete conversation history.

Headers

Authorization
string
required
Bearer token (JWT) from OAuth2 login

Path Parameters

chat_id
string
required
The ID of the chat to add the message to

Body

role
string
required
Message role: user or assistant
content
string
required
Message content
tokens
integer
Token count for billing purposes (optional)

Response

id
string
Unique message identifier
role
string
Message role
content
string
Message content
sequence
integer
Message order in conversation (auto-incremented)
created_at
string
ISO 8601 timestamp when created
tokens
integer
Token count (if provided)
Automatic Sequencing: The sequence field is automatically incremented to maintain message order. You don’t need to manage this manually.
Token Tracking: Include the tokens field to track token usage for billing and analytics. This is especially useful when storing AI-generated responses.
Messages are stored in chronological order. The sequence number ensures correct ordering even if messages are created out of order.