Manage memories
This guide shows how to forget a memory and how to tell Alvia which memories are useful. Both operations need the memory’s ID, which you get from recall, search or list.
For endpoint schemas and status codes, use the API reference.
Forget a memory
Section titled “Forget a memory”curl -X DELETE \ https://api.alvia.ai/v1/memories/mem_01K6Z1M4TB7D9E2F5G8H3J6K0P \ -H "Authorization: Bearer $ALVIA_API_KEY"import osimport requests
API_KEY = os.environ["ALVIA_API_KEY"]MEMORY_ID = "mem_01K6Z1M4TB7D9E2F5G8H3J6K0P"
response = requests.delete( f"https://api.alvia.ai/v1/memories/{MEMORY_ID}", headers={"Authorization": f"Bearer {API_KEY}"}, timeout=30,)response.raise_for_status() # 202 Accepted, empty bodyconst memoryId = "mem_01K6Z1M4TB7D9E2F5G8H3J6K0P";
const response = await fetch( `https://api.alvia.ai/v1/memories/${memoryId}`, { method: "DELETE", headers: { Authorization: `Bearer ${process.env.ALVIA_API_KEY}` }, },);// 202 Accepted, empty bodyif (!response.ok) { throw new Error(`${response.status}: ${await response.text()}`);}package main
import ( "io" "log" "net/http" "os" "time")
func main() { memoryID := "mem_01K6Z1M4TB7D9E2F5G8H3J6K0P" req, err := http.NewRequest(http.MethodDelete, "https://api.alvia.ai/v1/memories/"+memoryID, nil) if err != nil { log.Fatal(err) } key := os.Getenv("ALVIA_API_KEY") req.Header.Set("Authorization", "Bearer "+key)
client := &http.Client{Timeout: 30 * time.Second} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() // 202 Accepted, empty body if resp.StatusCode != http.StatusAccepted { body, _ := io.ReadAll(resp.Body) log.Fatalf("%s: %s", resp.Status, body) }}var key = Environment.GetEnvironmentVariable("ALVIA_API_KEY");using var http = new HttpClient();http.Timeout = TimeSpan.FromSeconds(30);http.DefaultRequestHeaders.Authorization = new("Bearer", key);
var memoryId = "mem_01K6Z1M4TB7D9E2F5G8H3J6K0P";var response = await http.DeleteAsync( $"https://api.alvia.ai/v1/memories/{memoryId}");response.EnsureSuccessStatusCode(); // 202 Accepted, empty bodyThe response is 202 with an empty body. Forgetting the same memory again also returns 202.
Forgetting is permanent. A forgotten memory leaves every read:
- Get, list and context drop it at once, in context both as a match and as a related or contradicting memory
- Search and recall drop it as well
- The memory stops counting against the stored-memory limit
When a fact changes, send the new fact: Alvia records it as the memory’s next version, so the memory stays. Forget a memory when a user asks your application to forget something, or when a fact was stored by mistake.
Give feedback
Section titled “Give feedback”curl -X PUT \ https://api.alvia.ai/v1/memories/mem_01K6Y3V9QF2W8H4N7C5X0RZB1D/feedback \ -H "Authorization: Bearer $ALVIA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "is_favorited": true, "sentiment": "positive" }'import osimport requests
API_KEY = os.environ["ALVIA_API_KEY"]MEMORY_ID = "mem_01K6Y3V9QF2W8H4N7C5X0RZB1D"
response = requests.put( f"https://api.alvia.ai/v1/memories/{MEMORY_ID}/feedback", headers={"Authorization": f"Bearer {API_KEY}"}, json={"is_favorited": True, "sentiment": "positive"}, timeout=30,)response.raise_for_status() # 204 No Contentconst memoryId = "mem_01K6Y3V9QF2W8H4N7C5X0RZB1D";
const response = await fetch( `https://api.alvia.ai/v1/memories/${memoryId}/feedback`, { method: "PUT", headers: { Authorization: `Bearer ${process.env.ALVIA_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ is_favorited: true, sentiment: "positive", }), },);// 204 No Contentif (!response.ok) { throw new Error(`${response.status}: ${await response.text()}`);}package main
import ( "bytes" "encoding/json" "io" "log" "net/http" "os" "time")
func main() { memoryID := "mem_01K6Y3V9QF2W8H4N7C5X0RZB1D" payload, err := json.Marshal(map[string]any{ "is_favorited": true, "sentiment": "positive", }) if err != nil { log.Fatal(err) } req, err := http.NewRequest(http.MethodPut, "https://api.alvia.ai/v1/memories/"+memoryID+"/feedback", bytes.NewReader(payload)) if err != nil { log.Fatal(err) } key := os.Getenv("ALVIA_API_KEY") req.Header.Set("Authorization", "Bearer "+key) req.Header.Set("Content-Type", "application/json")
client := &http.Client{Timeout: 30 * time.Second} resp, err := client.Do(req) if err != nil { log.Fatal(err) } defer resp.Body.Close() // 204 No Content if resp.StatusCode != http.StatusNoContent { body, _ := io.ReadAll(resp.Body) log.Fatalf("%s: %s", resp.Status, body) }}using System.Net.Http.Json;
var key = Environment.GetEnvironmentVariable("ALVIA_API_KEY");using var http = new HttpClient();http.Timeout = TimeSpan.FromSeconds(30);http.DefaultRequestHeaders.Authorization = new("Bearer", key);
var memoryId = "mem_01K6Y3V9QF2W8H4N7C5X0RZB1D";var response = await http.PutAsJsonAsync( $"https://api.alvia.ai/v1/memories/{memoryId}/feedback", new { is_favorited = true, sentiment = "positive" });response.EnsureSuccessStatusCode(); // 204 No ContentRequest fields
Section titled “Request fields”| Field | Required | Description |
|---|---|---|
is_favorited |
Yes | true raises the memory’s rank in future reads. false removes that boost. |
sentiment |
Yes | positive: useful. negative: wrong, outdated or irrelevant. neutral: mixed or informational. |
Forget takes no request body.
Response
Section titled “Response”Feedback returns 204 with no body. Each call replaces the memory’s earlier feedback, and
ranking updates within moments.
Feedback changes ranking and leaves the memory’s text as it is. negative sentiment lowers a
memory’s rank; to remove a memory from reads, forget it.
Forget and feedback count as writes for Rate limits, but they never use your monthly write allowance.
Retries
Section titled “Retries”- Forget is safe to repeat. Forgetting a memory that is already forgotten returns
202again. - Feedback is safe to repeat. Each call replaces the earlier feedback, so a repeat changes nothing.
- Retry only calls that failed: network errors,
5xxresponses and429responses, after the wait inRetry-After. See Production checklist.
Errors
Section titled “Errors”| Error | Cause |
|---|---|
400 validation_error |
Feedback: a field is missing or has a value the API does not accept. |
401 unauthorized |
The API key is missing or not valid. |
404 not_found |
The memory does not exist or belongs to another project. Feedback: also a forgotten memory. |
429 rate_limit_exceeded |
Too many requests per second. |
See Errors for every code.