Add a fact
Save one fact in your own memory or an app user’s memory.
curl --request POST \
--url https://api.atlaso.ai/v1/memory/facts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "Prefers oat-milk lattes."
}
'import requests
url = "https://api.atlaso.ai/v1/memory/facts"
payload = { "text": "Prefers oat-milk lattes." }
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({text: 'Prefers oat-milk lattes.'})
};
fetch('https://api.atlaso.ai/v1/memory/facts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.atlaso.ai/v1/memory/facts"
payload := strings.NewReader("{\n \"text\": \"Prefers oat-milk lattes.\"\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.atlaso.ai/v1/memory/facts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Prefers oat-milk lattes.\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.atlaso.ai/v1/memory/facts");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"text\": \"Prefers oat-milk lattes.\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"id": "0b6f3c1e-2a4d-4e8f-9c1b-5d7e6f8a9b0c",
"object": "memory.fact",
"created": 1763366400,
"text": "Prefers oat-milk lattes.",
"source": "api",
"app_user": "3f9a1c7e5b2d"
}{
"error": {
"message": "This key keeps memory for each user of your app. Use atlaso.for_user(id).memory.",
"type": "invalid_request_error",
"param": "x-atlaso-user",
"code": "memory_scope_per_user",
"doc_url": "https://docs.atlaso.ai/gateway/errors#memory_scope_per_user"
}
}{
"error": {
"message": "Your Atlaso API key is missing, invalid or revoked. Set Authorization: Bearer to an active key from the API keys page.",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key",
"doc_url": "https://docs.atlaso.ai/gateway/errors#invalid_api_key"
}
}{
"error": {
"message": "This key uses your own memory. Use atlaso.memory, without a user id.",
"type": "permission_error",
"param": "x-atlaso-user",
"code": "memory_scope_owner",
"doc_url": "https://docs.atlaso.ai/gateway/errors#memory_scope_owner"
}
}{
"error": {
"message": "This request is still being saved. Retry with the same Idempotency-Key.",
"type": "invalid_request_error",
"param": null,
"code": "idempotency_in_progress",
"doc_url": "https://docs.atlaso.ai/gateway/errors#idempotency_in_progress"
}
}{
"error": {
"message": "The body must be at most 65536 bytes.",
"type": "invalid_request_error",
"param": null,
"code": "request_too_large",
"doc_url": "https://docs.atlaso.ai/gateway/errors#request_too_large"
}
}{
"error": {
"message": "Too many requests. Try again shortly.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limited",
"doc_url": "https://docs.atlaso.ai/gateway/errors#rate_limited"
}
}{
"error": {
"message": "A deletion for this user has not finished yet. Retry the same request in a few seconds; retrying is safe.",
"type": "api_error",
"param": null,
"code": "delete_pending",
"doc_url": "https://docs.atlaso.ai/gateway/errors#delete_pending"
}
}x-atlaso-user; without it the call gets 400 memory_scope_per_user. A key
whose Memory for is Me reaches your own memory and sends no
x-atlaso-user; with it, the call gets 403 memory_scope_owner.
Send an Idempotency-Key header to make a retry safe: a resend with the same key
and the same text within 24 hours saves nothing new. The 409 answers are listed
in Memory API errors. See
Memory API.Authorizations
Headers
Your app user's id, set by your server. A key set to memory for each user of your app must send it on every call; without it the call gets 400 memory_scope_per_user, and an empty value gets 400 missing_user_id. A key whose Memory for is Me reaches your own memory and must not send it: with it, the call gets 403 memory_scope_owner and nothing is read or written. 1 to 256 printable characters, not only spaces, with no API key or token in it. Send it once. Used exactly as sent.
1 - 256Makes a retry safe. 1 to 255 printable ASCII characters, sent once. Resending the same body with the same key within 24 hours returns the first answer instead of saving again, with x-atlaso-idempotent-replay: true. The same key with a different body gets 409 idempotency_key_reused; a resend while the first request is still saving gets 409 idempotency_in_progress. A malformed or repeated header gets 400 invalid_idempotency_key. Do not send it as a body field. The Atlaso SDK sends one for you.
1 - 255Body
Response
The saved fact.
curl --request POST \
--url https://api.atlaso.ai/v1/memory/facts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"text": "Prefers oat-milk lattes."
}
'import requests
url = "https://api.atlaso.ai/v1/memory/facts"
payload = { "text": "Prefers oat-milk lattes." }
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({text: 'Prefers oat-milk lattes.'})
};
fetch('https://api.atlaso.ai/v1/memory/facts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.atlaso.ai/v1/memory/facts"
payload := strings.NewReader("{\n \"text\": \"Prefers oat-milk lattes.\"\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.atlaso.ai/v1/memory/facts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"Prefers oat-milk lattes.\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.atlaso.ai/v1/memory/facts");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"text\": \"Prefers oat-milk lattes.\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"id": "0b6f3c1e-2a4d-4e8f-9c1b-5d7e6f8a9b0c",
"object": "memory.fact",
"created": 1763366400,
"text": "Prefers oat-milk lattes.",
"source": "api",
"app_user": "3f9a1c7e5b2d"
}{
"error": {
"message": "This key keeps memory for each user of your app. Use atlaso.for_user(id).memory.",
"type": "invalid_request_error",
"param": "x-atlaso-user",
"code": "memory_scope_per_user",
"doc_url": "https://docs.atlaso.ai/gateway/errors#memory_scope_per_user"
}
}{
"error": {
"message": "Your Atlaso API key is missing, invalid or revoked. Set Authorization: Bearer to an active key from the API keys page.",
"type": "authentication_error",
"param": null,
"code": "invalid_api_key",
"doc_url": "https://docs.atlaso.ai/gateway/errors#invalid_api_key"
}
}{
"error": {
"message": "This key uses your own memory. Use atlaso.memory, without a user id.",
"type": "permission_error",
"param": "x-atlaso-user",
"code": "memory_scope_owner",
"doc_url": "https://docs.atlaso.ai/gateway/errors#memory_scope_owner"
}
}{
"error": {
"message": "This request is still being saved. Retry with the same Idempotency-Key.",
"type": "invalid_request_error",
"param": null,
"code": "idempotency_in_progress",
"doc_url": "https://docs.atlaso.ai/gateway/errors#idempotency_in_progress"
}
}{
"error": {
"message": "The body must be at most 65536 bytes.",
"type": "invalid_request_error",
"param": null,
"code": "request_too_large",
"doc_url": "https://docs.atlaso.ai/gateway/errors#request_too_large"
}
}{
"error": {
"message": "Too many requests. Try again shortly.",
"type": "rate_limit_error",
"param": null,
"code": "rate_limited",
"doc_url": "https://docs.atlaso.ai/gateway/errors#rate_limited"
}
}{
"error": {
"message": "A deletion for this user has not finished yet. Retry the same request in a few seconds; retrying is safe.",
"type": "api_error",
"param": null,
"code": "delete_pending",
"doc_url": "https://docs.atlaso.ai/gateway/errors#delete_pending"
}
}