Memokit
API Reference

Memories API

Create, search, and manage memories

Memories API

The Memories API allows you to store, search, and manage semantic memories.

Create Memory

Create a new memory with automatic vector embedding.

POST /v1/memories

Request Body

FieldTypeRequiredDescription
contentstringYesThe memory content (max 10,000 characters)
userIdstringYesUser identifier for the memory
agentIdstringNoAgent identifier
tagsstring[]NoArray of tags for categorization
metadataobjectNoCustom metadata object

Example Request

curl -X POST https://api.memokit.dev/v1/memories \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "The user mentioned they prefer Python for data science work",
    "userId": "user_123",
    "agentId": "agent_456",
    "tags": ["preference", "programming"],
    "metadata": {
      "source": "chat",
      "sessionId": "sess_789"
    }
  }'

Response

{
  "id": "mem_abc123def456",
  "content": "The user mentioned they prefer Python for data science work",
  "userId": "user_123",
  "agentId": "agent_456",
  "tags": ["preference", "programming"],
  "metadata": {
    "source": "chat",
    "sessionId": "sess_789"
  },
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Search Memories

Search for relevant memories using semantic similarity.

POST /v1/memories/search

Request Body

FieldTypeRequiredDescription
querystringYesNatural language search query
userIdstringNoFilter by user ID
agentIdstringNoFilter by agent ID
tagsstring[]NoFilter by tags (AND logic)
limitnumberNoMax results (default: 10, max: 100)
thresholdnumberNoMinimum similarity score (0-1, default: 0.5)

Example Request

curl -X POST https://api.memokit.dev/v1/memories/search \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What programming languages does the user prefer?",
    "userId": "user_123",
    "limit": 5,
    "threshold": 0.6
  }'

Response

{
  "results": [
    {
      "id": "mem_abc123def456",
      "content": "The user mentioned they prefer Python for data science work",
      "score": 0.87,
      "userId": "user_123",
      "agentId": "agent_456",
      "tags": ["preference", "programming"],
      "createdAt": "2024-01-15T10:30:00Z"
    },
    {
      "id": "mem_xyz789",
      "content": "User said they use JavaScript for web development",
      "score": 0.74,
      "userId": "user_123",
      "tags": ["programming"],
      "createdAt": "2024-01-14T15:20:00Z"
    }
  ]
}

The score field indicates semantic similarity (0-1, higher is more relevant).


List Memories

Retrieve a paginated list of memories.

GET /v1/memories

Query Parameters

ParameterTypeRequiredDescription
userIdstringNoFilter by user ID
agentIdstringNoFilter by agent ID
tagsstringNoComma-separated tags to filter
pagenumberNoPage number (default: 1)
limitnumberNoItems per page (default: 20, max: 100)

Example Request

curl -X GET "https://api.memokit.dev/v1/memories?userId=user_123&limit=10" \
  -H "Authorization: Bearer mk_your_api_key"

Response

{
  "items": [
    {
      "id": "mem_abc123def456",
      "content": "The user mentioned they prefer Python for data science work",
      "userId": "user_123",
      "agentId": "agent_456",
      "tags": ["preference", "programming"],
      "createdAt": "2024-01-15T10:30:00Z",
      "updatedAt": "2024-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 45,
    "totalPages": 5
  }
}

Get Memory

Retrieve a specific memory by ID.

GET /v1/memories/:id

Path Parameters

ParameterTypeDescription
idstringMemory ID

Example Request

curl -X GET https://api.memokit.dev/v1/memories/mem_abc123def456 \
  -H "Authorization: Bearer mk_your_api_key"

Response

{
  "id": "mem_abc123def456",
  "content": "The user mentioned they prefer Python for data science work",
  "userId": "user_123",
  "agentId": "agent_456",
  "tags": ["preference", "programming"],
  "metadata": {
    "source": "chat",
    "sessionId": "sess_789"
  },
  "createdAt": "2024-01-15T10:30:00Z",
  "updatedAt": "2024-01-15T10:30:00Z"
}

Delete Memory

Delete a memory permanently.

DELETE /v1/memories/:id

Path Parameters

ParameterTypeDescription
idstringMemory ID

Example Request

curl -X DELETE https://api.memokit.dev/v1/memories/mem_abc123def456 \
  -H "Authorization: Bearer mk_your_api_key"

Response

{
  "success": true,
  "id": "mem_abc123def456"
}

Error Codes

CodeDescription
MEMORY_NOT_FOUNDThe specified memory does not exist
CONTENT_TOO_LONGContent exceeds 10,000 characters
INVALID_USER_IDUser ID is required
QUOTA_EXCEEDEDMonthly quota has been exceeded

On this page