API Documentation

Build powerful integrations with the AI Memory System REST API. Store, search, and retrieve memories with semantic understanding.

Base URL: http://www.aimemory.com.br/api

📖 Overview

The AI Memory System API allows you to programmatically manage projects, memories, sessions, tasks, and code snippets. All endpoints return JSON responses and accept JSON request bodies where applicable.

🔐

Token Authentication

Secure API access with token-based authentication for all requests.

🔍

Semantic Search

Find memories by meaning, not just keywords, using vector embeddings.

🏢

Multi-Tenant

Data isolation per tenant with role-based access control.

RESTful Design

Standard REST conventions with consistent JSON responses.

🔑 Authentication

All API requests require authentication using a token. Include your token in the Authorization header of each request.

🔒 Authorization Header

Include this header in all API requests:

Authorization: Token YOUR_API_TOKEN

POST /api/auth/login/ Get authentication token
Request Body
Field Type Required Description
username string Required Your username
password string Required Your password
Request
curl -X POST http://www.aimemory.com.br/api/auth/login/ \
  -H "Content-Type: application/json" \
  -d '{
    "username": "your_username",
    "password": "your_password"
  }'
200 OK
Response
{
  "token": "abc123def456...",
  "user_id": 1,
  "username": "your_username",
  "email": "user@example.com",
  "tenant": {
    "id": "uuid-here",
    "name": "Your Tenant",
    "slug": "your-tenant",
    "plan": "premium"
  }
}

🚀 Quick Start

Get started in 3 steps

Get your API token

Login via the API or get your token from the admin panel.

Create a project

Projects organize your memories, sessions, and tasks.

Start storing memories

Store facts, decisions, learnings, and more.

Example: Create a memory
curl -X POST http://www.aimemory.com.br/api/memories/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "your-project-slug",
    "memory_type": "decision",
    "content": "We chose PostgreSQL for better JSON support",
    "importance": 8,
    "tags": ["database", "architecture"]
  }'

📁 Projects

Projects are containers for organizing memories, sessions, tasks, and code snippets. Each project has a unique slug for easy reference.

GET /api/projects/ List all projects
Query Parameters
ParameterTypeRequiredDescription
search string Optional Search by project name
200 OK
Response
[
  {
    "id": "uuid",
    "name": "My Project",
    "slug": "my-project",
    "description": "Project description",
    "stack": "Django, React, PostgreSQL",
    "is_active": true,
    "created_at": "2024-01-01T00:00:00Z",
    "updated_at": "2024-01-01T00:00:00Z"
  }
]
POST /api/projects/ Create a new project
Request Body
FieldTypeRequiredDescription
name string Required Project name
slug string Optional URL-friendly identifier (auto-generated if not provided)
description string Optional Project description
stack string Optional Technology stack
Request
curl -X POST http://www.aimemory.com.br/api/projects/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My New Project",
    "description": "A cool project",
    "stack": "Python, Django, React"
  }'
GET /api/projects/{id}/ Get project details
Path Parameters
ParameterTypeDescription
id uuid Project ID
GET /api/projects/{id}/context/ Get full project context (Markdown)

Returns a comprehensive Markdown document with project memories, sessions, tasks, and more. Perfect for pasting into AI chat conversations.

🧠 Memories

Memories are the core data type. Store facts, decisions, learnings, errors, solutions, and code notes. Each memory has an importance level (1-10) and can be tagged for organization.

Memory Types

fact - Information or factual data
decision - Decisions made during development
learning - Lessons learned
error - Errors encountered and solutions
solution - Implemented solutions
code - Code-related notes

GET /api/memories/ List memories with filters
Query Parameters
ParameterTypeRequiredDescription
project string Optional Filter by project ID or slug
memory_type string Optional Filter by type (fact, decision, learning, error, solution, code)
search string Optional Full-text search in content
importance__gte integer Optional Minimum importance level (1-10)
200 OK
Response
[
  {
    "id": "uuid",
    "project": "uuid",
    "memory_type": "decision",
    "content": "We chose PostgreSQL for better JSON support",
    "context": "Database selection meeting",
    "importance": 8,
    "tags": ["database", "architecture"],
    "access_count": 5,
    "last_accessed": "2024-01-15T10:30:00Z",
    "created_at": "2024-01-01T00:00:00Z"
  }
]
POST /api/memories/ Create a new memory
Request Body
FieldTypeRequiredDescription
project uuid/string Required Project ID or slug
memory_type string Required Type of memory
content string Required Memory content
context string Optional Additional context
importance integer Optional Importance level 1-10 (default: 5)
tags array Optional Array of tag strings
Request
curl -X POST http://www.aimemory.com.br/api/memories/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "my-project",
    "memory_type": "decision",
    "content": "We chose PostgreSQL for better JSON support",
    "context": "Database selection meeting",
    "importance": 8,
    "tags": ["database", "architecture"]
  }'
GET /api/memories/search/ Semantic search memories

Search memories using semantic understanding. Finds related memories even if they don't contain exact keywords.

Query Parameters
ParameterTypeRequiredDescription
q string Required Search query
project string Optional Filter by project
limit integer Optional Max results (default: 10)
PATCH /api/memories/{id}/ Update a memory

Update any field of an existing memory. Only include fields you want to change.

DELETE /api/memories/{id}/ Delete a memory

Soft-deletes the memory. Can be restored via admin panel.

📅 Sessions

Sessions track your work periods with AI. Record what you accomplished, blockers encountered, and next steps.

GET /api/sessions/ List sessions
Query Parameters
ParameterTypeRequiredDescription
project string Optional Filter by project
POST /api/sessions/ Create a session
Request Body
FieldTypeRequiredDescription
project uuid Required Project ID
summary string Optional Session summary
accomplished array Optional List of accomplishments
next_steps array Optional Planned next steps
blockers array Optional Blockers encountered
Request
curl -X POST http://www.aimemory.com.br/api/sessions/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "project": "project-uuid",
    "summary": "Implemented user authentication",
    "accomplished": [
      "Created login endpoint",
      "Added JWT token validation"
    ],
    "next_steps": [
      "Add refresh token mechanism",
      "Implement password reset"
    ],
    "blockers": [
      "Need Redis for token storage"
    ]
  }'

Tasks

Track tasks and to-dos for your projects. Set priorities, due dates, and manage status.

Task Status

pending - Not started
in_progress - Currently working
completed - Finished
cancelled - Not doing

GET /api/tasks/ List tasks
Query Parameters
ParameterTypeRequiredDescription
project string Optional Filter by project
status string Optional Filter by status
priority__gte integer Optional Minimum priority (1-10)
POST /api/tasks/ Create a task
Request Body
FieldTypeRequiredDescription
project uuid Required Project ID
title string Required Task title
description string Optional Task description
priority integer Optional Priority 1-10 (default: 5)
due_date datetime Optional Due date (ISO 8601)
tags array Optional Array of tags
PATCH /api/tasks/{id}/ Update task (including status)
Mark as completed
curl -X PATCH http://www.aimemory.com.br/api/tasks/TASK_UUID/ \
  -H "Authorization: Token YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"status": "completed"}'

💻 Code Snippets

Store important code fragments with metadata like file path, language, and line numbers.

GET /api/snippets/ List code snippets
Query Parameters
ParameterTypeRequiredDescription
project string Optional Filter by project
language string Optional Filter by language (python, javascript, etc.)
POST /api/snippets/ Create a code snippet
Request Body
FieldTypeRequiredDescription
project uuid Required Project ID
name string Required Snippet name
code string Required The code content
language string Optional Programming language
file_path string Optional Source file path
description string Optional Description of the snippet

📋 Context Generation

Generate comprehensive context documents for your projects. Perfect for starting new AI conversations with full project knowledge.

GET /api/projects/{id}/context/ Generate full project context

Returns a comprehensive Markdown document containing:

  • Project information and stack
  • Recent sessions and accomplishments
  • Important memories (decisions, learnings, etc.)
  • Pending and in-progress tasks
  • Code snippets (optional)
Request
curl http://www.aimemory.com.br/api/projects/PROJECT_UUID/context/ \
  -H "Authorization: Token YOUR_TOKEN"

⚠️ Error Handling

The API uses standard HTTP status codes and returns JSON error responses.

StatusMeaningDescription
200 OK Request successful
201 Created Resource created successfully
400 Bad Request Invalid request data
401 Unauthorized Missing or invalid token
403 Forbidden No permission for this resource
404 Not Found Resource not found
500 Server Error Internal server error
Error Response Example
{
  "detail": "Authentication credentials were not provided."
}

📄 Pagination

List endpoints support pagination using limit and offset parameters.

Example
GET /api/memories/?limit=20&offset=40
ParameterDefaultDescription
limit 50 Number of results per page (max 200)
offset 0 Number of results to skip

🔌 MCP Integration

AI Memory System integrates with Claude Code via the Model Context Protocol (MCP). This allows Claude to directly access and manage your memories during coding sessions.

Setup MCP Server

Download the MCP server

Get the server from /admin/mcp-setup/ or clone from the repository.

Configure Claude Code

Add the server configuration to ~/.claude/settings.json

Start using

Claude will automatically use your memories in conversations.

~/.claude/settings.json
{
  "mcpServers": {
    "ai-memory": {
      "command": "python",
      "args": ["/path/to/mcp_server/server.py"],
      "env": {
        "AIM_API_URL": "http://www.aimemory.com.br"
      }
    }
  }
}