{"title":"Cron y Scheduler","slug":"cron","category":"api","summary":"Programe llamadas recurrentes a la API — trabajos cron que se disparan según una programación, ideales para sincronización periódica y recordatorios.","audience":["human","llm"],"tags":["api","cron","scheduler","automation"],"difficulty":"intermediate","updated":"2026-06-27","word_count":227,"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":"es","translated":true,"requested_lang":"es","content_markdown":"\n# Cron y Scheduler\n\nLa API de Cron permite programar llamadas HTTP recurrentes a endpoints de\nSynapse (o a endpoints HTTPS externos). Ideal para sincronización periódica,\nrecordatorios y tareas de mantenimiento.\n\n## Endpoints\n\n### POST /cron\n\nCrea una tarea programada.\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\nRespuesta:\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\nLista todas las tareas programadas.\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/cron\n```\n\n### DELETE /cron/:id\n\nElimina una tarea programada.\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\nHabilita o deshabilita una tarea sin 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## Sintaxis de programación\n\n### Cron estándar (5 campos)\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\nEjemplos:\n\n| Programación | Significado |\n|----------|---------|\n| `0 * * * *` | Cada hora |\n| `*/15 * * * *` | Cada 15 minutos |\n| `0 9 * * 1-5` | Días laborables a las 9am |\n| `0 0 * * 0` | Cada domingo a medianoche |\n| `0 0 1 * *` | El primero de cada mes a medianoche |\n\n### Intervalo entero (segundos)\n\nPara intervalos simples, pase un entero:\n\n```json\n{ \"schedule\": \"300\" }  // Every 5 minutes\n```\n\n## Restricciones de endpoints\n\n> [!WARNING]\n> Los endpoints deben ser URLs `http://` o `https://` que apunten a:\n> - La misma instancia de Synapse (p. ej. `http://synapse:12800/memory/recall`)\n> - URLs HTTPS públicas (no IPs privadas, no localhost, no IPs de metadata)\n\nEsto evita ataques SSRF donde un mind comprometido podría programar peticiones\na servicios internos.\n\n## Patrones comunes\n\n### Recall de memoria cada hora (para agentes 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 diario\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### Poll periódico de chat (cada 5 minutos)\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### Disparador de reporte semanal\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## Próximos pasos\n\n- [API de Variables](/docs/api/variables)\n- [API de Webhooks](/docs/api/webhooks)\n","content_html":"<h1>Cron y Scheduler</h1>\n<p>La API de Cron permite programar llamadas HTTP recurrentes a endpoints de\nSynapse (o a endpoints HTTPS externos). Ideal para sincronización periódica,\nrecordatorios y tareas de mantenimiento.</p>\n<h2>Endpoints</h2>\n<h3>POST /cron</h3>\n<p>Crea una tarea programada.</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>Respuesta:</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>Lista todas las tareas programadas.</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 una tarea programada.</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>Habilita o deshabilita una tarea sin 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>Sintaxis de programación</h2>\n<h3>Cron estándar (5 campos)</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>Ejemplos:</p>\n<table>\n<thead>\n<tr>\n<th>Programación</th>\n<th>Significado</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>0 * * * *</code></td>\n<td>Cada hora</td>\n</tr>\n<tr>\n<td><code>*/15 * * * *</code></td>\n<td>Cada 15 minutos</td>\n</tr>\n<tr>\n<td><code>0 9 * * 1-5</code></td>\n<td>Días laborables a las 9am</td>\n</tr>\n<tr>\n<td><code>0 0 * * 0</code></td>\n<td>Cada domingo a medianoche</td>\n</tr>\n<tr>\n<td><code>0 0 1 * *</code></td>\n<td>El primero de cada mes a medianoche</td>\n</tr>\n</tbody></table>\n<h3>Intervalo entero (segundos)</h3>\n<p>Para intervalos simples, pase un entero:</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>Restricciones de endpoints</h2>\n<div class=\"callout callout-warn\">Los endpoints deben ser URLs `http://` o `https://` que apunten a:</div><p>Esto evita ataques SSRF donde un mind comprometido podría programar peticiones\na servicios internos.</p>\n<h2>Patrones comunes</h2>\n<h3>Recall de memoria cada hora (para agentes 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 diario</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>Poll periódico de chat (cada 5 minutos)</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>Disparador de reporte semanal</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>Próximos pasos</h2>\n<ul>\n<li><a href=\"/docs/api/variables\">API de Variables</a></li>\n<li><a href=\"/docs/api/webhooks\">API de 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"]}