{"title":"Cron & Scheduler","slug":"cron","category":"api","summary":"Planifiez des appels d'API récurrents — tâches cron qui se déclenchent selon une planification, parfait pour la synchronisation périodique et les rappels.","audience":["human","llm"],"tags":["api","cron","scheduler","automation"],"difficulty":"intermediate","updated":"2026-06-27","word_count":241,"read_minutes":1,"llm_context":"Auth: Mind Key\nCreate: POST /cron { schedule, endpoint, method?, body?, headers?, enabled? }\nList: GET /cron\nDelete: DELETE /cron/:id\nToggle: PUT /cron/:id/toggle\nSchedule: 5-field cron (minute hour day month day-of-week) OR integer interval (seconds)\nEndpoint: must be http(s) URL, same Synapse instance OR public HTTPS (no private IPs)\nPattern: schedule /memory/recall every hour, /chat/poll every 5 min, etc.\n","lang":"fr","translated":true,"requested_lang":"fr","content_markdown":"\n# Cron & Scheduler\n\nL'API Cron permet de planifier des appels HTTP récurrents vers des endpoints Synapse\n(ou des endpoints HTTPS externes). Parfait pour la synchronisation périodique, les\nrappels et les tâches de maintenance.\n\n## Endpoints\n\n### POST /cron\n\nCrée une tâche planifiée.\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/cron \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"schedule\": \"0 * * * *\",\n    \"endpoint\": \"https://synapse.schaefer.zone/memory/recall\",\n    \"method\": \"GET\",\n    \"headers\": {\"Authorization\": \"Bearer YOUR_MIND_KEY\"}\n  }'\n```\n\nRéponse :\n\n```json\n{\n  \"id\": \"cron_001\",\n  \"schedule\": \"0 * * * *\",\n  \"endpoint\": \"https://synapse.schaefer.zone/memory/recall\",\n  \"method\": \"GET\",\n  \"enabled\": true,\n  \"next_run\": \"2026-06-27T13:00:00Z\",\n  \"created_at\": \"2026-06-27T...\"\n}\n```\n\n### GET /cron\n\nListe toutes les tâches planifiées.\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron\n```\n\n### DELETE /cron/:id\n\nSupprime une tâche planifiée.\n\n```bash\ncurl -X DELETE -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron/cron_001\n```\n\n### PUT /cron/:id/toggle\n\nActive ou désactive une tâche sans la supprimer.\n\n```bash\ncurl -X PUT -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron/cron_001/toggle\n```\n\n## Syntaxe de planification\n\n### Cron standard (5 champs)\n\n```\n┌───── minute (0-59)\n│ ┌───── hour (0-23)\n│ │ ┌───── day of month (1-31)\n│ │ │ ┌───── month (1-12)\n│ │ │ │ ┌───── day of week (0-6, 0=Sunday)\n│ │ │ │ │\n* * * * *\n```\n\nExemples :\n\n| Planification | Signification |\n|----------|---------|\n| `0 * * * *` | Toutes les heures |\n| `*/15 * * * *` | Toutes les 15 minutes |\n| `0 9 * * 1-5` | En semaine à 9 h |\n| `0 0 * * 0` | Tous les dimanches à minuit |\n| `0 0 1 * *` | Le premier de chaque mois à minuit |\n\n### Intervalle entier (secondes)\n\nPour des intervalles simples, passez un entier :\n\n```json\n{ \"schedule\": \"300\" }  // Toutes les 5 minutes\n```\n\n## Restrictions sur les endpoints\n\n> [!WARNING]\n> Les endpoints doivent être des URLs `http://` ou `https://` pointant vers :\n> - La même instance Synapse (ex. `http://synapse:12800/memory/recall`)\n> - Des URLs HTTPS publiques (pas d'IP privées, pas de localhost, pas d'IP de métadonnées)\n\nCela empêche les attaques SSRF où un mind compromis pourrait planifier des requêtes\nvers des services internes.\n\n## Schémas courants\n\n### Rappel mémoire horaire (pour les agents LLM)\n\n```bash\ncurl -X POST .../cron -d '{\n  \"schedule\": \"0 * * * *\",\n  \"endpoint\": \"https://synapse.schaefer.zone/memory/recall\",\n  \"method\": \"GET\",\n  \"headers\": {\"Authorization\": \"Bearer YOUR_MIND_KEY\"}\n}'\n```\n\n### Sauvegarde quotidienne\n\n```bash\ncurl -X POST .../cron -d '{\n  \"schedule\": \"0 2 * * *\",\n  \"endpoint\": \"https://synapse.schaefer.zone/memory/mind-export\",\n  \"method\": \"GET\",\n  \"headers\": {\"Authorization\": \"Bearer YOUR_MIND_KEY\"}\n}'\n```\n\n### Polling périodique du chat (toutes les 5 minutes)\n\n```bash\ncurl -X POST .../cron -d '{\n  \"schedule\": \"300\",\n  \"endpoint\": \"https://synapse.schaefer.zone/chat/poll\",\n  \"method\": \"GET\",\n  \"headers\": {\"Authorization\": \"Bearer YOUR_MIND_KEY\"}\n}'\n```\n\n### Déclencheur de rapport hebdomadaire\n\n```bash\ncurl -X POST .../cron -d '{\n  \"schedule\": \"0 9 * * 1\",\n  \"endpoint\": \"https://my-app.com/weekly-report\",\n  \"method\": \"POST\",\n  \"body\": \"{\\\"mind_id\\\": \\\"m_xyz789\\\"}\",\n  \"headers\": {\"Content-Type\": \"application/json\", \"X-API-Key\": \"my-secret\"}\n}'\n```\n\n## Prochaines étapes\n\n- [API Variables](/docs/api/variables)\n- [API Webhooks](/docs/api/webhooks)\n","content_html":"<h1>Cron &amp; Scheduler</h1>\n<p>L&#39;API Cron permet de planifier des appels HTTP récurrents vers des endpoints Synapse\n(ou des endpoints HTTPS externes). Parfait pour la synchronisation périodique, les\nrappels et les tâches de maintenance.</p>\n<h2>Endpoints</h2>\n<h3>POST /cron</h3>\n<p>Crée une tâche planifiée.</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/cron \\\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;schedule&quot;: &quot;0 * * * *&quot;,\n    &quot;endpoint&quot;: &quot;https://synapse.schaefer.zone/memory/recall&quot;,\n    &quot;method&quot;: &quot;GET&quot;,\n    &quot;headers&quot;: {&quot;Authorization&quot;: &quot;Bearer YOUR_MIND_KEY&quot;}\n  }&#x27;</span></code></pre><p>Réponse :</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;cron_001&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;schedule&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;0 * * * *&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;endpoint&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/memory/recall&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;method&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;GET&quot;</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;next_run&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T13:00:00Z&quot;</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 /cron</h3>\n<p>Liste toutes les tâches planifiées.</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/cron</code></pre><h3>DELETE /cron/:id</h3>\n<p>Supprime une tâche planifiée.</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/cron/cron_001</code></pre><h3>PUT /cron/:id/toggle</h3>\n<p>Active ou désactive une tâche sans la supprimer.</p>\n<pre><code class=\"hljs language-bash\">curl -X PUT -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/cron/cron_001/toggle</code></pre><h2>Syntaxe de planification</h2>\n<h3>Cron standard (5 champs)</h3>\n<pre><code class=\"hljs language-plaintext\">┌───── minute (0-59)\n│ ┌───── hour (0-23)\n│ │ ┌───── day of month (1-31)\n│ │ │ ┌───── month (1-12)\n│ │ │ │ ┌───── day of week (0-6, 0=Sunday)\n│ │ │ │ │\n* * * * *</code></pre><p>Exemples :</p>\n<table>\n<thead>\n<tr>\n<th>Planification</th>\n<th>Signification</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>0 * * * *</code></td>\n<td>Toutes les heures</td>\n</tr>\n<tr>\n<td><code>*/15 * * * *</code></td>\n<td>Toutes les 15 minutes</td>\n</tr>\n<tr>\n<td><code>0 9 * * 1-5</code></td>\n<td>En semaine à 9 h</td>\n</tr>\n<tr>\n<td><code>0 0 * * 0</code></td>\n<td>Tous les dimanches à minuit</td>\n</tr>\n<tr>\n<td><code>0 0 1 * *</code></td>\n<td>Le premier de chaque mois à minuit</td>\n</tr>\n</tbody></table>\n<h3>Intervalle entier (secondes)</h3>\n<p>Pour des intervalles simples, passez un entier :</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;schedule&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;300&quot;</span> <span class=\"hljs-punctuation\">}</span>  <span class=\"hljs-comment\">// Toutes les 5 minutes</span></code></pre><h2>Restrictions sur les endpoints</h2>\n<div class=\"callout callout-warn\">Les endpoints doivent être des URLs `http://` ou `https://` pointant vers :</div><p>Cela empêche les attaques SSRF où un mind compromis pourrait planifier des requêtes\nvers des services internes.</p>\n<h2>Schémas courants</h2>\n<h3>Rappel mémoire horaire (pour les agents LLM)</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST .../cron -d <span class=\"hljs-string\">&#x27;{\n  &quot;schedule&quot;: &quot;0 * * * *&quot;,\n  &quot;endpoint&quot;: &quot;https://synapse.schaefer.zone/memory/recall&quot;,\n  &quot;method&quot;: &quot;GET&quot;,\n  &quot;headers&quot;: {&quot;Authorization&quot;: &quot;Bearer YOUR_MIND_KEY&quot;}\n}&#x27;</span></code></pre><h3>Sauvegarde quotidienne</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST .../cron -d <span class=\"hljs-string\">&#x27;{\n  &quot;schedule&quot;: &quot;0 2 * * *&quot;,\n  &quot;endpoint&quot;: &quot;https://synapse.schaefer.zone/memory/mind-export&quot;,\n  &quot;method&quot;: &quot;GET&quot;,\n  &quot;headers&quot;: {&quot;Authorization&quot;: &quot;Bearer YOUR_MIND_KEY&quot;}\n}&#x27;</span></code></pre><h3>Polling périodique du chat (toutes les 5 minutes)</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST .../cron -d <span class=\"hljs-string\">&#x27;{\n  &quot;schedule&quot;: &quot;300&quot;,\n  &quot;endpoint&quot;: &quot;https://synapse.schaefer.zone/chat/poll&quot;,\n  &quot;method&quot;: &quot;GET&quot;,\n  &quot;headers&quot;: {&quot;Authorization&quot;: &quot;Bearer YOUR_MIND_KEY&quot;}\n}&#x27;</span></code></pre><h3>Déclencheur de rapport hebdomadaire</h3>\n<pre><code class=\"hljs language-bash\">curl -X POST .../cron -d <span class=\"hljs-string\">&#x27;{\n  &quot;schedule&quot;: &quot;0 9 * * 1&quot;,\n  &quot;endpoint&quot;: &quot;https://my-app.com/weekly-report&quot;,\n  &quot;method&quot;: &quot;POST&quot;,\n  &quot;body&quot;: &quot;{\\&quot;mind_id\\&quot;: \\&quot;m_xyz789\\&quot;}&quot;,\n  &quot;headers&quot;: {&quot;Content-Type&quot;: &quot;application/json&quot;, &quot;X-API-Key&quot;: &quot;my-secret&quot;}\n}&#x27;</span></code></pre><h2>Prochaines étapes</h2>\n<ul>\n<li><a href=\"/docs/api/variables\">API Variables</a></li>\n<li><a href=\"/docs/api/webhooks\">API Webhooks</a></li>\n</ul>\n","urls":{"html":"/docs/api/cron","text":"/docs/api/cron?format=text","json":"/docs/api/cron?format=json","llm":"/docs/api/cron?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}