{"title":"Errors & Error Handling","slug":"errors","category":"api","summary":"HTTP status codes, error response format, and how to recover from common errors.","audience":["human","llm"],"tags":["api","errors","troubleshooting","http"],"difficulty":"beginner","updated":"2026-06-27","word_count":505,"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":"en","translated":true,"requested_lang":"en","content_markdown":"\n# Errors & Error Handling\n\nSynapse uses standard HTTP status codes with a consistent error response format.\nThis page explains how to interpret and recover from errors.\n\n## Error Response Format\n\nAll errors return JSON with this 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| Field | Description |\n|-------|-------------|\n| `statusCode` | HTTP status code |\n| `error` | HTTP status name |\n| `message` | Human-readable error description |\n| `docs` | URL to relevant documentation (when applicable) |\n\n## HTTP Status Codes\n\n### 200 OK\n\nSuccess. The request was processed correctly.\n\n### 201 Created\n\nSuccess. A new resource was created (e.g. `POST /memory`).\n\n### 204 No Content\n\nSuccess. No body returned (e.g. `DELETE /memory/:id`).\n\n### 400 Bad Request\n\nThe request was malformed. Common causes:\n\n- Missing required JSON fields\n- Invalid JSON syntax\n- Invalid enum value (e.g. wrong category)\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**Fix:** Check the request body against the API docs. Ensure all required\nfields are present and have valid values.\n\n### 401 Unauthorized\n\nAuthentication failed. Common causes:\n\n- Missing `Authorization` header\n- Invalid Mind Key or JWT\n- Using a Mind Key where a JWT is required (or vice versa)\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**Fix:** Verify your token. See [Authentication](/docs/getting-started/authentication).\n\n### 403 Forbidden\n\nYou're authenticated but not allowed to perform this action. Common causes:\n\n- Trying to delete another user's mind\n- Trying to verify a memory with a Mind Key (requires JWT)\n- Mind is disabled\n\n**Fix:** Check if you're using the correct token type for this endpoint.\n\n### 404 Not Found\n\nThe requested path or resource doesn't exist.\n\n> [!CRITICAL]\n> **Do NOT guess endpoint paths.** Only the paths listed in `GET /endpoints`\n> exist. If you get a 404, you used a wrong path.\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**Fix:** Call `GET /endpoints` to see the list of valid endpoints. Compare\nyour URL against the list character-by-character.\n\n### 409 Conflict\n\nThe request conflicts with existing state. Common causes:\n\n- Trying to register with an email that already exists\n- Duplicate webhook URL\n\n**Fix:** Use a different value, or use `PUT` to update the existing resource.\n\n### 429 Too Many Requests\n\nYou hit a rate limit. Only applies to `?key=` query parameter auth (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 headers:\n\n```\nX-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42\n```\n\n**Fix:** Switch to `Authorization: Bearer` header (no rate limit), or wait\n`Retry-After` seconds.\n\n### 500 Internal Server Error\n\nServer error. This shouldn't happen — if it does, it's a bug.\n\n**Fix:**\n\n1. Retry with exponential backoff (1s, 2s, 4s, 8s)\n2. Check `GET /health` to see if the server is up\n3. If persistent, report the error\n\n### 503 Service Unavailable\n\nServer is temporarily down (e.g. during deployment, database migration).\n\n**Fix:** Wait and retry. Check `GET /health`.\n\n## Recovery Patterns\n\n### Retry with exponential 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 error handling\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## Common Error Scenarios\n\n### \"Mind Key fehlt oder ungültig\"\n\n- You forgot the `Authorization` header\n- You used `?key=` but the key is wrong\n- You're using a JWT where a Mind Key is required\n\n### \"Route not found\"\n\n- You guessed a path that doesn't exist\n- You used a verb wrong (e.g. `GET /memory` vs `POST /memory`)\n- Check `GET /endpoints` for valid paths\n\n### \"Rate limit exceeded\"\n\n- You're using `?key=` and exceeded 60 req/min\n- Switch to `Authorization: Bearer` header\n\n## Next Steps\n\n- [Authentication](/docs/getting-started/authentication)\n- [API Overview](/docs/api/overview)\n- [Rate Limits](/docs/api/rate-limits)\n","content_html":"<h1>Errors &amp; Error Handling</h1>\n<p>Synapse uses standard HTTP status codes with a consistent error response format.\nThis page explains how to interpret and recover from errors.</p>\n<h2>Error Response Format</h2>\n<p>All errors return JSON with this 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>Field</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>statusCode</code></td>\n<td>HTTP status code</td>\n</tr>\n<tr>\n<td><code>error</code></td>\n<td>HTTP status name</td>\n</tr>\n<tr>\n<td><code>message</code></td>\n<td>Human-readable error description</td>\n</tr>\n<tr>\n<td><code>docs</code></td>\n<td>URL to relevant documentation (when applicable)</td>\n</tr>\n</tbody></table>\n<h2>HTTP Status Codes</h2>\n<h3>200 OK</h3>\n<p>Success. The request was processed correctly.</p>\n<h3>201 Created</h3>\n<p>Success. A new resource was created (e.g. <code>POST /memory</code>).</p>\n<h3>204 No Content</h3>\n<p>Success. No body returned (e.g. <code>DELETE /memory/:id</code>).</p>\n<h3>400 Bad Request</h3>\n<p>The request was malformed. Common causes:</p>\n<ul>\n<li>Missing required JSON fields</li>\n<li>Invalid JSON syntax</li>\n<li>Invalid enum value (e.g. wrong category)</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>Fix:</strong> Check the request body against the API docs. Ensure all required\nfields are present and have valid values.</p>\n<h3>401 Unauthorized</h3>\n<p>Authentication failed. Common causes:</p>\n<ul>\n<li>Missing <code>Authorization</code> header</li>\n<li>Invalid Mind Key or JWT</li>\n<li>Using a Mind Key where a JWT is required (or vice versa)</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>Fix:</strong> Verify your token. See <a href=\"/docs/getting-started/authentication\">Authentication</a>.</p>\n<h3>403 Forbidden</h3>\n<p>You&#39;re authenticated but not allowed to perform this action. Common causes:</p>\n<ul>\n<li>Trying to delete another user&#39;s mind</li>\n<li>Trying to verify a memory with a Mind Key (requires JWT)</li>\n<li>Mind is disabled</li>\n</ul>\n<p><strong>Fix:</strong> Check if you&#39;re using the correct token type for this endpoint.</p>\n<h3>404 Not Found</h3>\n<p>The requested path or resource doesn&#39;t exist.</p>\n<div class=\"callout callout-critical\">**Do NOT guess endpoint paths.** Only the paths listed in `GET /endpoints`\nexist. If you get a 404, you used a wrong path.</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>Fix:</strong> Call <code>GET /endpoints</code> to see the list of valid endpoints. Compare\nyour URL against the list character-by-character.</p>\n<h3>409 Conflict</h3>\n<p>The request conflicts with existing state. Common causes:</p>\n<ul>\n<li>Trying to register with an email that already exists</li>\n<li>Duplicate webhook URL</li>\n</ul>\n<p><strong>Fix:</strong> Use a different value, or use <code>PUT</code> to update the existing resource.</p>\n<h3>429 Too Many Requests</h3>\n<p>You hit a rate limit. Only applies to <code>?key=</code> query parameter auth (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 headers:</p>\n<pre><code class=\"hljs language-plaintext\">X-RateLimit-Limit: 60\nX-RateLimit-Remaining: 0\nRetry-After: 42</code></pre><p><strong>Fix:</strong> Switch to <code>Authorization: Bearer</code> header (no rate limit), or wait\n<code>Retry-After</code> seconds.</p>\n<h3>500 Internal Server Error</h3>\n<p>Server error. This shouldn&#39;t happen — if it does, it&#39;s a bug.</p>\n<p><strong>Fix:</strong></p>\n<ol>\n<li>Retry with exponential backoff (1s, 2s, 4s, 8s)</li>\n<li>Check <code>GET /health</code> to see if the server is up</li>\n<li>If persistent, report the error</li>\n</ol>\n<h3>503 Service Unavailable</h3>\n<p>Server is temporarily down (e.g. during deployment, database migration).</p>\n<p><strong>Fix:</strong> Wait and retry. Check <code>GET /health</code>.</p>\n<h2>Recovery Patterns</h2>\n<h3>Retry with exponential 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 error handling</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>Common Error Scenarios</h2>\n<h3>&quot;Mind Key fehlt oder ungültig&quot;</h3>\n<ul>\n<li>You forgot the <code>Authorization</code> header</li>\n<li>You used <code>?key=</code> but the key is wrong</li>\n<li>You&#39;re using a JWT where a Mind Key is required</li>\n</ul>\n<h3>&quot;Route not found&quot;</h3>\n<ul>\n<li>You guessed a path that doesn&#39;t exist</li>\n<li>You used a verb wrong (e.g. <code>GET /memory</code> vs <code>POST /memory</code>)</li>\n<li>Check <code>GET /endpoints</code> for valid paths</li>\n</ul>\n<h3>&quot;Rate limit exceeded&quot;</h3>\n<ul>\n<li>You&#39;re using <code>?key=</code> and exceeded 60 req/min</li>\n<li>Switch to <code>Authorization: Bearer</code> header</li>\n</ul>\n<h2>Next Steps</h2>\n<ul>\n<li><a href=\"/docs/getting-started/authentication\">Authentication</a></li>\n<li><a href=\"/docs/api/overview\">API Overview</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"]}