Skip to content

API reference ​

The REST API is what the dashboard and the CLI use. Everything is under /v1 on your server. This page is a condensed map; the full contract, with every field, is docs/api.md in the repository. For agents, prefer MCP.

Conventions ​

  • JSON in and out. Errors are { "error": "<message>" } with a status: 400 validation, 401 not signed in, 403 not allowed, 404 not found, 409 conflict (a duplicate, or a locked rule), 413 body over 256 KB, 429 too many attempts (with Retry-After).
  • IDs are strings. Timestamps are ISO 8601.
  • Names (teams, rule keys, skill names) match ^[a-z0-9][a-z0-9-]{0,63}$.
  • A repo is any git remote. The server normalizes it to host/path, for example github.com/acme/api.
  • GET /health needs no authentication and returns 503 when the database is down.

Authentication ​

Every /v1/* route except /v1/auth/* needs one of:

sh
curl https://memory.example.com/v1/me -H "Authorization: Bearer cb_your_key"
  • API key. Authorization: Bearer cb_..., a personal key used by the CLI, hooks and MCP clients. A read-only key can read but every write returns 403 this key is read-only.
  • Session cookie. carrybrain_session, used by the dashboard. Non-GET requests from another origin are refused.

A disabled user's key or session gets 401 account disabled. Login is rate limited per email and per IP.

Permissions ​

ScopeReadWriteLock
org (rules, skills, memories)everyoneadminsadmins (rules)
teammembers (admins: all)members, adminsadmins (rules)
repo (rules, skills)everyoneeveryone (rules: admins only if the instance says so)none
user, user_repo, private memoriesownerownernone

Me and keys ​

RequestNotes
GET /v1/me{ id, email, name, admin, teams, mode, identities, keyScope }
PATCH /v1/me{ name }
POST /v1/me/password{ current, password }; passwords are 10 to 200 characters
GET /v1/me/keysYour keys, masked: prefix and last six characters, scope, last use
POST /v1/me/keys{ name, scope?: "full" | "read", environment?, expiresInDays?: 7 | 30 | 90 | 365 | null }. The full key is returned once
DELETE /v1/me/keys/:idRevoke
GET /v1/statsCounts of memories, rules, skills, users, teams you can see

Memories ​

Memory = { id, content, visibility, team, repo, owner, mine, createdAt, updatedAt, score? }

RequestNotes
GET /v1/memoriesQuery q (semantic search, sorted by score), repo, visibility, mine=true, limit (max 100), offset, minScore. Without q, newest first
POST /v1/memories{ content, visibility = "private", teamId?, repo? }. 201 { memory, action: "created" }, or 200 { memory, action: "updated", replaced } when it merged a near-duplicate
PATCH /v1/memories/:id{ content?, visibility?, teamId?, repo? }. Owner only
DELETE /v1/memories/:idOwner or admin
sh
curl -X POST https://memory.example.com/v1/memories \
  -H "Authorization: Bearer cb_your_key" -H "Content-Type: application/json" \
  -d '{"content":"Deploys go out from the release branch","repo":"github.com/acme/api"}'

Rules ​

Rule = { id, scope, team, repo, user, key, content, locked, updatedBy, updatedAt, editable }

RequestNotes
GET /v1/rulesQuery scope, teamId, repo. Rules visible to you
PUT /v1/rules{ scope, teamId?, repo?, key, content, locked? }. Upserts by target and key. 409 if a broader locked rule owns the key
DELETE /v1/rules/:id
GET /v1/rules/effectiveQuery repo, format=json|markdown. The merged rules for you; markdown is the exact text the session hook injects
GET /v1/rules/historyRecent changes to rules you can see

team needs teamId; repo and user_repo need repo. See Rules for merging and locks.

Skills ​

Skill = { id, scope, repo, team, name, description, content, updatedBy, updatedAt, editable }

RequestNotes
GET /v1/skillsQuery scope, teamId
PUT /v1/skills{ scope, teamId?, repo?, content } where content is a full SKILL.md. Name and description come from the frontmatter
DELETE /v1/skills/:id
GET /v1/skills/effectiveQuery repo. Skills that apply to you, one per name, with sha256. Sends an ETag and answers 304 on If-None-Match
GET /v1/skills/historyRecent changes

Session hook ​

GET /v1/hooks/claude/session-start?repo=<remote> returns Claude Code's hook output:

json
{ "hookSpecificOutput": { "hookEventName": "SessionStart", "additionalContext": "<markdown>" } }

The context holds the trust statement and merged rules, up to ten recent memories, and a catalog of up to 30 skills. POST on the same path exists for tools that send the event as a body; the repo then comes from the repo query parameter or the X-Carrybrain-Repo header. Read-only keys may call both.

Import ​

POST /v1/me/import copies rules and skills into your personal scopes. The CLI's import and the dashboard both use it.

json
{ "source": "claude", "rules": { "markdown": "## Testing\nRun pnpm test." },
  "skills": [{ "name": "release-checklist", "content": "---\nname: ...\n---" }],
  "dryRun": true, "overwrite": false }

source is claude, codex, cursor, gemini or paste. Each item comes back with a status: new, same, conflict, written or skipped. With dryRun nothing is written. This route accepts bodies up to 11 MB.

Admin ​

Admins only, under /v1/admin:

RequestNotes
GET, PATCH /v1/admin/instance{ mode, agentSharedWrites, repoRuleWriters }
GET /v1/admin/auditFilter by actor, action prefix, target, since; paged with before and limit
GET, POST /v1/admin/usersList users; invite one with { email, name, admin? } (returns an invite token valid for 7 days)
PATCH, DELETE /v1/admin/users/:idRename, change admin flag, delete
POST /v1/admin/users/:id/reset-password, /disable, /enable
GET /v1/admin/users/:id/keys, DELETE .../keys/:keyIdInspect and revoke someone's keys
GET, POST /v1/admin/teams; PATCH, DELETE /v1/admin/teams/:idTeams
PUT, DELETE /v1/admin/teams/:id/members/:userIdMembership

Auth endpoints ​

No authentication needed: GET /v1/auth/status, POST /v1/auth/setup (first run), POST /v1/auth/login, POST /v1/auth/logout, POST /v1/auth/forgot-password, GET /v1/auth/invite/:token, POST /v1/auth/accept-invite, and the Google flow at /v1/auth/oidc/google/start and /v1/auth/google/callback.

MCP ​

POST /mcp is the same data as nine tools. See MCP.

Carrybrain is open source under the MIT license.