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",
"content": "<string>",
"id": "abc123-def456-789-ghi-012345678901",
"messageIndex": 0,
"metadata": {},
"fileIds": [
"f1a83d84-7154-464c-bd19-a9f10e0a067f",
"f2b94e95-8265-575d-ce2a-b0f21f1b178g"
]
}
'import requests
url = "https://api.leanmcp.com/api/chat-messages"
payload = {
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"content": "<string>",
"id": "abc123-def456-789-ghi-012345678901",
"messageIndex": 0,
"metadata": {},
"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({
chatId: 'c1a83d84-7154-464c-bd19-a9f10e0a067f',
content: '<string>',
id: 'abc123-def456-789-ghi-012345678901',
messageIndex: 0,
metadata: {},
fileIds: ['f1a83d84-7154-464c-bd19-a9f10e0a067f', 'f2b94e95-8265-575d-ce2a-b0f21f1b178g']
})
};
fetch('https://api.leanmcp.com/api/chat-messages', 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",
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([
'chatId' => 'c1a83d84-7154-464c-bd19-a9f10e0a067f',
'content' => '<string>',
'id' => 'abc123-def456-789-ghi-012345678901',
'messageIndex' => 0,
'metadata' => [
],
'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"
payload := strings.NewReader("{\n \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leanmcp.com/api/chat-messages")
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 \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"userId": "<string>",
"role": "system",
"content": "<string>",
"messageIndex": 1,
"createdAt": "<string>",
"updatedAt": "<string>",
"metadata": {}
}Create a new message in a chat via API key
Create a message with explicit chatId using API key authentication. MessageIndex is auto-calculated if not provided. Requires CHAT scope.
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",
"content": "<string>",
"id": "abc123-def456-789-ghi-012345678901",
"messageIndex": 0,
"metadata": {},
"fileIds": [
"f1a83d84-7154-464c-bd19-a9f10e0a067f",
"f2b94e95-8265-575d-ce2a-b0f21f1b178g"
]
}
'import requests
url = "https://api.leanmcp.com/api/chat-messages"
payload = {
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"content": "<string>",
"id": "abc123-def456-789-ghi-012345678901",
"messageIndex": 0,
"metadata": {},
"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({
chatId: 'c1a83d84-7154-464c-bd19-a9f10e0a067f',
content: '<string>',
id: 'abc123-def456-789-ghi-012345678901',
messageIndex: 0,
metadata: {},
fileIds: ['f1a83d84-7154-464c-bd19-a9f10e0a067f', 'f2b94e95-8265-575d-ce2a-b0f21f1b178g']
})
};
fetch('https://api.leanmcp.com/api/chat-messages', 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",
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([
'chatId' => 'c1a83d84-7154-464c-bd19-a9f10e0a067f',
'content' => '<string>',
'id' => 'abc123-def456-789-ghi-012345678901',
'messageIndex' => 0,
'metadata' => [
],
'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"
payload := strings.NewReader("{\n \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leanmcp.com/api/chat-messages")
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 \"chatId\": \"c1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"content\": \"<string>\",\n \"id\": \"abc123-def456-789-ghi-012345678901\",\n \"messageIndex\": 0,\n \"metadata\": {},\n \"fileIds\": [\n \"f1a83d84-7154-464c-bd19-a9f10e0a067f\",\n \"f2b94e95-8265-575d-ce2a-b0f21f1b178g\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
"userId": "<string>",
"role": "system",
"content": "<string>",
"messageIndex": 1,
"createdAt": "<string>",
"updatedAt": "<string>",
"metadata": {}
}Authorizations
Enter your LeanMCP API key
Body
Chat ID this message belongs to (UUID)
"c1a83d84-7154-464c-bd19-a9f10e0a067f"
Role of the message sender
system, assistant, user Message content/text
Pre-generated message ID (UUID). Auto-generated if not provided
"abc123-def456-789-ghi-012345678901"
Order of message in chat (0-based). Auto-calculated if not provided
x >= 00
Additional metadata for the message
Array of file IDs to associate with this message
[
"f1a83d84-7154-464c-bd19-a9f10e0a067f",
"f2b94e95-8265-575d-ce2a-b0f21f1b178g"
]
Response
Message created successfully
Unique message identifier (UUID)
Chat ID this message belongs to (UUID)
"c1a83d84-7154-464c-bd19-a9f10e0a067f"
User ID who owns this message
Role of the message sender
system, assistant, user Message content/text
Order of message in the chat (0-based)
x >= 0Timestamp when message was created
Timestamp when message was last updated
Additional metadata for the message

