Add User Memory
Store new user memories for future reference.
This API allows you to add memories in two formats:
- Raw text string - A single text-based memory
- User/Assistant pairs array - Conversation pairs that will be chunked as a single memory
The stored memories will be chunked, embedded, and indexed for semantic search and retrieval.
Sample Request
Examples
- API Request
- TypeScript
- Python (Sync)
Overview
Store personal memories for a specific user to enhance personalization and provide context-aware responses in your AI applications.What are User Memories?
User memories are personal, contextual information stored for individual users that help your AI system:- Remember user preferences and past interactions
- Provide personalized responses based on user history
- Enhance user experience through adaptive behavior
Memory Types
Raw Text: Textual content that you want to save in Cortex as a memory. This can be any descriptive information about a user, such as their preferences, habits, background information, or important context that should be remembered for future interactions. User-Assistant Pairs: Conversational exchanges between a user and an AI assistant (or any similar interaction pattern). These are structured as question-response or prompt-answer pairs that capture the flow of conversations, including responses from an LLM or any similar system.Additional Parameters
Custom Instructions: Contextual information you provide about the text being indexed that Cortex needs to know. This helps guide how the memory should be interpreted, categorized, or retrieved later. For example, you might specify that certain information is particularly important, should be weighted more heavily, or relates to specific topics. Infer: When set totrue, Cortex will process and analyze the memory content to improve its indexing and retrieval capabilities. This includes extracting key concepts, understanding context, and optimizing how the memory is stored for better semantic search and recall.
Functionality
- Manual Memory Addition: Allows you to explicitly add specific memories for a user
- Vector Store Integration: Stores memories in a searchable vector database for semantic retrieval
- Tenant Isolation: Ensures memories are properly isolated by tenant and sub-tenant
- Automatic Provisioning: If the tenant/sub-tenant combination doesn’t exist for user memory, it will be automatically provisioned on first use
Use Cases
- Preference Storage: Store user preferences like preferred communication style, timezone, or language
- Context Preservation: Remember important details from previous conversations
- Personalization Data: Store information that helps tailor responses to individual users
Important Notes
- Use clear, descriptive memory content that will be useful for future AI interactions
- Consider the context in which memories will be retrieved
- Avoid storing sensitive information unless necessary
- Use consistent formatting for similar types of memories
- Choose either
raw_textoruser_assistant_pairs- do not provide both in the same request
Error Responses
All endpoints return consistent error responses following the standard format. For detailed error information, see our Error Responses documentation.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Unique identifier for the tenant/organization
"tenant_1234"
Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
"sub_tenant_4567"
Single raw text memory to store. If both raw_text and user_assistant_pairs are provided, raw_text will be used.
Array of user/assistant conversation pairs to store as a single memory
Expiry time in seconds for the memory (optional)
If true, process and compress chunks into inferred representations before indexing (default: False)
true
Custom instructions to guide cortex
User's name for personalization
"John Doe"
Optional custom memory ID (auto-generated if not provided)
"memory_1234"
Response
Successful Response
Response model for adding a new user memory.
Indicates whether the memory addition operation was successful
true
Confirms whether the memory was successfully stored in the system
true
Unique identifier assigned to the newly created memory
"memory_1234"
Source identifier from the memory service
"CortexDoc1234"
Total number of chunks created from the memory
1
Number of original (non-inferred) chunks created
1
Number of inferred chunks created
1