Home/Documentation

REST API / n8n

External Integration

Integrate MemoAir with any platform using our REST API. Perfect for n8n workflows, custom chatbots, and any application that can make HTTP requests.

Base URL

1https://backend.memoair.space

Authentication

All requests require authentication via HTTP headers:

HeaderRequiredDescription
X-API-KeyRequiredYour project API key from the dashboard
X-User-IdRequiredThe end-user ID for memory isolation
X-Agent-NameOptionalAgent name for dashboard visibility (e.g., "my-n8n-chatbot")
Content-TypeRequiredMust be application/json

Tip: Use X-Agent-Name to see your integration's activity in the Agents dashboard.

POSTSearch Memories
HTTP:POST /v1/ext/memory/search

Search your memory bank for relevant information.

Parameters

querystringRequired

The search query to find relevant memories.

limitnumberOptionalDefault: 10

Maximum number of results to return.

Example Request

search.shbash
1curl -X POST "https://backend.memoair.space/v1/ext/memory/search" \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: your-api-key" \
4 -H "X-User-Id: user-123" \
5 -H "X-Agent-Name: my-n8n-chatbot" \
6 -d '{
7 "query": "What are the user preferences?",
8 "limit": 5
9 }'

Example Response

1{
2 "success": true,
3 "results": [
4 {
5 "content": "User prefers TypeScript over JavaScript",
6 "score": 0.92,
7 "category": "preference",
8 "source": "mcp-agent"
9 },
10 {
11 "content": "User works on React projects",
12 "score": 0.85,
13 "category": "fact",
14 "source": "n8n-chatbot"
15 }
16 ]
17}
POSTSave Memory
HTTP:POST /v1/ext/memory/save

Save new information to the user's memory.

Parameters

contentstringRequired

The content to save to memory.

sourceIdstringOptional

Unique identifier for this conversation/session. Used to consolidate multiple messages.

sourceTitlestringOptional

Display name for this memory source (e.g., "my-n8n-chatbot").

Example Request

save.shbash
1curl -X POST "https://backend.memoair.space/v1/ext/memory/save" \
2 -H "Content-Type: application/json" \
3 -H "X-API-Key: your-api-key" \
4 -H "X-User-Id: user-123" \
5 -H "X-Agent-Name: my-n8n-chatbot" \
6 -d '{
7 "content": "User: Hello!\nAssistant: Hi there! How can I help?",
8 "sourceId": "conversation-abc123",
9 "sourceTitle": "my-n8n-chatbot"
10 }'

Example Response

1{
2 "success": true,
3 "itemId": "f13eb412-5b80-4f94-ba54-d370ee034fee"
4}

Note: Using the same sourceId will append content to the existing memory item, consolidating the conversation.

n8n Integration Guide

Build a memory-enabled chatbot in n8n using MemoAir:

Recommended Flow

Chat Trigger
Search Memory
AI Agent
Save Memory
1. Search Memory Node

Before your AI agent processes the user input, search for relevant context:

  • Method: POST
  • URL: /v1/ext/memory/search
  • Body: User's message as the query
2. Save Memory Node

After the AI responds, save the conversation exchange:

  • Method: POST
  • URL: /v1/ext/memory/save
  • Body: Format as "User: ... Assistant: ..."

n8n HTTP Request Configuration

In each HTTP Request node, configure:

n8n-config.txttext
1Method: POST
2URL: https://backend.memoair.space/v1/ext/memory/search
3
4Headers (Using Fields):
5 - X-API-Key: {{ $credentials.memoairApiKey }}
6 - X-User-Id: {{ $json.userId || "default-user" }}
7 - X-Agent-Name: my-n8n-chatbot
8 - Content-Type: application/json
9
10Body (Using Fields):
11 - query: {{ $json.chatInput }}
12 - limit: 5

Important: In n8n, use "Specify Body" → "Using Fields Below" instead of raw JSON to avoid escaping issues with special characters in the content.

How It Works

1. Working Memory (Hippocampus)

Saved memories first go to "Working Memory" - a temporary staging area where they're processed and extracted.

2. Memory Extraction

MemoAir automatically extracts facts, preferences, actions, and Q&A from the conversation content.

3. Auto-Promotion to Cortex

Based on your project settings, extracted memories are automatically saved to the long-term memory graph (Cortex).

4. Searchable via Graph

Memories are indexed in the knowledge graph and can be searched semantically across all your agents and integrations.

Multi-User Support

Use a single API key for multiple end-users by varying the X-User-Id header:

1# User A's memories
2curl -X POST "https://backend.memoair.space/v1/ext/memory/search" \
3 -H "X-API-Key: project-key" \
4 -H "X-User-Id: user-alice" \
5 -d '{"query": "preferences"}'
6
7# User B's memories (isolated)
8curl -X POST "https://backend.memoair.space/v1/ext/memory/search" \
9 -H "X-API-Key: project-key" \
10 -H "X-User-Id: user-bob" \
11 -d '{"query": "preferences"}'

Each user ID has isolated memory storage while sharing the same project configuration.

Error Handling

StatusMeaningSolution
400Bad RequestCheck required fields (query, content)
401UnauthorizedVerify X-API-Key and X-User-Id headers
405Method Not AllowedUse POST method, not GET
500Server ErrorCheck request body is valid JSON