Skip to content

Import conversations

This guide shows how to send a conversation between a user and an assistant with POST /v1/memories/import. Alvia reads the turns in order and forms memories from the facts in the user’s turns; the assistant’s turns give them context. Use it at the end of a chat session, or to bring past conversations into Alvia.

For endpoint schemas and status codes, use the API reference.

POST /v1/memories/import
curl https://api.alvia.ai/v1/memories/import \
-H "Authorization: Bearer $ALVIA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"occurred_at": "2026-10-02T11:15:00-07:00",
"scope": { "organization_id": "acme", "user_id": "u_4821" },
"messages": [
{
"role": "user",
"content": "We moved to the Enterprise plan yesterday."
},
{
"role": "assistant",
"content": "Got it. Where should invoices go now?"
},
{
"role": "user",
"content": "Send invoices to ap@acme.example from now on."
}
]
}'

Because occurred_at is October 2 in the user’s time zone, “yesterday” resolves to October 1, 2026.

  • Send the user and assistant turns. Import takes the conversation itself, so leave out system, developer and tool turns.
  • Keep the turns in order. Alvia reads them as one conversation.
  • Import one conversation per request. The occurred_at date anchors every relative date in the conversation, so two chats from different days need two requests.
  • Name other speakers. Alvia reads a user turn without speaker as the words of the person the memories are about, and its memories keep the first person: the example above can form “We moved to the Enterprise plan yesterday (October 1, 2026).” Set speaker to a name, such as "Dana Reyes", when someone else said it. Write other memories in that scope in the same voice, so a new fact reads like the memory it changes.
Field Required Description
messages Yes 1 to 500 turns, in order.
messages[].role Yes user or assistant.
messages[].content Yes 1 to 16,000 characters, with no run of more than 2,000 characters without a space.
messages[].speaker No Who said the turn, when it is not the person the memories are about. 1 to 128 characters, on one line, not starting with a space.
occurred_at Yes When the conversation took place. See Point-in-Time Reasoning and change over time.
scope No Who or what the memories are about. See Projects and scope.

All messages together can hold up to 320,000 characters. Very long conversations import best split into sessions: send each as its own request.

A successful import returns 202 with an empty body. The memories become readable once formation finishes, in less than a minute; see Accepted means queued for formation and Read memories.

Alvia splits a long conversation into chunks. Each chunk uses one write from your monthly allowance, and each fact formed from a chunk uses one more. See Limits and allowances.

When the write allowance runs out partway through an import, Alvia imports the chunks that fit, in order, and still returns 202; the chunks past the allowance are not imported. The response does not say which part of the conversation was left out, so you cannot resume from where it stopped. Check the remaining allowance in the dashboard before a large import, and send long histories in smaller imports that your application tracks.

  • Validation is all-or-nothing: a request with an invalid turn returns 400 and imports nothing, so a fixed request imports cleanly. Do not retry a 400 unchanged.
  • Retry only requests that failed: network errors, 5xx responses and 429 responses, after the wait in Retry-After. A 202 means Alvia accepted the import, so do not send it again. When you retry, send the same messages and occurred_at. Each accepted request uses writes. See Retries in Store memories.
Error Cause
400 validation_error A field breaks a rule. errors names it, such as messages[2].role.
400 invalid_argument
message_too_large_to_process
One message is too large to process. Shorten it.
400 invalid_argument
conversation_too_large_to_process
The conversation is too large for one request. Split it.
401 unauthorized The API key is missing or not valid.
404 not_found The project’s deletion started while the request was in progress.
409 conflict
memory_limit_reached
The account holds its plan’s stored-memory limit.
429 rate_limit_exceeded Too many requests per second.
429 rate_limit_exceeded
monthly_write_quota_reached
The monthly write allowance is used up.

See Errors for every code.

Filter sensitive information before imports

Section titled “Filter sensitive information before imports”

Set the project’s memory policy before the import, with keyword exclusions and a meaning rule for PII or health disclosures that your application must not remember. See Filter memories. A policy controls what becomes memory, not what reaches Alvia; see Memory policies. Alvia keeps the conversation’s text for the life of the project, and deleting the project erases it along with every memory; see Data retention and deletion in Security.

Use the conversation’s original occurred_at for historical imports, so its facts keep their real age. See Age and temporal decay.