{"title":"Errors & Fehlerbehandlung","slug":"errors","category":"api","summary":"HTTP-Statuscodes, Fehler-Antwortformat und Wiederherstellung nach häufigen Fehlern.","audience":["human","llm"],"tags":["api","errors","troubleshooting","http"],"difficulty":"beginner","updated":"2026-06-27","word_count":481,"read_minutes":2,"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":"de","translated":true,"requested_lang":"de","content_markdown":"\n# Errors & Fehlerbehandlung\n\nSynapse verwendet Standard-HTTP-Statuscodes mit einem konsistenten Fehler-\nAntwortformat. Diese Seite erklärt, wie du Fehler interpretierst und behebst.\n\n## Fehler-Antwortformat\n\nAlle Fehler liefern JSON mit dieser Struktur:\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| Feld | Beschreibung |\n|-------|--------------|\n| `statusCode` | HTTP-Statuscode |\n| `error` | HTTP-Statusname |\n| `message` | Lesbare Fehlerbeschreibung |\n| `docs` | URL zur relevanten Doku (falls verfügbar) |\n\n## HTTP-Statuscodes\n\n### 200 OK\n\nErfolg. Die Anfrage wurde korrekt verarbeitet.\n\n### 201 Created\n\nErfolg. Eine neue Ressource wurde erstellt (z. B. `POST /memory`).\n\n### 204 No Content\n\nErfolg. Kein Body zurückgegeben (z. B. `DELETE /memory/:id`).\n\n### 400 Bad Request\n\nDie Anfrage war fehlerhaft. Häufige Ursachen:\n\n- Fehlende Pflicht-JSON-Felder\n- Ungültige JSON-Syntax\n- Ungültiger Enum-Wert (z. B. falsche Kategorie)\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**Lösung:** Prüfe den Request-Body gegen die API-Doku. Stelle sicher, dass alle\nPflichtfelder vorhanden sind und gültige Werte haben.\n\n### 401 Unauthorized\n\nAuthentifizierung fehlgeschlagen. Häufige Ursachen:\n\n- Fehlender `Authorization`-Header\n- Ungültiger Mind Key oder JWT\n- Mind Key verwendet, wo JWT erforderlich ist (oder umgekehrt)\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**Lösung:** Überprüfe deinen Token. Siehe [Authentifizierung](/docs/getting-started/authentication).\n\n### 403 Forbidden\n\nDu bist authentifiziert, darfst diese Aktion aber nicht ausführen. Häufige\nUrsachen:\n\n- Versuch, den Mind eines anderen Nutzers zu löschen\n- Versuch, einen Memory mit Mind Key zu verifizieren (erfordert JWT)\n- Mind ist deaktiviert\n\n**Lösung:** Prüfe, ob du den richtigen Token-Typ für diesen Endpunkt verwendest.\n\n### 404 Not Found\n\nDer angeforderte Pfad oder die Ressource existiert nicht.\n\n> [!CRITICAL]\n> **Rate keine Endpunkt-Pfade.** Nur die in `GET /endpoints` gelisteten Pfade\n> existieren. Bei einer 404 hast du einen falschen Pfad verwendet.\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**Lösung:** Rufe `GET /endpoints` auf, um die Liste gültiger Endpunkte zu\nsehen. Vergleiche deine URL Zeichen für Zeichen mit der Liste.\n\n### 409 Conflict\n\nDie Anfrage kollidiert mit dem bestehenden Zustand. Häufige Ursachen:\n\n- Registrierung mit einer E-Mail, die bereits existiert\n- Doppelte Webhook-URL\n\n**Lösung:** Verwende einen anderen Wert oder nutze `PUT`, um die bestehende\nRessource zu aktualisieren.\n\n### 429 Too Many Requests\n\nDu hast ein Rate Limit erreicht. Betrifft nur `?key=`-Query-Parameter-Auth\n(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\nResponse-Header:\n\n```\nX-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42\n```\n\n**Lösung:** Wechsle zum `Authorization: Bearer`-Header (kein Rate Limit) oder\nwarte `Retry-After` Sekunden.\n\n### 500 Internal Server Error\n\nServerfehler. Sollte nicht passieren — falls doch, ist es ein Bug.\n\n**Lösung:**\n\n1. Mit exponentiellem Backoff retry (1s, 2s, 4s, 8s)\n2. `GET /health` prüfen, ob der Server läuft\n3. Bei anhaltendem Fehler diesen melden\n\n### 503 Service Unavailable\n\nServer ist vorübergehend nicht verfügbar (z. B. während Deploy, DB-Migration).\n\n**Lösung:** Warten und retry. Prüfe `GET /health`.\n\n## Recovery-Patterns\n\n### Retry mit exponentiellem Backoff\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### Auth-Fehlerbehandlung\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 invalid — alert user\n        raise AuthError(\"Mind Key invalid or expired\")\n    return r\n```\n\n## Häufige Fehler-Szenarien\n\n### „Mind Key fehlt oder ungültig\"\n\n- Du hast den `Authorization`-Header vergessen\n- Du hast `?key=` verwendet, aber der Key ist falsch\n- Du verwendest einen JWT, wo ein Mind Key erforderlich ist\n\n### „Route not found\"\n\n- Du hast einen Pfad geraten, der nicht existiert\n- Du hast ein Verb falsch verwendet (z. B. `GET /memory` vs `POST /memory`)\n- Prüfe `GET /endpoints` für gültige Pfade\n\n### „Rate limit exceeded\"\n\n- Du verwendest `?key=` und hast 60 req/min überschritten\n- Wechsle zum `Authorization: Bearer`-Header\n\n## Nächste Schritte\n\n- [Authentifizierung](/docs/getting-started/authentication)\n- [API-Übersicht](/docs/api/overview)\n- [Rate Limits](/docs/api/rate-limits)\n","content_html":"<h1>Errors &amp; Fehlerbehandlung</h1>\n<p>Synapse verwendet Standard-HTTP-Statuscodes mit einem konsistenten Fehler-\nAntwortformat. Diese Seite erklärt, wie du Fehler interpretierst und behebst.</p>\n<h2>Fehler-Antwortformat</h2>\n<p>Alle Fehler liefern JSON mit dieser Struktur:</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>Feld</th>\n<th>Beschreibung</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>statusCode</code></td>\n<td>HTTP-Statuscode</td>\n</tr>\n<tr>\n<td><code>error</code></td>\n<td>HTTP-Statusname</td>\n</tr>\n<tr>\n<td><code>message</code></td>\n<td>Lesbare Fehlerbeschreibung</td>\n</tr>\n<tr>\n<td><code>docs</code></td>\n<td>URL zur relevanten Doku (falls verfügbar)</td>\n</tr>\n</tbody></table>\n<h2>HTTP-Statuscodes</h2>\n<h3>200 OK</h3>\n<p>Erfolg. Die Anfrage wurde korrekt verarbeitet.</p>\n<h3>201 Created</h3>\n<p>Erfolg. Eine neue Ressource wurde erstellt (z. B. <code>POST /memory</code>).</p>\n<h3>204 No Content</h3>\n<p>Erfolg. Kein Body zurückgegeben (z. B. <code>DELETE /memory/:id</code>).</p>\n<h3>400 Bad Request</h3>\n<p>Die Anfrage war fehlerhaft. Häufige Ursachen:</p>\n<ul>\n<li>Fehlende Pflicht-JSON-Felder</li>\n<li>Ungültige JSON-Syntax</li>\n<li>Ungültiger Enum-Wert (z. B. falsche Kategorie)</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>Lösung:</strong> Prüfe den Request-Body gegen die API-Doku. Stelle sicher, dass alle\nPflichtfelder vorhanden sind und gültige Werte haben.</p>\n<h3>401 Unauthorized</h3>\n<p>Authentifizierung fehlgeschlagen. Häufige Ursachen:</p>\n<ul>\n<li>Fehlender <code>Authorization</code>-Header</li>\n<li>Ungültiger Mind Key oder JWT</li>\n<li>Mind Key verwendet, wo JWT erforderlich ist (oder umgekehrt)</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>Lösung:</strong> Überprüfe deinen Token. Siehe <a href=\"/docs/getting-started/authentication\">Authentifizierung</a>.</p>\n<h3>403 Forbidden</h3>\n<p>Du bist authentifiziert, darfst diese Aktion aber nicht ausführen. Häufige\nUrsachen:</p>\n<ul>\n<li>Versuch, den Mind eines anderen Nutzers zu löschen</li>\n<li>Versuch, einen Memory mit Mind Key zu verifizieren (erfordert JWT)</li>\n<li>Mind ist deaktiviert</li>\n</ul>\n<p><strong>Lösung:</strong> Prüfe, ob du den richtigen Token-Typ für diesen Endpunkt verwendest.</p>\n<h3>404 Not Found</h3>\n<p>Der angeforderte Pfad oder die Ressource existiert nicht.</p>\n<div class=\"callout callout-critical\">**Rate keine Endpunkt-Pfade.** Nur die in `GET /endpoints` gelisteten Pfade\nexistieren. Bei einer 404 hast du einen falschen Pfad verwendet.</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>Lösung:</strong> Rufe <code>GET /endpoints</code> auf, um die Liste gültiger Endpunkte zu\nsehen. Vergleiche deine URL Zeichen für Zeichen mit der Liste.</p>\n<h3>409 Conflict</h3>\n<p>Die Anfrage kollidiert mit dem bestehenden Zustand. Häufige Ursachen:</p>\n<ul>\n<li>Registrierung mit einer E-Mail, die bereits existiert</li>\n<li>Doppelte Webhook-URL</li>\n</ul>\n<p><strong>Lösung:</strong> Verwende einen anderen Wert oder nutze <code>PUT</code>, um die bestehende\nRessource zu aktualisieren.</p>\n<h3>429 Too Many Requests</h3>\n<p>Du hast ein Rate Limit erreicht. Betrifft nur <code>?key=</code>-Query-Parameter-Auth\n(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>Response-Header:</p>\n<pre><code class=\"hljs language-plaintext\">X-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42</code></pre><p><strong>Lösung:</strong> Wechsle zum <code>Authorization: Bearer</code>-Header (kein Rate Limit) oder\nwarte <code>Retry-After</code> Sekunden.</p>\n<h3>500 Internal Server Error</h3>\n<p>Serverfehler. Sollte nicht passieren — falls doch, ist es ein Bug.</p>\n<p><strong>Lösung:</strong></p>\n<ol>\n<li>Mit exponentiellem Backoff retry (1s, 2s, 4s, 8s)</li>\n<li><code>GET /health</code> prüfen, ob der Server läuft</li>\n<li>Bei anhaltendem Fehler diesen melden</li>\n</ol>\n<h3>503 Service Unavailable</h3>\n<p>Server ist vorübergehend nicht verfügbar (z. B. während Deploy, DB-Migration).</p>\n<p><strong>Lösung:</strong> Warten und retry. Prüfe <code>GET /health</code>.</p>\n<h2>Recovery-Patterns</h2>\n<h3>Retry mit exponentiellem Backoff</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>Auth-Fehlerbehandlung</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 invalid — alert user</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>Häufige Fehler-Szenarien</h2>\n<h3>„Mind Key fehlt oder ungültig&quot;</h3>\n<ul>\n<li>Du hast den <code>Authorization</code>-Header vergessen</li>\n<li>Du hast <code>?key=</code> verwendet, aber der Key ist falsch</li>\n<li>Du verwendest einen JWT, wo ein Mind Key erforderlich ist</li>\n</ul>\n<h3>„Route not found&quot;</h3>\n<ul>\n<li>Du hast einen Pfad geraten, der nicht existiert</li>\n<li>Du hast ein Verb falsch verwendet (z. B. <code>GET /memory</code> vs <code>POST /memory</code>)</li>\n<li>Prüfe <code>GET /endpoints</code> für gültige Pfade</li>\n</ul>\n<h3>„Rate limit exceeded&quot;</h3>\n<ul>\n<li>Du verwendest <code>?key=</code> und hast 60 req/min überschritten</li>\n<li>Wechsle zum <code>Authorization: Bearer</code>-Header</li>\n</ul>\n<h2>Nächste Schritte</h2>\n<ul>\n<li><a href=\"/docs/getting-started/authentication\">Authentifizierung</a></li>\n<li><a href=\"/docs/api/overview\">API-Übersicht</a></li>\n<li><a href=\"/docs/api/rate-limits\">Rate Limits</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"]}