{"title":"Webhooks API","slug":"webhooks","category":"api","summary":"मेमोरी, चैट, और कार्य घटनाओं के लिए HTTP कॉलबैक पंजीकृत करें — डेटा बदलने पर सूचित हों।","audience":["human","llm"],"tags":["api","webhooks","automation","events"],"difficulty":"intermediate","updated":"2026-06-27","word_count":223,"read_minutes":1,"llm_context":"Auth: Mind Key\nRegister: POST /webhooks { url, events, secret? }\nList: GET /webhooks\nGet: GET /webhooks/:id\nUpdate: PUT /webhooks/:id { url?, events?, secret?, enabled? }\nDelete: DELETE /webhooks/:id\nEvents: memory.*, memory.store, memory.update, memory.delete, chat.*, chat.message_received, task.*, task.created, task.completed\nSecret: HMAC-SHA256 signed payload, sent in X-Synapse-Signature header\nPattern: register webhook → receive POST → process event → call Synapse API\n","lang":"hi","translated":true,"requested_lang":"hi","content_markdown":"\n# Webhooks API\n\nWebhooks आपको Synapse में घटनाएँ होने पर HTTP कॉलबैक प्राप्त करने की सुविधा देते हैं। बाहरी ऑटोमेशन ट्रिगर करने, सूचनाएँ भेजने, या अन्य सिस्टम्स में सिंक करने के लिए आदर्श।\n\n## एंडपॉइंट्स\n\n### POST /webhooks\n\nनया webhook पंजीकृत करें।\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/webhooks \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://my-app.com/webhook\",\n    \"events\": \"memory.*\",\n    \"secret\": \"my-hmac-secret-min-8-chars\"\n  }'\n```\n\nप्रतिक्रिया:\n\n```json\n{\n  \"id\": \"wh_001\",\n  \"url\": \"https://my-app.com/webhook\",\n  \"events\": [\"memory.*\"],\n  \"enabled\": true,\n  \"created_at\": \"2026-06-27T...\"\n}\n```\n\n### GET /webhooks\n\nवर्तमान mind के लिए सभी webhooks की सूची बनाएँ।\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/webhooks\n```\n\n### GET /webhooks/:id\n\nएकल webhook प्राप्त करें।\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/webhooks/wh_001\n```\n\n### PUT /webhooks/:id\n\nWebhook अपडेट करें (URL, events, secret, या enabled फ़्लैग)।\n\n```bash\ncurl -X PUT https://synapse.schaefer.zone/webhooks/wh_001 \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"enabled\": false}'\n```\n\n### DELETE /webhooks/:id\n\nWebhook हटाएँ।\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/webhooks/wh_001\n```\n\n## घटना प्रकार\n\n| पैटर्न | कब सक्रिय होता है |\n|---------|------------|\n| `memory.*` | कोई भी मेमोरी घटना |\n| `memory.store` | नई मेमोरी स्टोर की गई |\n| `memory.update` | मेमोरी अपडेट की गई |\n| `memory.delete` | मेमोरी हटाई गई |\n| `chat.*` | कोई भी चैट घटना |\n| `chat.message_received` | मानव से नया संदेश |\n| `task.*` | कोई भी कार्य घटना |\n| `task.created` | नया कार्य बनाया गया |\n| `task.completed` | कार्य पूर्ण चिह्नित किया गया |\n| `*` | सभी घटनाएँ |\n\n## Webhook Payload\n\nजब कोई घटना सक्रिय होती है, Synapse आपके URL पर POST करता है:\n\n```json\n{\n  \"event\": \"memory.store\",\n  \"timestamp\": \"2026-06-27T...\",\n  \"mind_id\": \"m_xyz789\",\n  \"data\": {\n    \"id\": \"mem_001\",\n    \"category\": \"fact\",\n    \"key\": \"user_name\",\n    \"content\": \"Michael Schäfer\"\n  }\n}\n```\n\n## हस्ताक्षर सत्यापन\n\nयदि आप `secret` सेट करते हैं, तो Synapse प्रत्येक payload को HMAC-SHA256 के साथ हस्ताक्षरित करता है:\n\n```\nX-Synapse-Signature: sha256=<hex-hmac>\n```\n\nअपने हैंडलर में सत्यापित करें:\n\n```python\nimport hmac, hashlib\n\ndef verify_signature(payload_body: bytes, signature: str, secret: str) -> bool:\n    expected = hmac.new(\n        secret.encode(),\n        payload_body,\n        hashlib.sha256\n    ).hexdigest()\n    return hmac.compare_digest(f\"sha256={expected}\", signature)\n```\n\n## पैटर्न: रियल-टाइम सिंक\n\n```python\n# Your webhook handler\n@app.post(\"/webhook\")\nasync def handle_webhook(request):\n    body = await request.body()\n    signature = request.headers.get(\"X-Synapse-Signature\", \"\")\n    if not verify_signature(body, signature, WEBHOOK_SECRET):\n        return 401\n\n    event = json.loads(body)\n    if event[\"event\"] == \"memory.store\":\n        # Sync to another system\n        sync_to_external(event[\"data\"])\n    elif event[\"event\"] == \"chat.message_received\":\n        # Trigger agent wake-up\n        notify_agent(event[\"data\"])\n```\n\n## अगले कदम\n\n- [Cron और Scheduler](/docs/api/cron)\n- [Webhook ऑटोमेशन गाइड](/docs/guides/webhook-automation)\n","content_html":"<h1>Webhooks API</h1>\n<p>Webhooks आपको Synapse में घटनाएँ होने पर HTTP कॉलबैक प्राप्त करने की सुविधा देते हैं। बाहरी ऑटोमेशन ट्रिगर करने, सूचनाएँ भेजने, या अन्य सिस्टम्स में सिंक करने के लिए आदर्श।</p>\n<h2>एंडपॉइंट्स</h2>\n<h3>POST /webhooks</h3>\n<p>नया webhook पंजीकृत करें।</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/webhooks \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;url&quot;: &quot;https://my-app.com/webhook&quot;,\n    &quot;events&quot;: &quot;memory.*&quot;,\n    &quot;secret&quot;: &quot;my-hmac-secret-min-8-chars&quot;\n  }&#x27;</span></code></pre><p>प्रतिक्रिया:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;wh_001&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;url&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://my-app.com/webhook&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;events&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;memory.*&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;enabled&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">true</span></span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>GET /webhooks</h3>\n<p>वर्तमान mind के लिए सभी webhooks की सूची बनाएँ।</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/webhooks</code></pre><h3>GET /webhooks/:id</h3>\n<p>एकल webhook प्राप्त करें।</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/webhooks/wh_001</code></pre><h3>PUT /webhooks/:id</h3>\n<p>Webhook अपडेट करें (URL, events, secret, या enabled फ़्लैग)।</p>\n<pre><code class=\"hljs language-bash\">curl -X PUT https://synapse.schaefer.zone/webhooks/wh_001 \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;enabled&quot;: false}&#x27;</span></code></pre><h3>DELETE /webhooks/:id</h3>\n<p>Webhook हटाएँ।</p>\n<pre><code class=\"hljs language-bash\">curl -X DELETE -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/webhooks/wh_001</code></pre><h2>घटना प्रकार</h2>\n<table>\n<thead>\n<tr>\n<th>पैटर्न</th>\n<th>कब सक्रिय होता है</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>memory.*</code></td>\n<td>कोई भी मेमोरी घटना</td>\n</tr>\n<tr>\n<td><code>memory.store</code></td>\n<td>नई मेमोरी स्टोर की गई</td>\n</tr>\n<tr>\n<td><code>memory.update</code></td>\n<td>मेमोरी अपडेट की गई</td>\n</tr>\n<tr>\n<td><code>memory.delete</code></td>\n<td>मेमोरी हटाई गई</td>\n</tr>\n<tr>\n<td><code>chat.*</code></td>\n<td>कोई भी चैट घटना</td>\n</tr>\n<tr>\n<td><code>chat.message_received</code></td>\n<td>मानव से नया संदेश</td>\n</tr>\n<tr>\n<td><code>task.*</code></td>\n<td>कोई भी कार्य घटना</td>\n</tr>\n<tr>\n<td><code>task.created</code></td>\n<td>नया कार्य बनाया गया</td>\n</tr>\n<tr>\n<td><code>task.completed</code></td>\n<td>कार्य पूर्ण चिह्नित किया गया</td>\n</tr>\n<tr>\n<td><code>*</code></td>\n<td>सभी घटनाएँ</td>\n</tr>\n</tbody></table>\n<h2>Webhook Payload</h2>\n<p>जब कोई घटना सक्रिय होती है, Synapse आपके URL पर POST करता है:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;event&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;memory.store&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;timestamp&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;mind_id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;m_xyz789&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;data&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">{</span>\n    <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;mem_001&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;category&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;fact&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;user_name&quot;</span><span class=\"hljs-punctuation\">,</span>\n    <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Michael Schäfer&quot;</span>\n  <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h2>हस्ताक्षर सत्यापन</h2>\n<p>यदि आप <code>secret</code> सेट करते हैं, तो Synapse प्रत्येक payload को HMAC-SHA256 के साथ हस्ताक्षरित करता है:</p>\n<pre><code class=\"hljs language-plaintext\">X-Synapse-Signature: sha256=&lt;hex-hmac&gt;</code></pre><p>अपने हैंडलर में सत्यापित करें:</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import</span> hmac, hashlib\n\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">verify_signature</span>(<span class=\"hljs-params\">payload_body: <span class=\"hljs-built_in\">bytes</span>, signature: <span class=\"hljs-built_in\">str</span>, secret: <span class=\"hljs-built_in\">str</span></span>) -&gt; <span class=\"hljs-built_in\">bool</span>:\n    expected = hmac.new(\n        secret.encode(),\n        payload_body,\n        hashlib.sha256\n    ).hexdigest()\n    <span class=\"hljs-keyword\">return</span> hmac.compare_digest(<span class=\"hljs-string\">f&quot;sha256=<span class=\"hljs-subst\">{expected}</span>&quot;</span>, signature)</code></pre><h2>पैटर्न: रियल-टाइम सिंक</h2>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># Your webhook handler</span>\n<span class=\"hljs-meta\">@app.post(<span class=\"hljs-params\"><span class=\"hljs-string\">&quot;/webhook&quot;</span></span>)</span>\n<span class=\"hljs-keyword\">async</span> <span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">handle_webhook</span>(<span class=\"hljs-params\">request</span>):\n    body = <span class=\"hljs-keyword\">await</span> request.body()\n    signature = request.headers.get(<span class=\"hljs-string\">&quot;X-Synapse-Signature&quot;</span>, <span class=\"hljs-string\">&quot;&quot;</span>)\n    <span class=\"hljs-keyword\">if</span> <span class=\"hljs-keyword\">not</span> verify_signature(body, signature, WEBHOOK_SECRET):\n        <span class=\"hljs-keyword\">return</span> <span class=\"hljs-number\">401</span>\n\n    event = json.loads(body)\n    <span class=\"hljs-keyword\">if</span> event[<span class=\"hljs-string\">&quot;event&quot;</span>] == <span class=\"hljs-string\">&quot;memory.store&quot;</span>:\n        <span class=\"hljs-comment\"># Sync to another system</span>\n        sync_to_external(event[<span class=\"hljs-string\">&quot;data&quot;</span>])\n    <span class=\"hljs-keyword\">elif</span> event[<span class=\"hljs-string\">&quot;event&quot;</span>] == <span class=\"hljs-string\">&quot;chat.message_received&quot;</span>:\n        <span class=\"hljs-comment\"># Trigger agent wake-up</span>\n        notify_agent(event[<span class=\"hljs-string\">&quot;data&quot;</span>])</code></pre><h2>अगले कदम</h2>\n<ul>\n<li><a href=\"/docs/api/cron\">Cron और Scheduler</a></li>\n<li><a href=\"/docs/guides/webhook-automation\">Webhook ऑटोमेशन गाइड</a></li>\n</ul>\n","urls":{"html":"/docs/api/webhooks","text":"/docs/api/webhooks?format=text","json":"/docs/api/webhooks?format=json","llm":"/docs/api/webhooks?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}