Skip to main content
POST
/
api
/
chat-messages
/
chat
/
id
/
{chatId}
/
bulk
Add multiple messages to a chat via API key
curl --request POST \
  --url https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {
      "role": "user",
      "content": "Hello, can you help me with my project?",
      "metadata": {
        "model": "claude-3-sonnet",
        "tokens": 150
      },
      "fileIds": [
        "f1a83d84-7154-464c-bd19-a9f10e0a067f",
        "f2b94e95-8265-575d-ce2a-b0f21f1b178g"
      ]
    }
  ]
}
'
{
  "messages": [
    {
      "id": "<string>",
      "chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
      "userId": "<string>",
      "role": "system",
      "content": "<string>",
      "messageIndex": 1,
      "createdAt": "<string>",
      "updatedAt": "<string>",
      "metadata": {}
    }
  ],
  "count": 123,
  "chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f"
}

Authorizations

Authorization
string
header
required

Enter your LeanMCP API key

Path Parameters

chatId
string
required

Chat ID

Example:

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

Body

application/json
messages
object[]
required

Array of messages to create

Response

Messages added to chat successfully

messages
object[]
required

Created messages

count
number
required

Number of messages created

chatId
string
required

Chat ID where messages were added

Example:

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