{"title":"Authentication & Mind Keys","slug":"authentication","category":"getting-started","summary":"How Synapse authentication works: Mind Keys for agents, JWTs for humans, ?key= for URL-only tools.","audience":["human","llm"],"tags":["auth","mind-key","jwt","security"],"difficulty":"beginner","updated":"2026-06-27","word_count":476,"read_minutes":2,"llm_context":"Two auth methods: Mind Key (token-scoped, never expires) and JWT (user-scoped, 7-day expiry).\nMind Key: Authorization: Bearer mk_xxx OR ?key=mk_xxx (60 req/min limit on query)\nJWT: Authorization: Bearer eyJ... (no rate limit, used for /register, /login, /minds, /sharing)\nMind Key is shown only once at creation. Store it permanently.\nEach mind has exactly one Mind Key. Multiple minds = multiple keys.\n","lang":"en","translated":true,"requested_lang":"en","content_markdown":"\n# Authentication & Mind Keys\n\nSynapse uses two authentication methods, each optimized for a different use case.\nUnderstanding the difference is essential for building reliable integrations.\n\n## Two Auth Methods\n\n| Method | Use Case | Rate Limit | Expiry |\n|--------|----------|------------|--------|\n| **Mind Key** | LLM agents, automated tools | None (header) / 60 min (query) | Never |\n| **JWT** | Human-facing UI, account ops | None | 7 days |\n\n## Mind Key (for Agents)\n\nA Mind Key is a tenant-scoped API token. It authenticates a single mind's data\n(memories, tasks, chat, scripts, etc.). Use it for:\n\n- LLM agents calling the API\n- Background automation scripts\n- MCP server configuration\n- Any long-lived integration\n\n### Header authentication (recommended)\n\n```bash\ncurl -H \"Authorization: Bearer mk_yourMindKeyHere\" \\\n     https://synapse.schaefer.zone/memory/recall\n```\n\n### Query parameter (for URL-only tools)\n\n```bash\ncurl https://synapse.schaefer.zone/memory/recall?key=mk_yourMindKeyHere\n```\n\n> [!WARNING]\n> The `?key=` query parameter is rate-limited to **60 requests per minute**.\n> The Bearer header has no rate limit. Use the header whenever your client\n> supports custom headers.\n\n### Creating a Mind Key\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/minds \\\n  -H \"Authorization: Bearer YOUR_JWT\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"Work Mind\", \"description\": \"Project memories\"}'\n```\n\nResponse includes `mind_key` — **save it immediately**, it's shown only once.\n\n### Listing your minds\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds\n```\n\n### Deleting a mind (irreversible!)\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds/m_xyz789\n```\n\n## JWT (for Humans)\n\nJWTs authenticate the **user account**, not a specific mind. Use them for:\n\n- Account registration and login\n- Creating / listing / deleting minds\n- Sharing minds with other users\n- Web Push subscription management\n\n### Register\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/register \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\": \"you@example.com\", \"password\": \"secret\"}'\n```\n\nReturns: `{ \"jwt\": \"eyJ...\", \"user\": {...} }`\n\n### Login\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"email\": \"you@example.com\", \"password\": \"secret\"}'\n```\n\nReturns: `{ \"jwt\": \"eyJ...\", \"user\": {...} }`\n\n### JWT expiry\n\nJWTs expire after **7 days**. When a JWT expires, simply call `/login` again to\nget a fresh one. The Mind Key never expires, so existing agent integrations\nkeep working.\n\n## Security Best Practices\n\n> [!CRITICAL]\n> - **Never commit Mind Keys to git.** Use environment variables.\n> - **Never log Mind Keys.** Mask them in logs (`mk_***...***xyz`).\n> - **Rotate keys** if you suspect a leak (delete the mind, create a new one).\n> - **Use one mind per project** to limit blast radius if a key leaks.\n\n### Environment variable pattern\n\n```bash\n# .env (NEVER commit this file)\nSYNAPSE_MIND_KEY=mk_yourMindKeyHere\nSYNAPSE_URL=https://synapse.schaefer.zone\n```\n\n```typescript\n// Node.js\nconst mindKey = process.env.SYNAPSE_MIND_KEY;\nconst url = process.env.SYNAPSE_URL;\nawait fetch(`${url}/memory/recall`, {\n  headers: { Authorization: `Bearer ${mindKey}` },\n});\n```\n\n### MCP server config\n\n```json\n{\n  \"mcpServers\": {\n    \"synapse\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"synapse-mcp-api@latest\"],\n      \"env\": {\n        \"SYNAPSE_MIND_KEY\": \"mk_yourMindKeyHere\",\n        \"SYNAPSE_URL\": \"https://synapse.schaefer.zone\"\n      }\n    }\n  }\n}\n```\n\n## Multi-Mind Pattern\n\nEach user can have multiple minds. Common patterns:\n\n| Mind Name | Purpose |\n|-----------|---------|\n| `work` | Job-related memories |\n| `personal` | Personal preferences, family |\n| `project-synapse` | Specific project context |\n| `learning-german` | Learning progress |\n| `assistant-default` | General-purpose fallback |\n\nUse different Mind Keys for different LLM sessions to keep contexts isolated.\n\n## Rate Limits\n\n| Auth Method | Limit | Scope |\n|-------------|-------|-------|\n| Mind Key (header) | None | Per-mind |\n| Mind Key (?key=) | 60/min | Per-IP |\n| JWT (header) | None | Per-user |\n| Public endpoints | None | Global |\n\nRate limit headers (`X-RateLimit-Limit`, `X-RateLimit-Remaining`, `Retry-After`)\nare included in responses when applicable.\n\n## Next Steps\n\n- [Mind Key vs JWT](/docs/getting-started/mind-key-vs-jwt) — when to use which\n- [Memory API](/docs/api/memory) — what you can do with a Mind Key\n- [User API](/docs/api/user) — account management with JWTs\n","content_html":"<h1>Authentication &amp; Mind Keys</h1>\n<p>Synapse uses two authentication methods, each optimized for a different use case.\nUnderstanding the difference is essential for building reliable integrations.</p>\n<h2>Two Auth Methods</h2>\n<table>\n<thead>\n<tr>\n<th>Method</th>\n<th>Use Case</th>\n<th>Rate Limit</th>\n<th>Expiry</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><strong>Mind Key</strong></td>\n<td>LLM agents, automated tools</td>\n<td>None (header) / 60 min (query)</td>\n<td>Never</td>\n</tr>\n<tr>\n<td><strong>JWT</strong></td>\n<td>Human-facing UI, account ops</td>\n<td>None</td>\n<td>7 days</td>\n</tr>\n</tbody></table>\n<h2>Mind Key (for Agents)</h2>\n<p>A Mind Key is a tenant-scoped API token. It authenticates a single mind&#39;s data\n(memories, tasks, chat, scripts, etc.). Use it for:</p>\n<ul>\n<li>LLM agents calling the API</li>\n<li>Background automation scripts</li>\n<li>MCP server configuration</li>\n<li>Any long-lived integration</li>\n</ul>\n<h3>Header authentication (recommended)</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer mk_yourMindKeyHere&quot;</span> \\\n     https://synapse.schaefer.zone/memory/recall</code></pre><h3>Query parameter (for URL-only tools)</h3>\n<pre><code class=\"hljs language-bash\">curl https://synapse.schaefer.zone/memory/recall?key=mk_yourMindKeyHere</code></pre><div class=\"callout callout-warn\">The `?key=` query parameter is rate-limited to **60 requests per minute**.\nThe Bearer header has no rate limit. Use the header whenever your client\nsupports custom headers.</div><h3>Creating a Mind Key</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/minds \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;name&quot;: &quot;Work Mind&quot;, &quot;description&quot;: &quot;Project memories&quot;}&#x27;</span></code></pre><p>Response includes <code>mind_key</code> — <strong>save it immediately</strong>, it&#39;s shown only once.</p>\n<h3>Listing your minds</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n     https://synapse.schaefer.zone/minds</code></pre><h3>Deleting a mind (irreversible!)</h3>\n<pre><code class=\"hljs language-bash\">curl -X DELETE -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n     https://synapse.schaefer.zone/minds/m_xyz789</code></pre><h2>JWT (for Humans)</h2>\n<p>JWTs authenticate the <strong>user account</strong>, not a specific mind. Use them for:</p>\n<ul>\n<li>Account registration and login</li>\n<li>Creating / listing / deleting minds</li>\n<li>Sharing minds with other users</li>\n<li>Web Push subscription management</li>\n</ul>\n<h3>Register</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/register \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;email&quot;: &quot;you@example.com&quot;, &quot;password&quot;: &quot;secret&quot;}&#x27;</span></code></pre><p>Returns: <code>{ &quot;jwt&quot;: &quot;eyJ...&quot;, &quot;user&quot;: {...} }</code></p>\n<h3>Login</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/login \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;email&quot;: &quot;you@example.com&quot;, &quot;password&quot;: &quot;secret&quot;}&#x27;</span></code></pre><p>Returns: <code>{ &quot;jwt&quot;: &quot;eyJ...&quot;, &quot;user&quot;: {...} }</code></p>\n<h3>JWT expiry</h3>\n<p>JWTs expire after <strong>7 days</strong>. When a JWT expires, simply call <code>/login</code> again to\nget a fresh one. The Mind Key never expires, so existing agent integrations\nkeep working.</p>\n<h2>Security Best Practices</h2>\n<div class=\"callout callout-critical\"></div><h3>Environment variable pattern</h3>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># .env (NEVER commit this file)</span>\nSYNAPSE_MIND_KEY=mk_yourMindKeyHere\nSYNAPSE_URL=https://synapse.schaefer.zone</code></pre><pre><code class=\"hljs language-typescript\"><span class=\"hljs-comment\">// Node.js</span>\n<span class=\"hljs-keyword\">const</span> mindKey = process.<span class=\"hljs-property\">env</span>.<span class=\"hljs-property\">SYNAPSE_MIND_KEY</span>;\n<span class=\"hljs-keyword\">const</span> url = process.<span class=\"hljs-property\">env</span>.<span class=\"hljs-property\">SYNAPSE_URL</span>;\n<span class=\"hljs-keyword\">await</span> <span class=\"hljs-title function_\">fetch</span>(<span class=\"hljs-string\">`<span class=\"hljs-subst\">${url}</span>/memory/recall`</span>, {\n  <span class=\"hljs-attr\">headers</span>: { <span class=\"hljs-title class_\">Authorization</span>: <span class=\"hljs-string\">`Bearer <span class=\"hljs-subst\">${mindKey}</span>`</span> },\n});</code></pre><h3>MCP server config</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;mcpServers&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">{</span>\n    <span class=\"hljs-attr\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">{</span>\n      <span class=\"hljs-attr\">&quot;command&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;npx&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;args&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;-y&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;synapse-mcp-api@latest&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;env&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">{</span>\n        <span class=\"hljs-attr\">&quot;SYNAPSE_MIND_KEY&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;mk_yourMindKeyHere&quot;</span><span class=\"hljs-punctuation\">,</span>\n        <span class=\"hljs-attr\">&quot;SYNAPSE_URL&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone&quot;</span>\n      <span class=\"hljs-punctuation\">}</span>\n    <span class=\"hljs-punctuation\">}</span>\n  <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h2>Multi-Mind Pattern</h2>\n<p>Each user can have multiple minds. Common patterns:</p>\n<table>\n<thead>\n<tr>\n<th>Mind Name</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>work</code></td>\n<td>Job-related memories</td>\n</tr>\n<tr>\n<td><code>personal</code></td>\n<td>Personal preferences, family</td>\n</tr>\n<tr>\n<td><code>project-synapse</code></td>\n<td>Specific project context</td>\n</tr>\n<tr>\n<td><code>learning-german</code></td>\n<td>Learning progress</td>\n</tr>\n<tr>\n<td><code>assistant-default</code></td>\n<td>General-purpose fallback</td>\n</tr>\n</tbody></table>\n<p>Use different Mind Keys for different LLM sessions to keep contexts isolated.</p>\n<h2>Rate Limits</h2>\n<table>\n<thead>\n<tr>\n<th>Auth Method</th>\n<th>Limit</th>\n<th>Scope</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Mind Key (header)</td>\n<td>None</td>\n<td>Per-mind</td>\n</tr>\n<tr>\n<td>Mind Key (?key=)</td>\n<td>60/min</td>\n<td>Per-IP</td>\n</tr>\n<tr>\n<td>JWT (header)</td>\n<td>None</td>\n<td>Per-user</td>\n</tr>\n<tr>\n<td>Public endpoints</td>\n<td>None</td>\n<td>Global</td>\n</tr>\n</tbody></table>\n<p>Rate limit headers (<code>X-RateLimit-Limit</code>, <code>X-RateLimit-Remaining</code>, <code>Retry-After</code>)\nare included in responses when applicable.</p>\n<h2>Next Steps</h2>\n<ul>\n<li><a href=\"/docs/getting-started/mind-key-vs-jwt\">Mind Key vs JWT</a> — when to use which</li>\n<li><a href=\"/docs/api/memory\">Memory API</a> — what you can do with a Mind Key</li>\n<li><a href=\"/docs/api/user\">User API</a> — account management with JWTs</li>\n</ul>\n","urls":{"html":"/docs/getting-started/authentication","text":"/docs/getting-started/authentication?format=text","json":"/docs/getting-started/authentication?format=json","llm":"/docs/getting-started/authentication?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}