API reference
Read and write the memory of your users from any app: n8n, Make, Zapier, a script or your own SaaS. Base URL https://crystalbrain.ai. The same API as an OpenAPI 3.1 document: /api/v1/openapi.json.
To connect Claude or another AI assistant instead, use the MCP link https://crystalbrain.ai/api/mcp, shown with its steps on the Connections page of your dashboard.
Authentication
Create an API key on the Connections page of your dashboard and send it with every call in the header Authorization: Bearer mp_…. A key opens your whole workspace: keep it on your server, never in a browser or a mobile app.
Users, brains and apps
- user: your customer’s ID or name in your own app. Each user has its own brains; a search never crosses users. Omit it to work on your own account. A save creates an unknown user.
- brain: a topic of that user (billing, onboarding, a project). Omit it: a search reads all the user’s brains, a save lets CrystalBrain pick an existing brain or create one.
- app: the name of your app, shown in your dashboard.
TypeScript SDK
For Node apps (Node 18 or later): npm install crystalbrain. Every input and result is typed from this reference, and an error throws a CrystalBrainError with the codes listed below. Methods: search, save, listBrains, mentionSkill, logToolCalls, getUser, getBrain, listMemories, getMemory, getAnalytics, resolveContradiction, similarMemories, mergeMemories, undoMerge, updateMemory, archiveMemory, createBrain, listUsers, deleteUser, restoreUser. Package on npm.
Python SDK
For Python apps (Python 3.11 or later, no dependency): pip install crystalbrain. Every input and result is typed (TypedDicts generated from this reference), and an error raises a CrystalBrainError with the codes listed below. The same methods as the TypeScript SDK, in snake_case (search, save, list_brains, update_memory, delete_user…), with keyword arguments. Package on PyPI.
POST /api/v1/search
Search a user's memory. Returns what CrystalBrain knows about one user for this request: the closest memories, passages of the brain's documents, and a ready-to-use context block for your LLM. Reads the user's brains and the brains opened to its groups. With tags, only memories holding at least one of them. When passages of images are returned, images gives a link to each image, valid one hour. Send one topic per search: a long request that mixes a customer, a rule and an action lowers the score of a memory about only one of them (a memory that names a person, company, product or code of the request is still kept).
| Field | Type | Description |
|---|---|---|
query (required) | string | What the user is asking about, in a short sentence. One topic per search: when the request mixes several (a customer, a rule, an action), search each one separately. |
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
brain | string | A brain (topic) of this user, by name: one open in reading for this user (unknown or closed: an error). Omit it to use all the brains open in reading. |
types | (fact | preference | instruction | goal | episode | learning | decision | entity | example | procedure | term | constraint | question)[] | Only these kinds of memory |
tags | string[] | Only memories with at least one of these tags. Passages of documents are then left out (only memories carry tags). |
limit | integer | Maximum number of memories returned. Default 8. |
app | string | Name of your app, shown among the brain's readers. Default: api. |
model | string | The AI model the search is for (its model ID), shown in Usage history and Insights. |
skills | boolean | Also return the workspace skills that fit the request (at most 2, matched by meaning), with their instructions in the context block. Default false. |
as_of | string | A past date (YYYY-MM-DD, or an ISO date-time): returns what was true then. Memories replaced later (a contradiction resolved in favour of a newer one) are included and marked "true until" in the context block. Omit for what is true now. |
POST /api/v1/save
Save a memory. Stores something durable about one user. CrystalBrain structures the input, may split a long exchange into several memories, picks or creates the brain when you name none, and skips near-duplicates. An unknown user is created. When the brain you name is archived, the memory is saved in the user's General brain instead and the answer says so (space, message). A memory that reads like orders to an AI is saved but held for the account owner's review (held, message). At most 60 memories written by AI apps per user in 10 minutes (429 RATE_LIMITED beyond).
| Field | Type | Description |
|---|---|---|
user | string | Your customer's ID or name; created on its first save. Omit it for your own account. |
user_kind | human | agent | Whether this user is a person (human, the default) or an AI agent (agent). Used only when the call creates the user; change it later on the user's page in the dashboard. |
brain | string | A brain by name, open in writing for this user (closed: an error); created when missing, unless the user's settings forbid new brains (then an error). Omit it: the AI picks one of the brains open in writing or creates one. An archived brain is not written to: the memory goes to General. |
type (required) | fact | preference | instruction | goal | episode | learning | decision | entity | example | procedure | term | constraint | question | Kind of memory |
title (required) | string | Short title |
content (required) | string | The information itself, self-contained |
source_text | string | Optional conversation excerpt this comes from, verbatim: CrystalBrain structures it and may split it into several memories. |
fields | object | Structured details, e.g. objective, outcome, participants, period |
tags | string[] | Tags; only those allowed in the workspace (Settings › Tags, or already in use) are kept. |
source_ref | string | Your own reference for this memory, e.g. a message ID |
app | string | Name of your app, stored on the memory. |
model | string | The AI model that wrote it (its model ID), stored on the memory. |
sources | string[] | Documents, files or web pages your app used for this, by name or URL. Kept on the main memory (at most 20); those CrystalBrain knows are linked on the dashboard. |
skills | string[] | Skills your app used for this, by name. Kept on the main memory (at most 20). |
tool_calls | string[] | Tools your app called for this, by name. Kept on the main memory (at most 20). |
GET /api/v1/brains
List a user's brains. The user's brains, then the brains opened to its groups (read only), with their number of memories. An unknown user has none.
| Query parameter | Type | Description |
|---|---|---|
user | string | Your customer's ID or name. Omit it for your own account. |
POST /api/v1/brains
Create a brain. Creates a brain (topic) for one user, with the sentence the AI reads to pick it. When the user already has a brain with this name, that brain is returned (created: false). An unknown user is created, as on a save.
| Field | Type | Description |
|---|---|---|
user | string | Your customer's ID or name; created when unknown, as on a save. Omit it for your own account. |
user_kind | human | agent | Whether this user is a person (human, the default) or an AI agent (agent). Used only when the call creates the user; change it later on the user's page in the dashboard. |
name (required) | string | The brain's name, unique per user |
description | string | In one sentence, what the brain is about: the AI reads it to pick the brain |
GET /api/v1/users
List your users. Your end users (groups are not listed), by name, one page at a time: call again with offset = next_offset until it is null. Active users unless status says otherwise. Users scheduled for permanent deletion are left out, whatever the status.
| Query parameter | Type | Description |
|---|---|---|
q | string | Part of the name, external ID or email |
status | active | archived | all | active (default), archived, or all |
offset | integer | Rows to skip: the next_offset of the previous page. Default 0. |
limit | integer | Rows per page. Default 50, at most 100. |
GET /api/v1/user
Read a user. One user's profile, counts, latest AI activity and own brains (archived ones included), plus access: its setting against new brains and the brains opened to its groups with what the AI may do there. Like every GET below, this read changes no read counter and does not count the user as tracked.
| Query parameter | Type | Description |
|---|---|---|
user | string | Your customer's ID or name. Omit it for your own account. |
PATCH /api/v1/user
Set a user's brain access. no_new_brain: when true, the user's saves never create a brain; they go only into the brains open in writing for the user, and a memory none of them fits is not kept (save answers saved: false). brain_access: the user's exceptions for brains opened to its groups, each read and/or write, or inherit to go back to the groups' setting. Answers the user's setting and the brains of its groups with what applies.
| Field | Type | Description |
|---|---|---|
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
no_new_brain | boolean | True: the user's saves never create a brain; they go into the brains open in writing, and a memory none of them fits is not kept |
brain_access | (object | object)[] | The user's exceptions to its groups' settings, brain by brain |
GET /api/v1/groups
List the groups of users. The workspace's groups of users, with their members and the brains opened to them (read: their members' searches read it; write: their saves may go into it). A user in several groups gets everything its groups allow.
POST /api/v1/groups
Create a group of users. Creates a group, or returns the existing one of this name or external ID (created: false). A group owns no brain and is not counted as a user: open brains to it with PATCH /api/v1/brain (groups), add members with PATCH /api/v1/group.
| Field | Type | Description |
|---|---|---|
name (required) | string | The group's name |
external_id | string | Its ID in your app |
PATCH /api/v1/group
Change a group's name or members. Renames a group and adds or removes members. A member to add that CrystalBrain does not know yet is created (not counted as a tracked user until the AI reads or writes for it); a member to remove that is not in the group is ignored. Groups and archived users cannot be members.
| Field | Type | Description |
|---|---|---|
group (required) | string | A group of users, by ID, external ID or name |
name | string | New name |
add_members | string[] | Users to add, by ID or name; a user CrystalBrain does not know yet is created |
remove_members | string[] | Users to remove; one that is not a member is ignored |
DELETE /api/v1/user
Delete a user permanently. For a deletion request under the GDPR. Access is closed at once: the API and the MCP refuse the user (USER_DELETION_PENDING), and the brains it opened to groups are no longer read. Seven days later, all its data (brains, memories and their previous versions, files, web pages, search history, tool calls, skill mentions) is permanently deleted; until then POST /api/v1/user/restore cancels it. Answers 202. Not available to AI assistants through the MCP. After the deletion, a save naming the same user creates a new, empty user.
| Query parameter | Type | Description |
|---|---|---|
user (required) | string | Your customer's ID or name. Required: your own account cannot be deleted. |
POST /api/v1/user/restore
Cancel a user's deletion. Cancels a deletion requested with DELETE /api/v1/user, before it happens. Nothing was deleted; the user is accepted again (an archived user stays archived).
| Field | Type | Description |
|---|---|---|
user (required) | string | Your customer's ID or name, as given to DELETE /api/v1/user |
GET /api/v1/brain
Read a brain. One brain of a user with its framing, summary, files, web pages, saved prompts and latest memory checks, plus access: what the AI may do there for its owner and for the groups it is opened to. Its memories: GET /api/v1/memories with brain.
| Query parameter | Type | Description |
|---|---|---|
brain (required) | string | A brain of this user, by name or ID. By ID, user is not needed. |
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
PATCH /api/v1/brain
Set what the AI may do in a brain. ai_read / ai_write: whether searches for the brain's owner read it, and whether the owner's saves and AI edits may write into it. groups: the groups the brain is opened to, each with read and/or write for their members (the list replaces the current one; [] makes it private again). A brain opened in writing to a group receives its members' saves: every member who reads it sees them, and each memory keeps which user it came from. A search, save or edit on a brain not open for that mode is refused (BRAIN_CLOSED).
| Field | Type | Description |
|---|---|---|
brain (required) | string | A brain of this user, by name or ID. By ID, user is not needed. |
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
ai_read | boolean | Searches for the brain's owner read it (default true) |
ai_write | boolean | The owner's saves and AI edits may write into it (default true) |
groups | object[] | The groups this brain is opened to, with what their members' AI may do there. Replaces the current list: [] makes the brain private again; a group with read and write false is left out. Written memories keep which member they came from |
GET /api/v1/memories
List a user's memories. Full memories of one user's own brains, newest first, one page at a time: call again with offset = next_offset until it is null. Active memories unless status says otherwise. An unknown user has none.
| Query parameter | Type | Description |
|---|---|---|
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
brain | string | Only this brain, by name or ID. Omit it for all the user's brains. |
type | fact | preference | instruction | goal | episode | learning | decision | entity | example | procedure | term | constraint | question | Only this kind of memory |
tag | string | Only memories with this tag |
status | active | archived | all | active (default), archived, or all |
from | string | Created on or after this day (UTC day, YYYY-MM-DD, included) |
to | string | Created on or before this day (UTC day, YYYY-MM-DD, included) |
offset | integer | Rows to skip: the next_offset of the previous page. Default 0. |
limit | integer | Rows per page. Default 50, at most 100. |
GET /api/v1/memory
Read a memory. One memory by ID, with the input it was structured from, the memories merged into it and its contradictions.
| Query parameter | Type | Description |
|---|---|---|
id (required) | string | The memory's ID |
GET /api/v1/analytics
Read a user's analytics. Raw rows of one user over a period (default: the last 30 days), one kind at a time and one page at a time: activity (AI reads and writes per day), searches, tool_calls, skills, checks, contradictions, merges. An unknown user has none.
| Query parameter | Type | Description |
|---|---|---|
kind (required) | activity | searches | tool_calls | skills | checks | contradictions | merges | activity (AI reads and writes per day), searches (query, app, model, brain, memories returned), tool_calls, skills (mentions), checks (memory check runs), contradictions, merges |
user | string | Your customer's ID or name. Omit it for your own account. Searches never cross users. |
from | string | First day. Default: 29 days before to (UTC day, YYYY-MM-DD, included) |
to | string | Last day. Default: today (UTC day, YYYY-MM-DD, included) |
offset | integer | Rows to skip: the next_offset of the previous page. Default 0. |
limit | integer | Rows per page. Default 50, at most 100. |
POST /api/v1/contradictions/resolve
Resolve a contradiction. Same as Keep A, Keep B or Keep both in the Review queue: keep one memory (the other is archived, and other open contradictions on it are closed), or keep both (the contradiction is dismissed).
| Field | Type | Description |
|---|---|---|
id (required) | string | The contradiction's ID (analytics kind contradictions, or the contradictions of GET /api/v1/memory) |
keep (required) | string | "both" to keep the two memories (the contradiction is dismissed), or the ID of the memory to keep (the other one is archived) |
GET /api/v1/memory/similar
Find similar memories. The active memories of the same brain closest to one memory, with their similarity score: candidates for a merge.
| Query parameter | Type | Description |
|---|---|---|
id (required) | string | The memory's ID |
limit | integer | How many similar memories. Default 10, at most 20. |
POST /api/v1/memories/merge
Merge memories. Replaces 2 to 10 active memories of one brain by one memory whose title and content you wrote. The originals are archived and the merge shows in the Review queue, where it can be undone. Open contradictions between two of the merged memories are resolved.
| Field | Type | Description |
|---|---|---|
ids (required) | string[] | The memories to merge, 2 to 10, all active and in the same brain. The first one gives the type, the brain and, on a clash, the fields. |
title (required) | string | Title of the merged memory |
content (required) | string | Content of the merged memory, written by you: everything the merged memories say, nothing lost |
type | fact | preference | instruction | goal | episode | learning | decision | entity | example | procedure | term | constraint | question | Kind of the merged memory. Default: the first memory's |
app | string | Name of your app, stored on the merged memory. Default: api. |
POST /api/v1/memories/unmerge
Undo a merge. Undoes a merge, automatic or not: its memories come back (the memory checks never merge them again) and the merged memory is archived.
| Field | Type | Description |
|---|---|---|
id (required) | string | ID of the merged memory (source merge) |
PATCH /api/v1/memory
Change a memory. Changes what you name on one memory of the user (title, content, type, tags, fields); the rest stays. You write the final text: no AI rewrite. Send append instead of content to add a dated follow-up at the end. The previous version is kept and can be restored from the Edit memory screen. Only the user's own memories: brains shared through a group are read-only.
| Field | Type | Description |
|---|---|---|
id (required) | string | The memory's ID (from search, GET /api/v1/memories or GET /api/v1/memory) |
user | string | Your customer's ID or name: the memory must be one of this user's own (not of a brain shared through a group). Omit it for your own account. |
title | string | New title |
content | string | New content, written by you in full: it replaces the current one (no AI rewrite) |
append | string | Text to add at the end of the current content, stamped with today's date (UTC), instead of replacing it: a follow-up, progress or a later outcome. Not with content. |
type | fact | preference | instruction | goal | episode | learning | decision | entity | example | procedure | term | constraint | question | New kind of memory |
tags | string[] | The new list of tags; only those allowed in the workspace (Settings › Tags, or already in use) are kept. |
fields | object | Fields to change: each key replaces the current value, null removes it; the other fields stay. |
app | string | Name of your app, kept with the previous version. Default: api. |
POST /api/v1/memory/archive
Archive a memory. Archives one memory of the user, for instance when they ask you to forget it: searches no longer return it. Reversible: you restore it from its brain in the dashboard. Only the user's own memories.
| Field | Type | Description |
|---|---|---|
id (required) | string | The memory's ID |
user | string | Your customer's ID or name: the memory must be one of this user's own (not of a brain shared through a group). Omit it for your own account. |
POST /api/v1/skills
Report the use of a skill. Your app used a skill (reusable instructions). CrystalBrain looks for the user's own skill of that name, then a skill shared by the workspace, counts the use and returns the skill's instructions when it has them; an unknown skill is recorded by name, for that user.
| Field | Type | Description |
|---|---|---|
name (required) | string | The skill's name |
user | string | Your customer's ID or name, when known. Never created here. Their own skill of that name comes before a shared one; an unknown skill is stored for them. |
brain | string | The brain the work is about, if any |
app | string | Name of your app, stored with the mention. Default: api. |
POST /api/v1/documents
Add a document. Adds text your app has already extracted (from a PDF, a web page, its own content) as a document of one user's brain, like a file added on the dashboard: cut into passages and indexed, so searches return the passages that fit. Or adds an image (image + media_type): Claude describes it and transcribes its text, and searches return that description with a link to the image. The user is created when unknown; the brain is created when missing, General when omitted.
| Field | Type | Description |
|---|---|---|
title (required) | string | The document's title, shown on the dashboard and in the passages the search returns |
text | string | The document's text, already extracted by your app (4 MB at most). CrystalBrain cuts it into passages and indexes them. Send text or image, not both. |
image | string | An image (screenshot, photo, diagram), in base64 without a data: prefix. The whole request must stay under 4.5 MB, so about 3 MB of image. Claude describes it and transcribes its text; searches return that description, and a link to the image. Uses the monthly AI credit. |
media_type | image/png | image/jpeg | image/webp | image/gif | The image's type. Required with image. |
user | string | Your customer's ID or name; created on its first write. Omit it for your own account. |
user_kind | human | agent | Whether this user is a person (human, the default) or an AI agent (agent). Used only when the call creates the user; change it later on the user's page in the dashboard. |
brain | string | A brain by name, created when missing. Omit it: General. An archived brain is not written to: General is used. |
GET /api/v1/skills
List the skills. The active skills that have instructions, by name, with their description: the user's own skills and the skills shared by the whole workspace (shared: true). Fetch a skill's instructions by reporting its use (POST /api/v1/skills). The Chrome extension lists them so that /name in a message adds that skill.
| Query parameter | Type | Description |
|---|---|---|
user | string | Your customer's ID or name: their own skills and the shared ones. Omit it for your own account. |
POST /api/v1/skills/import
Import skills from a zip. Sends a zip of skills as multipart/form-data, in the format of Claude skills: each skill is a SKILL.md file whose front matter gives its name and description, the rest of the file being its instructions. A zip can hold several skills, one per SKILL.md (at most 50); the other files of the zip are not kept. A skill whose name the owner already has is updated (description and instructions replaced, active again, mentions kept); the others are created. Answers 400 INVALID_BODY when the file is not a zip or no SKILL.md could be read.
| Field | Type | Description |
|---|---|---|
file (required) | string | The zip: one or more skills, each in a SKILL.md file (the format of Claude skills), at most 4 MB |
user | string | Your customer's ID or name: the skills become theirs. Never created here. Omit it: the skills are shared by the whole workspace. |
POST /api/v1/tool-calls
Report tool calls. Your app reports the tools its LLM called (one call, or up to 100 in calls), with the model and the MCP server. Shown on the Tool calls page.
| Field | Type | Description |
|---|---|---|
tool | string | The tool's name |
model | string | The LLM model that called it |
mcp_server | string | The MCP server the tool belongs to, if any |
status | ok | error | Whether the call succeeded |
duration_ms | integer | Duration of the call in milliseconds |
called_at | string | ISO date of the call; default: now |
calls | object[] | Up to 100 calls at once, instead of the single call fields |
user | string | Your customer's ID or name. Never created here. |
brain | string | The brain the work is about, if any |
app | string | Name of your app. Default: api. |
GET /api/v1/extension/status
Chrome extension status. Used by the CrystalBrain Chrome extension: whether Claude already reaches this workspace through the MCP connector (a search by Claude through the MCP in the last 30 days). The connector belongs to the claude.ai account, so it works on every computer; the extension then stays off on claude.ai.
Webhooks
Add an endpoint on Connections › Webhooks in your dashboard and pick its events. CrystalBrain then sends a POST with a JSON body to that HTTPS URL each time one happens. A 2xx answer within 5 seconds is a success; otherwise it tries twice more, 3 and 15 seconds later. Every delivery is listed for 30 days in the dashboard, where you can resend it.
| Event | When |
|---|---|
memory.created | Saved or merged by the AI or the API, or added in the dashboard (not imports, nor merges made by memory checks or in the Review queue). |
memory.updated | Its text, type, tags or “Stop using after” date changed, or it moved to another brain: the AI or the API corrected it, it was edited or a previous version restored. |
memory.archived | By the AI or the API (the memories they merge included), in the dashboard or by resolving a contradiction (not by memory checks, merges in the Review queue or an undone merge). |
contradiction.detected | A memory check found memories that contradict each other. |
user.deleted | A permanent deletion was carried out, 7 days after the request. |
quota.reached | A new user went over the plan's monthly tracked users quota (once a month). The payload says whether that user was still served: a paid plan serves new users up to 150% of its quota. |
quota.blocked | A new user got no memory because the limit of tracked users is reached: the quota on Free, 150% of it on a paid plan (once a month). |
credit.used_up | The workspace's monthly AI credit is used up: new memories are saved as sent and memory checks pause until the 1st (once a month). |
write.failed | A save failed with a server error, or stored nothing because the limit of tracked users is reached; the payload's reason says which (once a day per reason). |
The body is { id, event, created_at, data }. Memory events list the memories in data.memories (ID, type, title, brain, user), never their content: read it with GET /api/v1/memory. Headers: CrystalBrain-Event, CrystalBrain-Delivery (the same id on a retry: use it to ignore duplicates) and CrystalBrain-Signature. Check the signature before trusting the body: it is t=timestamp,v1=hex, where hex is the HMAC SHA-256 of the timestamp, a dot and the raw body, keyed with the endpoint’s secret (shown once when you add it).
Errors
Every error answers {"error": "…", "code": "…"}. The code is stable: test it in your app. The message is for people and can change.
| Status | Code | Meaning |
|---|---|---|
| 400 | INVALID_JSON | The body is not JSON. |
| 400 | INVALID_BODY | A field is missing or invalid; details lists them. |
| 400 | INVALID_QUERY | A query parameter is missing or invalid; details lists them. |
| 401 | INVALID_API_KEY | The API key is missing, unknown or revoked. |
| 402 | MTU_QUOTA_REACHED | A new end user would exceed the limit of tracked users (your plan's quota on Free, 150% of it on a paid plan) on an endpoint other than search and save: brains, documents, corrections, archive. Nothing was stored. Search and save answer 200 without memory instead, with the response header x-crystalbrain-quota: exceeded. |
| 402 | AI_CREDIT_EXHAUSTED | An image needs this month's AI credit to be read, and it is used up. Nothing was stored. |
| 403 | BRAIN_CLOSED | The brain you named is not open for this user in the mode the call needs: reading for a search, writing for a save or an edit (brain settings in the dashboard). |
| 404 | NOT_FOUND | No user, brain, memory or contradiction with this name or ID. A save to an unknown brain creates it, unless the user's settings forbid new brains. |
| 409 | INVALID_STATE | The action does not apply: contradiction already closed, memory archived or of another user, memories in different brains, not a merge, or a memory changed in the meantime. |
| 409 | USER_ARCHIVED | This user is archived in CrystalBrain. |
| 409 | NOT_A_USER | This name is a group of users, not a user. |
| 409 | NOT_A_GROUP | This name is a user, not a group of users. |
| 409 | USER_DELETION_PENDING | This user is scheduled for permanent deletion: refused until it is deleted, unless the deletion is cancelled (POST /api/v1/user/restore). |
| 429 | RATE_LIMITED | Too many requests for this key this minute. Retry after the Retry-After header's seconds; the RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset headers give the limit and its window. |
| 503 | EMBEDDING_UNAVAILABLE | The embedding service is busy. Retry in a moment. |
| 500 | INTERNAL_ERROR | Unexpected error. |
Rate limits
Requests per API key and per minute, by plan. Beyond the limit a call answers 429 with the code RATE_LIMITED and a Retry-After header giving the seconds to wait.
| Plan | Requests per minute per key |
|---|---|
| Free | 60 |
| Starter | 300 |
| Pro | 600 |