{"title":"Authentification & Mind Keys","slug":"authentication","category":"getting-started","summary":"Comment fonctionne l'authentification Synapse : Mind Keys pour les agents, JWT pour les humains, ?key= pour les outils n'utilisant que des URLs.","audience":["human","llm"],"tags":["auth","mind-key","jwt","security"],"difficulty":"beginner","updated":"2026-06-27","word_count":549,"read_minutes":3,"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":"fr","translated":true,"requested_lang":"fr","content_markdown":"\n# Authentification & Mind Keys\n\nSynapse utilise deux méthodes d'authentification, chacune optimisée pour un cas\nd'usage différent. Comprendre la différence est essentiel pour construire des\nintégrations fiables.\n\n## Deux méthodes d'auth\n\n| Méthode | Cas d'usage | Limite de débit | Expiration |\n|--------|----------|------------|--------|\n| **Mind Key** | Agents LLM, outils automatisés | Aucune (en-tête) / 60 min (requête) | Jamais |\n| **JWT** | Interface humaine, opérations de compte | Aucune | 7 jours |\n\n## Mind Key (pour les agents)\n\nUne Mind Key est un jeton d'API limité au tenant. Elle authentifie les données d'un\nseul mind (mémoires, tâches, chat, scripts, etc.). Utilisez-la pour :\n\n- Les agents LLM appelant l'API\n- Les scripts d'automatisation en arrière-plan\n- La configuration du serveur MCP\n- Toute intégration longue durée\n\n### Authentification par en-tête (recommandée)\n\n```bash\ncurl -H \"Authorization: Bearer mk_yourMindKeyHere\" \\\n     https://synapse.schaefer.zone/memory/recall\n```\n\n### Paramètre de requête (pour les outils n'utilisant que des URLs)\n\n```bash\ncurl https://synapse.schaefer.zone/memory/recall?key=mk_yourMindKeyHere\n```\n\n> [!WARNING]\n> Le paramètre de requête `?key=` est limité à **60 requêtes par minute**. L'en-tête\n> Bearer n'a pas de limite de débit. Utilisez l'en-tête chaque fois que votre client\n> prend en charge les en-têtes personnalisés.\n\n### Créer une 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\nLa réponse inclut `mind_key` — **sauvegardez-la immédiatement**, elle n'est affichée\nqu'une seule fois.\n\n### Lister vos minds\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds\n```\n\n### Supprimer un mind (irréversible !)\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_JWT\" \\\n     https://synapse.schaefer.zone/minds/m_xyz789\n```\n\n## JWT (pour les humains)\n\nLes JWT authentifient le **compte utilisateur**, pas un mind spécifique. Utilisez-les\npour :\n\n- L'inscription et la connexion au compte\n- La création / liste / suppression de minds\n- Le partage de minds avec d'autres utilisateurs\n- La gestion des abonnements Web Push\n\n### Inscription\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\nRenvoie : `{ \"jwt\": \"eyJ...\", \"user\": {...} }`\n\n### Connexion\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\nRenvoie : `{ \"jwt\": \"eyJ...\", \"user\": {...} }`\n\n### Expiration du JWT\n\nLes JWT expirent après **7 jours**. Une fois expirés, appelez simplement `/login` à\nnouveau pour en obtenir un nouveau. La Mind Key n'expire jamais, donc les intégrations\nd'agents existantes continuent de fonctionner.\n\n## Bonnes pratiques de sécurité\n\n> [!CRITICAL]\n> - **Ne commitez jamais de Mind Keys dans git.** Utilisez des variables d'environnement.\n> - **Ne journalisez jamais de Mind Keys.** Masquez-les dans les logs (`mk_***...***xyz`).\n> - **Pivotez les clés** si vous suspectez une fuite (supprimez le mind, créez-en un nouveau).\n> - **Utilisez un mind par projet** pour limiter le rayon d'impact en cas de fuite de clé.\n\n### Schéma de variable d'environnement\n\n```bash\n# .env (NE JAMAIS commiter ce fichier)\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### Configuration du serveur MCP\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## Schéma multi-mind\n\nChaque utilisateur peut avoir plusieurs minds. Schémas courants :\n\n| Nom du mind | Rôle |\n|-----------|---------|\n| `work` | Mémoires liées au travail |\n| `personal` | Préférences personnelles, famille |\n| `project-synapse` | Contexte de projet spécifique |\n| `learning-german` | Progression d'apprentissage |\n| `assistant-default` | Fallback à usage général |\n\nUtilisez différentes Mind Keys pour différentes sessions LLM afin de garder les\ncontextes isolés.\n\n## Limites de débit\n\n| Méthode d'auth | Limite | Portée |\n|-------------|-------|-------|\n| Mind Key (en-tête) | Aucune | Par mind |\n| Mind Key (?key=) | 60/min | Par IP |\n| JWT (en-tête) | Aucune | Par utilisateur |\n| Endpoints publics | Aucune | Globale |\n\nLes en-têtes de limite de débit (`X-RateLimit-Limit`, `X-RateLimit-Remaining`,\n`Retry-After`) sont inclus dans les réponses le cas échéant.\n\n## Prochaines étapes\n\n- [Mind Key vs JWT](/docs/getting-started/mind-key-vs-jwt) — quand utiliser laquelle\n- [API Memory](/docs/api/memory) — ce que vous pouvez faire avec une Mind Key\n- [API User](/docs/api/user) — gestion de compte avec JWT\n","content_html":"<h1>Authentification &amp; Mind Keys</h1>\n<p>Synapse utilise deux méthodes d&#39;authentification, chacune optimisée pour un cas\nd&#39;usage différent. Comprendre la différence est essentiel pour construire des\nintégrations fiables.</p>\n<h2>Deux méthodes d&#39;auth</h2>\n<table>\n<thead>\n<tr>\n<th>Méthode</th>\n<th>Cas d&#39;usage</th>\n<th>Limite de débit</th>\n<th>Expiration</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><strong>Mind Key</strong></td>\n<td>Agents LLM, outils automatisés</td>\n<td>Aucune (en-tête) / 60 min (requête)</td>\n<td>Jamais</td>\n</tr>\n<tr>\n<td><strong>JWT</strong></td>\n<td>Interface humaine, opérations de compte</td>\n<td>Aucune</td>\n<td>7 jours</td>\n</tr>\n</tbody></table>\n<h2>Mind Key (pour les agents)</h2>\n<p>Une Mind Key est un jeton d&#39;API limité au tenant. Elle authentifie les données d&#39;un\nseul mind (mémoires, tâches, chat, scripts, etc.). Utilisez-la pour :</p>\n<ul>\n<li>Les agents LLM appelant l&#39;API</li>\n<li>Les scripts d&#39;automatisation en arrière-plan</li>\n<li>La configuration du serveur MCP</li>\n<li>Toute intégration longue durée</li>\n</ul>\n<h3>Authentification par en-tête (recommandée)</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>Paramètre de requête (pour les outils n&#39;utilisant que des URLs)</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\">Le paramètre de requête `?key=` est limité à **60 requêtes par minute**. L'en-tête\nBearer n'a pas de limite de débit. Utilisez l'en-tête chaque fois que votre client\nprend en charge les en-têtes personnalisés.</div><h3>Créer une 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>La réponse inclut <code>mind_key</code> — <strong>sauvegardez-la immédiatement</strong>, elle n&#39;est affichée\nqu&#39;une seule fois.</p>\n<h3>Lister vos 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>Supprimer un mind (irréversible !)</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 (pour les humains)</h2>\n<p>Les JWT authentifient le <strong>compte utilisateur</strong>, pas un mind spécifique. Utilisez-les\npour :</p>\n<ul>\n<li>L&#39;inscription et la connexion au compte</li>\n<li>La création / liste / suppression de minds</li>\n<li>Le partage de minds avec d&#39;autres utilisateurs</li>\n<li>La gestion des abonnements Web Push</li>\n</ul>\n<h3>Inscription</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>Renvoie : <code>{ &quot;jwt&quot;: &quot;eyJ...&quot;, &quot;user&quot;: {...} }</code></p>\n<h3>Connexion</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>Renvoie : <code>{ &quot;jwt&quot;: &quot;eyJ...&quot;, &quot;user&quot;: {...} }</code></p>\n<h3>Expiration du JWT</h3>\n<p>Les JWT expirent après <strong>7 jours</strong>. Une fois expirés, appelez simplement <code>/login</code> à\nnouveau pour en obtenir un nouveau. La Mind Key n&#39;expire jamais, donc les intégrations\nd&#39;agents existantes continuent de fonctionner.</p>\n<h2>Bonnes pratiques de sécurité</h2>\n<div class=\"callout callout-critical\"></div><h3>Schéma de variable d&#39;environnement</h3>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># .env (NE JAMAIS commiter ce fichier)</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>Configuration du serveur MCP</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>Schéma multi-mind</h2>\n<p>Chaque utilisateur peut avoir plusieurs minds. Schémas courants :</p>\n<table>\n<thead>\n<tr>\n<th>Nom du mind</th>\n<th>Rôle</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>work</code></td>\n<td>Mémoires liées au travail</td>\n</tr>\n<tr>\n<td><code>personal</code></td>\n<td>Préférences personnelles, famille</td>\n</tr>\n<tr>\n<td><code>project-synapse</code></td>\n<td>Contexte de projet spécifique</td>\n</tr>\n<tr>\n<td><code>learning-german</code></td>\n<td>Progression d&#39;apprentissage</td>\n</tr>\n<tr>\n<td><code>assistant-default</code></td>\n<td>Fallback à usage général</td>\n</tr>\n</tbody></table>\n<p>Utilisez différentes Mind Keys pour différentes sessions LLM afin de garder les\ncontextes isolés.</p>\n<h2>Limites de débit</h2>\n<table>\n<thead>\n<tr>\n<th>Méthode d&#39;auth</th>\n<th>Limite</th>\n<th>Portée</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Mind Key (en-tête)</td>\n<td>Aucune</td>\n<td>Par mind</td>\n</tr>\n<tr>\n<td>Mind Key (?key=)</td>\n<td>60/min</td>\n<td>Par IP</td>\n</tr>\n<tr>\n<td>JWT (en-tête)</td>\n<td>Aucune</td>\n<td>Par utilisateur</td>\n</tr>\n<tr>\n<td>Endpoints publics</td>\n<td>Aucune</td>\n<td>Globale</td>\n</tr>\n</tbody></table>\n<p>Les en-têtes de limite de débit (<code>X-RateLimit-Limit</code>, <code>X-RateLimit-Remaining</code>,\n<code>Retry-After</code>) sont inclus dans les réponses le cas échéant.</p>\n<h2>Prochaines étapes</h2>\n<ul>\n<li><a href=\"/docs/getting-started/mind-key-vs-jwt\">Mind Key vs JWT</a> — quand utiliser laquelle</li>\n<li><a href=\"/docs/api/memory\">API Memory</a> — ce que vous pouvez faire avec une Mind Key</li>\n<li><a href=\"/docs/api/user\">API User</a> — gestion de compte avec JWT</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"]}