Skip to main content
The Memories API allows you to manage memories that Khoj learns about you over time. These memories help personalize your AI interactions.

Overview

Khoj builds a memory of facts about you from your conversations and documents. You can view, update, and delete these memories through the API. Base endpoint: /api/memories Authentication: Required - All endpoints require a valid API token

List All Memories

Retrieve all memories associated with your account. Endpoint: GET /api/memories

Request

curl https://app.khoj.dev/api/memories \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

memories
array
Array of memory objects
[
  {
    "id": 123,
    "raw": "User prefers concise responses",
    "created_at": "2024-03-15T10:30:00Z"
  },
  {
    "id": 124,
    "raw": "User is a software engineer working with Python",
    "created_at": "2024-03-16T14:22:00Z"
  }
]

Update Memory

Update the content of an existing memory. Endpoint: PUT /api/memories/{memory_id}

Request

memory_id
integer
required
The ID of the memory to update
raw
string
required
The new memory text content
curl -X PUT https://app.khoj.dev/api/memories/123 \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"raw": "User prefers detailed technical explanations"}'

Response

id
integer
The updated memory ID
raw
string
The updated memory content
created_at
string
Original creation timestamp

Delete Memory

Remove a specific memory from your account. Endpoint: DELETE /api/memories/{memory_id}

Request

memory_id
integer
required
The ID of the memory to delete
curl -X DELETE https://app.khoj.dev/api/memories/123 \
  -H "Authorization: Bearer YOUR_API_TOKEN"

Response

Returns HTTP 204 (No Content) on success.

Error Responses

error
string
Error message describing what went wrong

Common Error Codes

Status CodeDescription
401Unauthorized - Invalid or missing API token
404Memory not found or doesn’t belong to your account
422Validation error - Invalid request body

Use Cases

Memory Management

Review and curate what Khoj remembers about you

Privacy Control

Delete sensitive memories you don’t want stored

Personalization

Add explicit memories to guide AI responses

Memory Export

Export your memories for backup or analysis

Best Practices

Memories help Khoj personalize responses. Add memories about your preferences, work context, and frequently needed information.
Deleting a memory is permanent. Khoj may re-learn similar facts from future conversations or documents.
Memories are automatically created from your conversations. You can also manually add them through the web interface.

Next Steps

Chat API

Use memories in conversations

User Settings

Manage other user preferences

Build docs developers (and LLMs) love