{"title":"Erreurs & gestion des erreurs","slug":"errors","category":"api","summary":"Codes d'état HTTP, format de réponse d'erreur et comment se remettre des erreurs courantes.","audience":["human","llm"],"tags":["api","errors","troubleshooting","http"],"difficulty":"beginner","updated":"2026-06-27","word_count":591,"read_minutes":3,"llm_context":"Error format: { statusCode, error, message, docs? }\nCommon errors: 401 (auth), 404 (wrong path), 429 (rate limit), 500 (server)\n401 → check Mind Key/JWT, see /docs/getting-started/authentication\n404 → wrong path, GET /endpoints for valid list, do NOT guess paths\n429 → rate limited (?key= is 60/min), use Bearer header instead\n500 → server error, retry with backoff, check /health\ndocs field in error response links to relevant documentation.\n","lang":"fr","translated":true,"requested_lang":"fr","content_markdown":"\n# Erreurs & gestion des erreurs\n\nSynapse utilise les codes d'état HTTP standard avec un format de réponse d'erreur\ncohérent. Cette page explique comment interpréter et récupérer les erreurs.\n\n## Format de réponse d'erreur\n\nToutes les erreurs renvoient du JSON avec cette structure :\n\n```json\n{\n  \"statusCode\": 401,\n  \"error\": \"Unauthorized\",\n  \"message\": \"Mind Key fehlt oder ungültig.\",\n  \"docs\": \"https://synapse.schaefer.zone/docs/getting-started/authentication\"\n}\n```\n\n| Champ | Description |\n|-------|-------------|\n| `statusCode` | Code d'état HTTP |\n| `error` | Nom de l'état HTTP |\n| `message` | Description de l'erreur lisible par l'humain |\n| `docs` | URL vers la documentation pertinente (le cas échéant) |\n\n## Codes d'état HTTP\n\n### 200 OK\n\nSuccès. La requête a été traitée correctement.\n\n### 201 Created\n\nSuccès. Une nouvelle ressource a été créée (ex. `POST /memory`).\n\n### 204 No Content\n\nSuccès. Aucun corps renvoyé (ex. `DELETE /memory/:id`).\n\n### 400 Bad Request\n\nLa requête était mal formée. Causes courantes :\n\n- Champs JSON requis manquants\n- Syntaxe JSON invalide\n- Valeur d'énumération invalide (ex. mauvaise catégorie)\n\n```json\n{\n  \"statusCode\": 400,\n  \"error\": \"Bad Request\",\n  \"message\": \"category must be one of: identity, preference, fact, project, skill, mistake, context, note, credentials\"\n}\n```\n\n**Correction :** Vérifiez le corps de la requête par rapport à la documentation de\nl'API. Assurez-vous que tous les champs requis sont présents et ont des valeurs valides.\n\n### 401 Unauthorized\n\nL'authentification a échoué. Causes courantes :\n\n- En-tête `Authorization` manquant\n- Mind Key ou JWT invalide\n- Utilisation d'une Mind Key là où un JWT est requis (ou inversement)\n\n```json\n{\n  \"statusCode\": 401,\n  \"error\": \"Unauthorized\",\n  \"message\": \"Mind Key fehlt oder ungültig.\",\n  \"docs\": \"https://synapse.schaefer.zone/docs/getting-started/authentication\"\n}\n```\n\n**Correction :** Vérifiez votre jeton. Voir [Authentification](/docs/getting-started/authentication).\n\n### 403 Forbidden\n\nVous êtes authentifié mais n'êtes pas autorisé à effectuer cette action. Causes\ncourantes :\n\n- Tentative de suppression du mind d'un autre utilisateur\n- Tentative de vérifier une mémoire avec une Mind Key (nécessite un JWT)\n- Le mind est désactivé\n\n**Correction :** Vérifiez si vous utilisez le bon type de jeton pour cet endpoint.\n\n### 404 Not Found\n\nLe chemin ou la ressource demandée n'existe pas.\n\n> [!CRITICAL]\n> **Ne devinez PAS les chemins d'endpoints.** Seuls les chemins listés dans\n> `GET /endpoints` existent. Si vous obtenez un 404, c'est que vous avez utilisé un\n> mauvais chemin.\n\n```json\n{\n  \"statusCode\": 404,\n  \"error\": \"Not Found\",\n  \"message\": \"Route GET /memory/list not found\",\n  \"docs\": \"https://synapse.schaefer.zone/docs/api/errors\"\n}\n```\n\n**Correction :** Appelez `GET /endpoints` pour voir la liste des endpoints valides.\nComparez votre URL à la liste caractère par caractère.\n\n### 409 Conflict\n\nLa requête entre en conflit avec l'état existant. Causes courantes :\n\n- Tentative d'inscription avec un email déjà existant\n- URL de webhook en doublon\n\n**Correction :** Utilisez une valeur différente, ou utilisez `PUT` pour mettre à jour\nla ressource existante.\n\n### 429 Too Many Requests\n\nVous avez atteint une limite de débit. S'applique uniquement à l'authentification par\nparamètre de requête `?key=` (60/min).\n\n```json\n{\n  \"statusCode\": 429,\n  \"error\": \"Too Many Requests\",\n  \"message\": \"Rate limit exceeded. Use Authorization header for unlimited access.\"\n}\n```\n\nEn-têtes de réponse :\n\n```\nX-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42\n```\n\n**Correction :** Passez à l'en-tête `Authorization: Bearer` (sans limite de débit), ou\nattendez `Retry-After` secondes.\n\n### 500 Internal Server Error\n\nErreur serveur. Cela ne devrait pas arriver — si c'est le cas, c'est un bug.\n\n**Correction :**\n\n1. Réessayez avec un backoff exponentiel (1 s, 2 s, 4 s, 8 s)\n2. Vérifiez `GET /health` pour voir si le serveur fonctionne\n3. Si cela persiste, signalez l'erreur\n\n### 503 Service Unavailable\n\nLe serveur est temporairement indisponible (ex. pendant un déploiement, une migration\nde base de données).\n\n**Correction :** Attendez et réessayez. Vérifiez `GET /health`.\n\n## Schémas de récupération\n\n### Réessai avec backoff exponentiel\n\n```python\nimport time\nimport requests\n\ndef call_with_retry(url, max_retries=3):\n    for attempt in range(max_retries):\n        try:\n            r = requests.get(url, headers={\"Authorization\": f\"Bearer {KEY}\"})\n            if r.status_code == 429:\n                wait = int(r.headers.get(\"Retry-After\", 60))\n                time.sleep(wait)\n                continue\n            if r.status_code >= 500:\n                time.sleep(2 ** attempt)\n                continue\n            return r\n        except requests.RequestException:\n            time.sleep(2 ** attempt)\n    raise Exception(f\"Failed after {max_retries} retries\")\n```\n\n### Gestion des erreurs d'authentification\n\n```python\ndef safe_call(url, key):\n    r = requests.get(url, headers={\"Authorization\": f\"Bearer {key}\"})\n    if r.status_code == 401:\n        # Mind Key invalide — avertir l'utilisateur\n        raise AuthError(\"Mind Key invalid or expired\")\n    return r\n```\n\n## Scénarios d'erreur courants\n\n### \"Mind Key fehlt oder ungültig\"\n\n- Vous avez oublié l'en-tête `Authorization`\n- Vous avez utilisé `?key=` mais la clé est erronée\n- Vous utilisez un JWT là où une Mind Key est requise\n\n### \"Route not found\"\n\n- Vous avez deviné un chemin qui n'existe pas\n- Vous avez utilisé un verbe incorrect (ex. `GET /memory` vs `POST /memory`)\n- Vérifiez `GET /endpoints` pour les chemins valides\n\n### \"Rate limit exceeded\"\n\n- Vous utilisez `?key=` et avez dépassé 60 req/min\n- Passez à l'en-tête `Authorization: Bearer`\n\n## Prochaines étapes\n\n- [Authentification](/docs/getting-started/authentication)\n- [Vue d'ensemble de l'API](/docs/api/overview)\n- [Limites de débit](/docs/api/rate-limits)\n","content_html":"<h1>Erreurs &amp; gestion des erreurs</h1>\n<p>Synapse utilise les codes d&#39;état HTTP standard avec un format de réponse d&#39;erreur\ncohérent. Cette page explique comment interpréter et récupérer les erreurs.</p>\n<h2>Format de réponse d&#39;erreur</h2>\n<p>Toutes les erreurs renvoient du JSON avec cette structure :</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;statusCode&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">401</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;error&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Unauthorized&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;message&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Mind Key fehlt oder ungültig.&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;docs&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/docs/getting-started/authentication&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><table>\n<thead>\n<tr>\n<th>Champ</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>statusCode</code></td>\n<td>Code d&#39;état HTTP</td>\n</tr>\n<tr>\n<td><code>error</code></td>\n<td>Nom de l&#39;état HTTP</td>\n</tr>\n<tr>\n<td><code>message</code></td>\n<td>Description de l&#39;erreur lisible par l&#39;humain</td>\n</tr>\n<tr>\n<td><code>docs</code></td>\n<td>URL vers la documentation pertinente (le cas échéant)</td>\n</tr>\n</tbody></table>\n<h2>Codes d&#39;état HTTP</h2>\n<h3>200 OK</h3>\n<p>Succès. La requête a été traitée correctement.</p>\n<h3>201 Created</h3>\n<p>Succès. Une nouvelle ressource a été créée (ex. <code>POST /memory</code>).</p>\n<h3>204 No Content</h3>\n<p>Succès. Aucun corps renvoyé (ex. <code>DELETE /memory/:id</code>).</p>\n<h3>400 Bad Request</h3>\n<p>La requête était mal formée. Causes courantes :</p>\n<ul>\n<li>Champs JSON requis manquants</li>\n<li>Syntaxe JSON invalide</li>\n<li>Valeur d&#39;énumération invalide (ex. mauvaise catégorie)</li>\n</ul>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;statusCode&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">400</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;error&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Bad Request&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;message&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;category must be one of: identity, preference, fact, project, skill, mistake, context, note, credentials&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><p><strong>Correction :</strong> Vérifiez le corps de la requête par rapport à la documentation de\nl&#39;API. Assurez-vous que tous les champs requis sont présents et ont des valeurs valides.</p>\n<h3>401 Unauthorized</h3>\n<p>L&#39;authentification a échoué. Causes courantes :</p>\n<ul>\n<li>En-tête <code>Authorization</code> manquant</li>\n<li>Mind Key ou JWT invalide</li>\n<li>Utilisation d&#39;une Mind Key là où un JWT est requis (ou inversement)</li>\n</ul>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;statusCode&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">401</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;error&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Unauthorized&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;message&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Mind Key fehlt oder ungültig.&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;docs&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/docs/getting-started/authentication&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><p><strong>Correction :</strong> Vérifiez votre jeton. Voir <a href=\"/docs/getting-started/authentication\">Authentification</a>.</p>\n<h3>403 Forbidden</h3>\n<p>Vous êtes authentifié mais n&#39;êtes pas autorisé à effectuer cette action. Causes\ncourantes :</p>\n<ul>\n<li>Tentative de suppression du mind d&#39;un autre utilisateur</li>\n<li>Tentative de vérifier une mémoire avec une Mind Key (nécessite un JWT)</li>\n<li>Le mind est désactivé</li>\n</ul>\n<p><strong>Correction :</strong> Vérifiez si vous utilisez le bon type de jeton pour cet endpoint.</p>\n<h3>404 Not Found</h3>\n<p>Le chemin ou la ressource demandée n&#39;existe pas.</p>\n<div class=\"callout callout-critical\">**Ne devinez PAS les chemins d'endpoints.** Seuls les chemins listés dans\n`GET /endpoints` existent. Si vous obtenez un 404, c'est que vous avez utilisé un\nmauvais chemin.</div><pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;statusCode&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">404</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;error&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Not Found&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;message&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Route GET /memory/list not found&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;docs&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/docs/api/errors&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><p><strong>Correction :</strong> Appelez <code>GET /endpoints</code> pour voir la liste des endpoints valides.\nComparez votre URL à la liste caractère par caractère.</p>\n<h3>409 Conflict</h3>\n<p>La requête entre en conflit avec l&#39;état existant. Causes courantes :</p>\n<ul>\n<li>Tentative d&#39;inscription avec un email déjà existant</li>\n<li>URL de webhook en doublon</li>\n</ul>\n<p><strong>Correction :</strong> Utilisez une valeur différente, ou utilisez <code>PUT</code> pour mettre à jour\nla ressource existante.</p>\n<h3>429 Too Many Requests</h3>\n<p>Vous avez atteint une limite de débit. S&#39;applique uniquement à l&#39;authentification par\nparamètre de requête <code>?key=</code> (60/min).</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;statusCode&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">429</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;error&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Too Many Requests&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;message&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Rate limit exceeded. Use Authorization header for unlimited access.&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><p>En-têtes de réponse :</p>\n<pre><code class=\"hljs language-plaintext\">X-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42</code></pre><p><strong>Correction :</strong> Passez à l&#39;en-tête <code>Authorization: Bearer</code> (sans limite de débit), ou\nattendez <code>Retry-After</code> secondes.</p>\n<h3>500 Internal Server Error</h3>\n<p>Erreur serveur. Cela ne devrait pas arriver — si c&#39;est le cas, c&#39;est un bug.</p>\n<p><strong>Correction :</strong></p>\n<ol>\n<li>Réessayez avec un backoff exponentiel (1 s, 2 s, 4 s, 8 s)</li>\n<li>Vérifiez <code>GET /health</code> pour voir si le serveur fonctionne</li>\n<li>Si cela persiste, signalez l&#39;erreur</li>\n</ol>\n<h3>503 Service Unavailable</h3>\n<p>Le serveur est temporairement indisponible (ex. pendant un déploiement, une migration\nde base de données).</p>\n<p><strong>Correction :</strong> Attendez et réessayez. Vérifiez <code>GET /health</code>.</p>\n<h2>Schémas de récupération</h2>\n<h3>Réessai avec backoff exponentiel</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import</span> time\n<span class=\"hljs-keyword\">import</span> requests\n\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">call_with_retry</span>(<span class=\"hljs-params\">url, max_retries=<span class=\"hljs-number\">3</span></span>):\n    <span class=\"hljs-keyword\">for</span> attempt <span class=\"hljs-keyword\">in</span> <span class=\"hljs-built_in\">range</span>(max_retries):\n        <span class=\"hljs-keyword\">try</span>:\n            r = requests.get(url, headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>})\n            <span class=\"hljs-keyword\">if</span> r.status_code == <span class=\"hljs-number\">429</span>:\n                wait = <span class=\"hljs-built_in\">int</span>(r.headers.get(<span class=\"hljs-string\">&quot;Retry-After&quot;</span>, <span class=\"hljs-number\">60</span>))\n                time.sleep(wait)\n                <span class=\"hljs-keyword\">continue</span>\n            <span class=\"hljs-keyword\">if</span> r.status_code &gt;= <span class=\"hljs-number\">500</span>:\n                time.sleep(<span class=\"hljs-number\">2</span> ** attempt)\n                <span class=\"hljs-keyword\">continue</span>\n            <span class=\"hljs-keyword\">return</span> r\n        <span class=\"hljs-keyword\">except</span> requests.RequestException:\n            time.sleep(<span class=\"hljs-number\">2</span> ** attempt)\n    <span class=\"hljs-keyword\">raise</span> Exception(<span class=\"hljs-string\">f&quot;Failed after <span class=\"hljs-subst\">{max_retries}</span> retries&quot;</span>)</code></pre><h3>Gestion des erreurs d&#39;authentification</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">safe_call</span>(<span class=\"hljs-params\">url, key</span>):\n    r = requests.get(url, headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{key}</span>&quot;</span>})\n    <span class=\"hljs-keyword\">if</span> r.status_code == <span class=\"hljs-number\">401</span>:\n        <span class=\"hljs-comment\"># Mind Key invalide — avertir l&#x27;utilisateur</span>\n        <span class=\"hljs-keyword\">raise</span> AuthError(<span class=\"hljs-string\">&quot;Mind Key invalid or expired&quot;</span>)\n    <span class=\"hljs-keyword\">return</span> r</code></pre><h2>Scénarios d&#39;erreur courants</h2>\n<h3>&quot;Mind Key fehlt oder ungültig&quot;</h3>\n<ul>\n<li>Vous avez oublié l&#39;en-tête <code>Authorization</code></li>\n<li>Vous avez utilisé <code>?key=</code> mais la clé est erronée</li>\n<li>Vous utilisez un JWT là où une Mind Key est requise</li>\n</ul>\n<h3>&quot;Route not found&quot;</h3>\n<ul>\n<li>Vous avez deviné un chemin qui n&#39;existe pas</li>\n<li>Vous avez utilisé un verbe incorrect (ex. <code>GET /memory</code> vs <code>POST /memory</code>)</li>\n<li>Vérifiez <code>GET /endpoints</code> pour les chemins valides</li>\n</ul>\n<h3>&quot;Rate limit exceeded&quot;</h3>\n<ul>\n<li>Vous utilisez <code>?key=</code> et avez dépassé 60 req/min</li>\n<li>Passez à l&#39;en-tête <code>Authorization: Bearer</code></li>\n</ul>\n<h2>Prochaines étapes</h2>\n<ul>\n<li><a href=\"/docs/getting-started/authentication\">Authentification</a></li>\n<li><a href=\"/docs/api/overview\">Vue d&#39;ensemble de l&#39;API</a></li>\n<li><a href=\"/docs/api/rate-limits\">Limites de débit</a></li>\n</ul>\n","urls":{"html":"/docs/api/errors","text":"/docs/api/errors?format=text","json":"/docs/api/errors?format=json","llm":"/docs/api/errors?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}