Skip to main content
POST
/
api
/
chat-messages
Create a new message in a chat via API key
curl --request POST \
  --url https://api.leanmcp.com/api/chat-messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
  "role": "system",
  "content": "<string>",
  "id": "abc123-def456-789-ghi-012345678901",
  "messageIndex": 0,
  "metadata": {},
  "fileIds": [
    "f1a83d84-7154-464c-bd19-a9f10e0a067f",
    "f2b94e95-8265-575d-ce2a-b0f21f1b178g"
  ]
}
'
{
  "id": "<string>",
  "chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
  "userId": "<string>",
  "role": "system",
  "content": "<string>",
  "messageIndex": 1,
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "metadata": {}
}

Authorizations

Authorization
string
header
required

Enter your LeanMCP API key

Body

application/json
chatId
string
required

Chat ID this message belongs to (UUID)

Example:

"c1a83d84-7154-464c-bd19-a9f10e0a067f"

role
enum<string>
required

Role of the message sender

Available options:
system,
assistant,
user
content
string
required

Message content/text

id
string

Pre-generated message ID (UUID). Auto-generated if not provided

Example:

"abc123-def456-789-ghi-012345678901"

messageIndex
number

Order of message in chat (0-based). Auto-calculated if not provided

Required range: x >= 0
Example:

0

metadata
object

Additional metadata for the message

fileIds
string[]

Array of file IDs to associate with this message

Example:
[
"f1a83d84-7154-464c-bd19-a9f10e0a067f",
"f2b94e95-8265-575d-ce2a-b0f21f1b178g"
]

Response

Message created successfully

id
string
required

Unique message identifier (UUID)

chatId
string
required

Chat ID this message belongs to (UUID)

Example:

"c1a83d84-7154-464c-bd19-a9f10e0a067f"

userId
string
required

User ID who owns this message

role
enum<string>
required

Role of the message sender

Available options:
system,
assistant,
user
content
string
required

Message content/text

messageIndex
number
required

Order of message in the chat (0-based)

Required range: x >= 0
createdAt
string
required

Timestamp when message was created

updatedAt
string
required

Timestamp when message was last updated

metadata
object

Additional metadata for the message