{"title":"Cron & Scheduler","slug":"cron","category":"api","summary":"Pianifica chiamate API ricorrenti — cron job che si attivano secondo una pianificazione, perfetti per sync periodici e promemoria.","audience":["human","llm"],"tags":["api","cron","scheduler","automation"],"difficulty":"intermediate","updated":"2026-06-27","word_count":216,"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":"it","translated":true,"requested_lang":"it","content_markdown":"\n# Cron & Scheduler\n\nLa Cron API permette di pianificare chiamate HTTP ricorrenti agli endpoint di\nSynapse (o a endpoint HTTPS esterni). Perfetta per sync periodici, promemoria e\nattività di manutenzione.\n\n## Endpoint\n\n### POST /cron\n\nCrea un'attività pianificata.\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\nRisposta:\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\nElenca tutte le attività pianificate.\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron\n```\n\n### DELETE /cron/:id\n\nElimina un'attività pianificata.\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\nAbilita o disabilita un'attività senza eliminarla.\n\n```bash\ncurl -X PUT -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron/cron_001/toggle\n```\n\n## Sintassi della pianificazione\n\n### Cron standard (5 campi)\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\nEsempi:\n\n| Pianificazione | Significato |\n|----------|---------|\n| `0 * * * *` | Ogni ora |\n| `*/15 * * * *` | Ogni 15 minuti |\n| `0 9 * * 1-5` | Giorni feriali alle 9:00 |\n| `0 0 * * 0` | Ogni domenica a mezzanotte |\n| `0 0 1 * *` | Il primo di ogni mese a mezzanotte |\n\n### Intervallo intero (secondi)\n\nPer intervalli semplici, passi un intero:\n\n```json\n{ \"schedule\": \"300\" }  // Every 5 minutes\n```\n\n## Restrizioni sugli endpoint\n\n> [!WARNING]\n> Gli endpoint devono essere URL `http://` o `https://` che puntano a:\n> - La stessa istanza Synapse (es. `http://synapse:12800/memory/recall`)\n> - URL HTTPS pubblici (no IP privati, no localhost, no IP di metadata)\n\nQuesto previene attacchi SSRF in cui una mente compromessa potrebbe pianificare\nrichieste a servizi interni.\n\n## Modelli comuni\n\n### Richiamo memoria orario (per agenti 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### Backup giornaliero\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 chat periodico (ogni 5 minuti)\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### Attivazione report settimanale\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## Prossimi passi\n\n- [API Variables](/docs/api/variables)\n- [API Webhooks](/docs/api/webhooks)\n","content_html":"<h1>Cron &amp; Scheduler</h1>\n<p>La Cron API permette di pianificare chiamate HTTP ricorrenti agli endpoint di\nSynapse (o a endpoint HTTPS esterni). Perfetta per sync periodici, promemoria e\nattività di manutenzione.</p>\n<h2>Endpoint</h2>\n<h3>POST /cron</h3>\n<p>Crea un&#39;attività pianificata.</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>Risposta:</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>Elenca tutte le attività pianificate.</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>Elimina un&#39;attività pianificata.</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>Abilita o disabilita un&#39;attività senza eliminarla.</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>Sintassi della pianificazione</h2>\n<h3>Cron standard (5 campi)</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>Esempi:</p>\n<table>\n<thead>\n<tr>\n<th>Pianificazione</th>\n<th>Significato</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>0 * * * *</code></td>\n<td>Ogni ora</td>\n</tr>\n<tr>\n<td><code>*/15 * * * *</code></td>\n<td>Ogni 15 minuti</td>\n</tr>\n<tr>\n<td><code>0 9 * * 1-5</code></td>\n<td>Giorni feriali alle 9:00</td>\n</tr>\n<tr>\n<td><code>0 0 * * 0</code></td>\n<td>Ogni domenica a mezzanotte</td>\n</tr>\n<tr>\n<td><code>0 0 1 * *</code></td>\n<td>Il primo di ogni mese a mezzanotte</td>\n</tr>\n</tbody></table>\n<h3>Intervallo intero (secondi)</h3>\n<p>Per intervalli semplici, passi un intero:</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\">// Every 5 minutes</span></code></pre><h2>Restrizioni sugli endpoint</h2>\n<div class=\"callout callout-warn\">Gli endpoint devono essere URL `http://` o `https://` che puntano a:</div><p>Questo previene attacchi SSRF in cui una mente compromessa potrebbe pianificare\nrichieste a servizi interni.</p>\n<h2>Modelli comuni</h2>\n<h3>Richiamo memoria orario (per agenti 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>Backup giornaliero</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 chat periodico (ogni 5 minuti)</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>Attivazione report settimanale</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>Prossimi passi</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"]}