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:400validation,401not signed in,403not allowed,404not found,409conflict (a duplicate, or a locked rule),413body over 256 KB,429too many attempts (withRetry-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 examplegithub.com/acme/api. GET /healthneeds no authentication and returns503when the database is down.
Authentication
Every /v1/* route except /v1/auth/* needs one of:
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 returns403 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
| Scope | Read | Write | Lock |
|---|---|---|---|
| org (rules, skills, memories) | everyone | admins | admins (rules) |
| team | members (admins: all) | members, admins | admins (rules) |
| repo (rules, skills) | everyone | everyone (rules: admins only if the instance says so) | none |
| user, user_repo, private memories | owner | owner | none |
Me and keys
| Request | Notes |
|---|---|
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/keys | Your 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/:id | Revoke |
GET /v1/stats | Counts of memories, rules, skills, users, teams you can see |
Memories
Memory = { id, content, visibility, team, repo, owner, mine, createdAt, updatedAt, score? }
| Request | Notes |
|---|---|
GET /v1/memories | Query 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/:id | Owner or admin |
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 }
| Request | Notes |
|---|---|
GET /v1/rules | Query 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/effective | Query repo, format=json|markdown. The merged rules for you; markdown is the exact text the session hook injects |
GET /v1/rules/history | Recent 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 }
| Request | Notes |
|---|---|
GET /v1/skills | Query 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/effective | Query repo. Skills that apply to you, one per name, with sha256. Sends an ETag and answers 304 on If-None-Match |
GET /v1/skills/history | Recent changes |
Session hook
GET /v1/hooks/claude/session-start?repo=<remote> returns Claude Code's hook output:
{ "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.
{ "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:
| Request | Notes |
|---|---|
GET, PATCH /v1/admin/instance | { mode, agentSharedWrites, repoRuleWriters } |
GET /v1/admin/audit | Filter by actor, action prefix, target, since; paged with before and limit |
GET, POST /v1/admin/users | List users; invite one with { email, name, admin? } (returns an invite token valid for 7 days) |
PATCH, DELETE /v1/admin/users/:id | Rename, change admin flag, delete |
POST /v1/admin/users/:id/reset-password, /disable, /enable | |
GET /v1/admin/users/:id/keys, DELETE .../keys/:keyId | Inspect and revoke someone's keys |
GET, POST /v1/admin/teams; PATCH, DELETE /v1/admin/teams/:id | Teams |
PUT, DELETE /v1/admin/teams/:id/members/:userId | Membership |
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.