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"
]
}
]
}
'import requests
url = "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk"
payload = { "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"]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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']
}
]
})
};
fetch('https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "<string>",
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"userId": "<string>",
"content": "<string>",
"messageIndex": 1,
"createdAt": "<string>",
"updatedAt": "<string>",
"metadata": {}
}
],
"count": 123,
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f"
}Add multiple messages to a chat via API key
Bulk insert multiple messages into a chat using API key authentication. MessageIndex values are auto-calculated sequentially. Requires CHAT scope.
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"
]
}
]
}
'import requests
url = "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk"
payload = { "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"]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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']
}
]
})
};
fetch('https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leanmcp.com/api/chat-messages/chat/id/{chatId}/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, can you help me with my project?\",\n \"metadata\": {\n \"model\": \"claude-3-sonnet\",\n \"tokens\": 150\n },\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "<string>",
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"userId": "<string>",
"content": "<string>",
"messageIndex": 1,
"createdAt": "<string>",
"updatedAt": "<string>",
"metadata": {}
}
],
"count": 123,
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f"
}Authorizations
Enter your LeanMCP API key
Path Parameters
Chat ID
Example:
"c1a83d84-7154-464c-bd19-a9f10e0a067f"
Body
application/json
Array of messages to create
Show child attributes
Show child attributes
⌘I

