Memory OS

Memories API

The Memories API provides full CRUD operations for managing memories. Memories are the core data units in Memory OS, representing pieces of information that can be stored, retrieved, and searched.

Memory Object

A memory object contains the following fields:

FieldTypeDescription
idstring (UUID)Unique identifier for the memory
contentstringThe actual memory content
content_typestringType of content: text, conversation, document, event, fact
tierstringMemory tier: short, medium, long
memory_naturestringNature of memory: episodic (events) or semantic (facts)
relevance_scorenumberCurrent relevance score (0-1)
importance_scorenumberImportance score (0-1)
confidence_scorenumberEmbedding confidence (0-1)
decay_ratenumberRate at which relevance decays
access_countnumberNumber of times accessed
last_accessed_atstring (ISO 8601)Last access timestamp
parent_memory_idstring (UUID)Optional parent memory reference
external_idstringYour external reference ID
source_idstringSource system identifier
metadataobjectCustom key-value metadata
pii_detectedbooleanWhether PII was detected
pii_fieldsstring[]Types of PII detected
integrity_hashstringContent integrity hash
created_atstring (ISO 8601)Creation timestamp
updated_atstring (ISO 8601)Last update timestamp
expires_atstring (ISO 8601)Optional expiration timestamp

Create Memory

HTTP
POST /v1/memories

Creates a new memory with automatic embedding generation and PII detection.

Required Scope: memories:write

Request Body

ParameterTypeRequiredDefaultDescription
contentstringYes-The memory content (min 1 character)
content_typestringNotextOne of: text, conversation, document, event, fact
tierstringNoshortOne of: short, medium, long
memory_naturestringNo-One of: episodic, semantic
parent_memory_idstringNo-UUID of parent memory for hierarchy
metadataobjectNo{}Custom key-value pairs
external_idstringNo-Your unique external reference
source_idstringNo-Source system identifier

Response

Returns the created memory object (without embedding).

cURL Example

Bash
curl -X POST "https://api.mymemoryos.com/api/v1/memories" \
  -H "Authorization: Bearer mos_live_<your_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User prefers dark mode interfaces and minimal UI designs",
    "content_type": "fact",
    "tier": "long",
    "memory_nature": "semantic",
    "metadata": {
      "category": "preferences",
      "source": "user_settings"
    }
  }'

JavaScript Example

JavaScript
const response = await fetch('https://api.mymemoryos.com/api/v1/memories', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer mos_live_<your_key>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    content: 'User prefers dark mode interfaces and minimal UI designs',
    content_type: 'fact',
    tier: 'long',
    memory_nature: 'semantic',
    metadata: {
      category: 'preferences',
      source: 'user_settings'
    }
  })
});

const { data } = await response.json();
console.log('Created memory:', data.id);

Python Example

Python
import requests

response = requests.post(
    'https://api.mymemoryos.com/api/v1/memories',
    headers={
        'Authorization': 'Bearer mos_live_<your_key>',
        'Content-Type': 'application/json'
    },
    json={
        'content': 'User prefers dark mode interfaces and minimal UI designs',
        'content_type': 'fact',
        'tier': 'long',
        'memory_nature': 'semantic',
        'metadata': {
            'category': 'preferences',
            'source': 'user_settings'
        }
    }
)

data = response.json()['data']
print(f"Created memory: {data['id']}")

Response Example

JSON
{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "tenant_id": "tenant_123",
    "content": "User prefers dark mode interfaces and minimal UI designs",
    "content_type": "fact",
    "tier": "long",
    "memory_nature": "semantic",
    "relevance_score": 0.5,
    "importance_score": 0.5,
    "confidence_score": 1.0,
    "decay_rate": 0.01,
    "access_count": 0,
    "last_accessed_at": null,
    "parent_memory_id": null,
    "metadata": {
      "category": "preferences",
      "source": "user_settings"
    },
    "pii_detected": false,
    "pii_fields": [],
    "integrity_hash": "a1b2c3d4e5f6...",
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-15T10:30:00.000Z",
    "expires_at": null
  },
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 150
  }
}

List Memories

HTTP
GET /v1/memories

Retrieves a paginated list of memories.

Required Scope: memories:read

Query Parameters

ParameterTypeRequiredDefaultDescription
limitintegerNo50Number of results (max 100)
offsetintegerNo0Pagination offset
tierstringNo-Filter by tier: short, medium, long
content_typestringNo-Filter by type: text, conversation, document, event, fact
memory_naturestringNo-Filter by nature: episodic, semantic
min_relevancenumberNo0Minimum relevance score (0-1)

Response

Returns a paginated list of memory objects.

cURL Example

Bash
curl -X GET "https://api.mymemoryos.com/api/v1/memories?tier=long&limit=20" \
  -H "Authorization: Bearer mos_live_<your_key>"

JavaScript Example

JavaScript
const params = new URLSearchParams({
  tier: 'long',
  limit: '20',
  min_relevance: '0.5'
});

const response = await fetch(`https://api.mymemoryos.com/api/v1/memories?${params}`, {
  headers: {
    'Authorization': 'Bearer mos_live_<your_key>'
  }
});

const { data, meta } = await response.json();
console.log(`Retrieved ${data.length} of ${meta.total} memories`);

Python Example

Python
import requests

response = requests.get(
    'https://api.mymemoryos.com/api/v1/memories',
    headers={'Authorization': 'Bearer mos_live_<your_key>'},
    params={
        'tier': 'long',
        'limit': 20,
        'min_relevance': 0.5
    }
)

result = response.json()
print(f"Retrieved {len(result['data'])} of {result['meta']['total']} memories")

Response Example

JSON
{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "content": "User prefers dark mode interfaces",
      "content_type": "fact",
      "tier": "long",
      "memory_nature": "semantic",
      "relevance_score": 0.85,
      "importance_score": 0.7,
      "confidence_score": 1.0,
      "metadata": {},
      "created_at": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-15T10:30:00.000Z"
    }
  ],
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 45,
    "total": 150,
    "limit": 20,
    "offset": 0,
    "has_more": true
  }
}

Get Memory

HTTP
GET /v1/memories/:id

Retrieves a single memory by ID. Automatically increments access_count and updates last_accessed_at.

Required Scope: memories:read

Path Parameters

ParameterTypeDescription
idstring (UUID)The memory ID

Response

Returns the full memory object.

cURL Example

Bash
curl -X GET "https://api.mymemoryos.com/api/v1/memories/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer mos_live_<your_key>"

JavaScript Example

JavaScript
const memoryId = '550e8400-e29b-41d4-a716-446655440000';

const response = await fetch(`https://api.mymemoryos.com/api/v1/memories/${memoryId}`, {
  headers: {
    'Authorization': 'Bearer mos_live_<your_key>'
  }
});

const { data } = await response.json();
console.log('Memory content:', data.content);

Python Example

Python
import requests

memory_id = '550e8400-e29b-41d4-a716-446655440000'

response = requests.get(
    f'https://api.mymemoryos.com/api/v1/memories/{memory_id}',
    headers={'Authorization': 'Bearer mos_live_<your_key>'}
)

data = response.json()['data']
print(f"Memory content: {data['content']}")

Response Example

JSON
{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "tenant_id": "tenant_123",
    "content": "User prefers dark mode interfaces and minimal UI designs",
    "content_type": "fact",
    "tier": "long",
    "memory_nature": "semantic",
    "relevance_score": 0.85,
    "importance_score": 0.7,
    "confidence_score": 1.0,
    "decay_rate": 0.01,
    "access_count": 5,
    "last_accessed_at": "2024-01-15T14:30:00.000Z",
    "parent_memory_id": null,
    "external_id": null,
    "source_id": null,
    "metadata": {
      "category": "preferences"
    },
    "pii_detected": false,
    "pii_fields": [],
    "integrity_hash": "a1b2c3d4e5f6...",
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-15T10:30:00.000Z",
    "expires_at": null
  },
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 25
  }
}

Error Response

JSON
{
  "error": {
    "code": "NOT_FOUND",
    "message": "Memory not found"
  },
  "meta": {
    "request_id": "req_abc123"
  }
}

Update Memory

HTTP
PATCH /v1/memories/:id

Updates specific fields of an existing memory. If content is updated, the embedding is regenerated.

Required Scope: memories:write

Path Parameters

ParameterTypeDescription
idstring (UUID)The memory ID

Request Body

ParameterTypeDescription
contentstringNew content (triggers re-embedding)
tierstringNew tier: short, medium, long
importance_scorenumberNew importance score (0-1)
memory_naturestringNew nature: episodic, semantic
metadataobjectNew metadata (replaces existing)

Response

Returns the updated memory object.

cURL Example

Bash
curl -X PATCH "https://api.mymemoryos.com/api/v1/memories/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer mos_live_<your_key>" \
  -H "Content-Type: application/json" \
  -d '{
    "tier": "long",
    "importance_score": 0.9,
    "metadata": {
      "category": "preferences",
      "verified": true
    }
  }'

JavaScript Example

JavaScript
const memoryId = '550e8400-e29b-41d4-a716-446655440000';

const response = await fetch(`https://api.mymemoryos.com/api/v1/memories/${memoryId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer mos_live_<your_key>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    tier: 'long',
    importance_score: 0.9,
    metadata: {
      category: 'preferences',
      verified: true
    }
  })
});

const { data } = await response.json();
console.log('Updated memory:', data.id);

Python Example

Python
import requests

memory_id = '550e8400-e29b-41d4-a716-446655440000'

response = requests.patch(
    f'https://api.mymemoryos.com/api/v1/memories/{memory_id}',
    headers={
        'Authorization': 'Bearer mos_live_<your_key>',
        'Content-Type': 'application/json'
    },
    json={
        'tier': 'long',
        'importance_score': 0.9,
        'metadata': {
            'category': 'preferences',
            'verified': True
        }
    }
)

data = response.json()['data']
print(f"Updated memory: {data['id']}")

Response Example

JSON
{
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "content": "User prefers dark mode interfaces and minimal UI designs",
    "content_type": "fact",
    "tier": "long",
    "memory_nature": "semantic",
    "relevance_score": 0.85,
    "importance_score": 0.9,
    "confidence_score": 1.0,
    "metadata": {
      "category": "preferences",
      "verified": true
    },
    "created_at": "2024-01-15T10:30:00.000Z",
    "updated_at": "2024-01-15T16:45:00.000Z"
  },
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 85
  }
}

Delete Memory

HTTP
DELETE /v1/memories/:id

Permanently deletes a memory.

Required Scope: memories:write

Path Parameters

ParameterTypeDescription
idstring (UUID)The memory ID

Response

Returns a deletion confirmation.

cURL Example

Bash
curl -X DELETE "https://api.mymemoryos.com/api/v1/memories/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer mos_live_<your_key>"

JavaScript Example

JavaScript
const memoryId = '550e8400-e29b-41d4-a716-446655440000';

const response = await fetch(`https://api.mymemoryos.com/api/v1/memories/${memoryId}`, {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer mos_live_<your_key>'
  }
});

const { data } = await response.json();
console.log('Memory deleted:', data.deleted);

Python Example

Python
import requests

memory_id = '550e8400-e29b-41d4-a716-446655440000'

response = requests.delete(
    f'https://api.mymemoryos.com/api/v1/memories/{memory_id}',
    headers={'Authorization': 'Bearer mos_live_<your_key>'}
)

data = response.json()['data']
print(f"Memory deleted: {data['deleted']}")

Response Example

JSON
{
  "data": {
    "deleted": true
  },
  "meta": {
    "request_id": "req_abc123",
    "latency_ms": 35
  }
}

Memory Tiers

Memory OS uses a three-tier system to organize memories by retention:

TierDurationUse Case
shortHours to daysSession context, temporary preferences
mediumDays to weeksProject details, recurring patterns
longWeeks to permanentCore facts, long-term preferences

Tier Selection Guidelines

  • Short-term: Conversation context, temporary states, session data
  • Medium-term: Project information, recent events, evolving preferences
  • Long-term: User identity, permanent preferences, critical facts

Content Types

TypeDescriptionExample
textGeneric text contentNotes, descriptions
conversationDialogue or chat contentChat history, meeting transcripts
documentStructured document contentArticles, reports
eventTime-based occurrencesMeetings, milestones
factDiscrete factual informationPreferences, attributes

Memory Nature

NatureDescriptionExample
episodicEvent-based memories tied to time/place"Met John at the conference on Tuesday"
semanticFactual knowledge without temporal context"John works at Acme Corp"

PII Detection

Memory OS automatically scans content for personally identifiable information (PII):

PII TypeExamples
emailEmail addresses
phonePhone numbers
ssnSocial Security Numbers
credit_cardCredit card numbers
addressPhysical addresses
namePersonal names
ip_addressIP addresses
date_of_birthBirth dates

When PII is detected, the pii_detected field is set to true and pii_fields contains the detected types.

Ctrl+Shift+C to copy