Skip to main content
PUT
/
v1
/
batch
/
Python
# To use the Python SDK, install the package:
# pip install mem0ai

from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")

update_memories = [
    {
        "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496",
        "text": "Watches football"
    },
    {
        "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",
        "text": "Likes to travel"
    }
]

response = client.batch_update(update_memories)
print(response)
// To use the JavaScript SDK, install the package:
// npm i mem0ai

import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });

const updateMemories = [
{
memoryId: "285ed74b-6e05-4043-b16b-3abd5b533496",
text: "Watches football"
},
{
memoryId: "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",
text: "Likes to travel"
}
];

client.batchUpdate(updateMemories)
.then(response => console.log('Batch update response:', response))
.catch(error => console.error(error));
curl -X PUT "https://api.mem0.ai/v1/batch/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
"memories": [
{
"memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496",
"text": "Watches football"
},
{
"memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",
"text": "Likes to travel"
}
]
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mem0.ai/v1/batch/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'memories' => [
[
'memory_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'text' => '<string>',
'metadata' => [

]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.mem0.ai/v1/batch/"

payload := strings.NewReader("{\n \"memories\": [\n {\n \"memory_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"text\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "<api-key>")
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.put("https://api.mem0.ai/v1/batch/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"memories\": [\n {\n \"memory_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"text\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.mem0.ai/v1/batch/")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"memories\": [\n {\n \"memory_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"text\": \"<string>\",\n \"metadata\": {}\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Successfully updated 2 memories"
}
{
"error": "Maximum of 1000 memories can be updated in a single request"
}

Authorizations

Authorization
string
header
required

API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'

Body

application/json
memories
object[]
required
Maximum array length: 1000

Response

Successfully updated memories

message
string
Example:

"Successfully updated 2 memories"