POST
/
v1
/
memories
curl -X POST "https://api.memsync.ai/v1/memories" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "I just got promoted to Senior Software Engineer at Google! I'll be working on their ML infrastructure team."
      },
      {
        "role": "assistant", 
        "content": "Congratulations on your promotion! That's a significant achievement. Working on ML infrastructure at Google must be exciting."
      },
      {
        "role": "user",
        "content": "Thanks! I'm really excited. I'll be leading a team of 5 engineers and working on scaling their recommendation systems."
      }
    ],
    "agent_id": "career-advisor-bot",
    "thread_id": "conversation-2024-001", 
    "source": "chat",
    "metadata": {
      "timestamp": "2024-03-20T10:00:00Z",
      "platform": "web-app",
      "session_id": "session-abc123"
    }
  }'
{
  "success": true,
  "memories_created": 3,
  "processing_time": "1.8s",
  "categories_detected": ["career", "identity"],
  "memories": [
    {
      "id": "mem_789abc",
      "memory": "Recently promoted to Senior Software Engineer at Google",
      "categories": ["career"],
      "type": "episodic",
      "created_at": "2024-03-20T10:00:15Z"
    },
    {
      "id": "mem_456def", 
      "memory": "Works on ML infrastructure team at Google",
      "categories": ["career"],
      "type": "semantic",
      "created_at": "2024-03-20T10:00:15Z"
    },
    {
      "id": "mem_123ghi",
      "memory": "Leads a team of 5 engineers working on recommendation systems",
      "categories": ["career"],
      "type": "episodic", 
      "created_at": "2024-03-20T10:00:15Z"
    }
  ]
}
Store and process conversation messages to extract meaningful memories. MemSync will automatically analyze the conversation, extract facts, categorize them, and store them as searchable memories.

Authentication

X-API-Key
string
required
API key for authentication

Request Body

messages
array
required
Array of conversation messages between user and assistant
agent_id
string
required
Identifier for the agent or application storing the memories
thread_id
string
required
Unique identifier for the conversation thread
source
string
required
Source of the conversation data (e.g., “chat”, “email”, “sms”)
metadata
object
Additional metadata about the conversation

Response

success
boolean
Indicates if the memory storage was successful
memories_created
number
Number of memories extracted and stored from the conversation
processing_time
string
Time taken to process the conversation (e.g., “1.2s”)
categories_detected
array
Array of memory categories detected in the conversation
curl -X POST "https://api.memsync.ai/v1/memories" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {
        "role": "user",
        "content": "I just got promoted to Senior Software Engineer at Google! I'll be working on their ML infrastructure team."
      },
      {
        "role": "assistant", 
        "content": "Congratulations on your promotion! That's a significant achievement. Working on ML infrastructure at Google must be exciting."
      },
      {
        "role": "user",
        "content": "Thanks! I'm really excited. I'll be leading a team of 5 engineers and working on scaling their recommendation systems."
      }
    ],
    "agent_id": "career-advisor-bot",
    "thread_id": "conversation-2024-001", 
    "source": "chat",
    "metadata": {
      "timestamp": "2024-03-20T10:00:00Z",
      "platform": "web-app",
      "session_id": "session-abc123"
    }
  }'
{
  "success": true,
  "memories_created": 3,
  "processing_time": "1.8s",
  "categories_detected": ["career", "identity"],
  "memories": [
    {
      "id": "mem_789abc",
      "memory": "Recently promoted to Senior Software Engineer at Google",
      "categories": ["career"],
      "type": "episodic",
      "created_at": "2024-03-20T10:00:15Z"
    },
    {
      "id": "mem_456def", 
      "memory": "Works on ML infrastructure team at Google",
      "categories": ["career"],
      "type": "semantic",
      "created_at": "2024-03-20T10:00:15Z"
    },
    {
      "id": "mem_123ghi",
      "memory": "Leads a team of 5 engineers working on recommendation systems",
      "categories": ["career"],
      "type": "episodic", 
      "created_at": "2024-03-20T10:00:15Z"
    }
  ]
}

How Memory Extraction Works

When you store a conversation, MemSync performs several steps:
  1. Context Analysis: Analyzes the full conversation to understand context and meaning
  2. Fact Extraction: Identifies meaningful facts and information about the user
  3. Memory Classification: Categorizes memories as semantic (lasting facts) or episodic (time-bound events)
  4. Category Assignment: Assigns memories to relevant categories (career, interests, etc.)
  5. Storage: Stores memories with vector embeddings for semantic search

Best Practices

Message Quality

  • Include sufficient context in conversations for better memory extraction
  • Use natural language rather than fragmented responses
  • Include follow-up questions and clarifications when relevant

Conversation Structure

{
  "messages": [
    {
      "role": "user",
      "content": "I'm a software engineer who loves hiking and photography"
    },
    {
      "role": "assistant", 
      "content": "That's a great combination! Do you have any favorite hiking spots where you like to take photos?"
    },
    {
      "role": "user",
      "content": "Yes! I love going to Yosemite National Park. I've been there 5 times in the past 2 years."
    }
  ]
}

Metadata Usage

Include relevant metadata to enhance memory context:
{
  "metadata": {
    "timestamp": "2024-03-20T10:00:00Z",
    "platform": "mobile-app",
    "session_id": "session-xyz789",
    "conversation_type": "onboarding",
    "user_initiated": true
  }
}

Rate Limiting

This endpoint has standard rate limiting:
  • 100 requests per minute per authenticated user
  • Bulk processing may take longer for large conversations
  • Consider implementing retry logic for high-volume applications

Error Codes

Error CodeDescription
VALIDATION_ERRORInvalid request format or missing required fields
AUTHENTICATION_ERRORInvalid or missing API key
RATE_LIMIT_EXCEEDEDToo many requests in the time window
PROCESSING_ERRORError occurred during memory extraction

Next Steps

After storing memories, you can: