Skip to main content
POST
/
user_memory
/
add_user_memory
Add User Memory
curl --request POST \
  --url https://api.usecortex.ai/user_memory/add_user_memory \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "user_memory": "I prefer detailed technical explanations and works in the Pacific timezone"
}'
{
  "success": true,
  "user_memory_added": true,
  "memory_id": "memory_1234"
}
Hit the Try it button to try this API now in our playground. It’s the best way to check the full request and response in one place, customize your parameters, and generate ready-to-use code snippets.

Sample Request

curl --request POST \
  --url 'https://api.usecortex.ai/user_memory/add_user_memory?tenant_id=tenant_1234&sub_tenant_id=sub_tenant_4567' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "user_memory": "I prefer detailed technical explanations and works in the Pacific timezone"
}'

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

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

Automatic Tenant Provisioning: If you receive an error stating “Tenant-id/sub-tenant-id combination either does not exist or is not provisioned for user memory”, this means the tenant/sub-tenant combination hasn’t been set up for user memory functionality yet. This will be automatically provisioned when you add or generate your first user memory for this combination.
Memory Persistence: User memories are stored permanently until explicitly deleted. They persist across sessions and can be retrieved using the Retrieve User Memory endpoint.
Best Practices:
  • 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

Error Responses

All endpoints return consistent error responses following the standard format. For detailed error information, see our Error Responses documentation.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

tenant_id
string
required

Unique identifier for the tenant/organization

Example:

"tenant_1234"

sub_tenant_id
string
default:""

Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.

Example:

"sub_tenant_4567"

Body

application/json

Request body containing the user memory to add

user_memory
string
required

The memory content to store for future reference

Example:

"I prefer detailed technical explanations and works in the Pacific timezone"

Response

Successful Response

Response model for adding a new user memory.

success
boolean
required

Indicates whether the memory addition operation was successful

Example:

true

user_memory_added
boolean
required

Confirms whether the memory was successfully stored in the system

Example:

true

memory_id
string | null

Unique identifier assigned to the newly created memory

Example:

"memory_1234"

I