## Documentation Index

Fetch the complete documentation index at: [/llms.txt](https://docs.mem0.ai/llms.txt)

Use this file to discover all available pages before exploring further.

### Python

```python
# To use the Python SDK, install the package:
# pip install mem0ai

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

# Update a memory
memory_id = "<memory_id>"
client.update(
    memory_id=memory_id,
    text="Your updated memory message here",
    metadata={"category": "example"}
)
```

### JavaScript

```javascript
// To use the JavaScript SDK, install the package:
// npm i mem0ai

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

// Update a specific memory
const memory_id = "<memory_id>";
client.update(memory_id, {
  text: "Your updated memory message here",
  metadata: { category: "example" }
})
  .then(result => console.log(result))
  .catch(error => console.error(error));
```

### cURL

```
curl --request PUT \
  --url https://api.mem0.ai/v1/memories/{memory_id}/ \
  --header 'Authorization: Token <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{"text": "Your updated memory text here", "metadata": {"category": "example"}}'
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

url := "https://api.mem0.ai/v1/memories/{memory_id}/"

payload := strings.NewReader(`{
	"text": "Your updated memory text here",
	"metadata": {
		"category": "example"
	}
}`)

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

req.Header.Add("Authorization", "Token <api-key>")
	req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
	fmt.Println(string(body))
}
```

### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.mem0.ai/v1/memories/{memory_id}/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_HTTPHEADER => [
    "Authorization: Token <api-key>",
    "Content-Type: application/json"
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "text" => "Your updated memory text here",
    "metadata" => ["category" => "example"]
  ])
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
?>
```

### HTTP Unirest

```
HttpResponse<String> response = Unirest.put("https://api.mem0.ai/v1/memories/{memory_id}/")
  .header("Authorization", "Token <api-key>")
  .header("Content-Type", "application/json")
  .body("{\"text\": \"Your updated memory text here\", \"metadata\": {\"category\": \"example\"}}")
  .asString();
```

### Ruby

```
require 'uri'
require 'net/http'

url = URI("https://api.mem0.ai/v1/memories/{memory_id}/")

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  \"text\": \"<string>\",\n  \"metadata\": {},\n  \"expiration_date\": \"2023-12-25\"\n}"

response = http.request(request)
puts response.read_body
```

### Response Example

```json
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "text": "<string>",
  "user_id": "<string>",
  "agent_id": "<string>",
  "app_id": "<string>",
  "run_id": "<string>",
  "hash": "<string>",
  "metadata": {},
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z"
}
```

### Usage
Use this endpoint to update mutable memory fields. To make a memory expire, set `expiration_date` to a `YYYY-MM-DD` date. To make it permanent again, send `expiration_date: null`.

```python
client.update("mem_123", expiration_date="2030-01-31")
client.update("mem_123", expiration_date=None)
```

### Authorizations

Authorization
- type: string
- location: header
- required: true

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

### Path Parameters

- **memory_id**: string<uuid> (required) - The unique identifier of the memory to retrieve.

### Body Parameters

- **text**: string - The updated text content of the memory
- **metadata**: object - Additional metadata associated with the memory
- **expiration_date**: string<date> | null - Expiration date in YYYY-MM-DD format, or null to clear the expiration date.

### Response

- **200 - application/json** - Successfully updated memory.
  - **id**: string<uuid> - The unique identifier of the updated memory.
  - **text**: string - The updated text content of the memory.
  - **user_id**: string | null - The user ID associated with the memory, if any.
  - **agent_id**: string | null - The agent ID associated with the memory, if any.
  - **app_id**: string | null - The app ID associated with the memory, if any.
  - **run_id**: string | null - The run ID associated with the memory, if any.
  - **hash**: string - Hash of the memory content.
  - **metadata**: object - Additional metadata associated with the memory.
  - **created_at**: string<date-time> - Timestamp of when the memory was created.
  - **updated_at**: string<date-time> - Timestamp of when the memory was last updated.
