Skip to main content
PATCH
/
api
/
chat-messages
/
id
/
{id}
Update message content via API key
curl --request PATCH \
  --url https://api.leanmcp.com/api/chat-messages/id/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "content": "Updated message content here",
  "metadata": {
    "edited": true,
    "editedAt": "2025-06-16T20:00:00Z"
  }
}
'
import requests

url = "https://api.leanmcp.com/api/chat-messages/id/{id}"

payload = {
"content": "Updated message content here",
"metadata": {
"edited": True,
"editedAt": "2025-06-16T20:00:00Z"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
content: 'Updated message content here',
metadata: {edited: true, editedAt: '2025-06-16T20:00:00Z'}
})
};

fetch('https://api.leanmcp.com/api/chat-messages/id/{id}', 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/id/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'content' => 'Updated message content here',
'metadata' => [
'edited' => true,
'editedAt' => '2025-06-16T20:00:00Z'
]
]),
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/id/{id}"

payload := strings.NewReader("{\n \"content\": \"Updated message content here\",\n \"metadata\": {\n \"edited\": true,\n \"editedAt\": \"2025-06-16T20:00:00Z\"\n }\n}")

req, _ := http.NewRequest("PATCH", 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.patch("https://api.leanmcp.com/api/chat-messages/id/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"Updated message content here\",\n \"metadata\": {\n \"edited\": true,\n \"editedAt\": \"2025-06-16T20:00:00Z\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.leanmcp.com/api/chat-messages/id/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"Updated message content here\",\n \"metadata\": {\n \"edited\": true,\n \"editedAt\": \"2025-06-16T20:00:00Z\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "chatId": "c1a83d84-7154-464c-bd19-a9f10e0a067f",
  "userId": "<string>",
  "content": "<string>",
  "messageIndex": 1,
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "metadata": {}
}

Authorizations

Authorization
string
header
required

Enter your LeanMCP API key

Path Parameters

id
string
required

Message ID

Body

application/json
content
string

Updated message content

Example:

"Updated message content here"

metadata
object

Updated metadata

Example:
{
"edited": true,
"editedAt": "2025-06-16T20:00:00Z"
}

Response

Message updated 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