Cron & Agendador
Agende chamadas recorrentes de API — cron jobs que disparam em horários programados, perfeitos para sincronização periódica e lembretes.
Cron & Agendador
A API de Cron permite agendar chamadas HTTP recorrentes para endpoints do Synapse (ou endpoints HTTPS externos). Perfeita para sincronização periódica, lembretes e tarefas de manutenção.
Endpoints
POST /cron
Cria uma tarefa agendada.
curl -X POST https://synapse.schaefer.zone/cron \
-H "Authorization: Bearer YOUR_MIND_KEY" \
-H "Content-Type: application/json" \
-d '{
"schedule": "0 * * * *",
"endpoint": "https://synapse.schaefer.zone/memory/recall",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'Resposta:
{
"id": "cron_001",
"schedule": "0 * * * *",
"endpoint": "https://synapse.schaefer.zone/memory/recall",
"method": "GET",
"enabled": true,
"next_run": "2026-06-27T13:00:00Z",
"created_at": "2026-06-27T..."
}GET /cron
Lista todas as tarefas agendadas.
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cronDELETE /cron/:id
Exclui uma tarefa agendada.
curl -X DELETE -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cron/cron_001PUT /cron/:id/toggle
Ativa ou desativa uma tarefa sem excluí-la.
curl -X PUT -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cron/cron_001/toggleSintaxe de agendamento
Cron padrão (5 campos)
┌───── minute (0-59)
│ ┌───── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌───── month (1-12)
│ │ │ │ ┌───── day of week (0-6, 0=Sunday)
│ │ │ │ │
* * * * *Exemplos:
| Agendamento | Significado |
|---|---|
0 * * * * |
A cada hora |
*/15 * * * * |
A cada 15 minutos |
0 9 * * 1-5 |
Dias úteis às 9h |
0 0 * * 0 |
Todo domingo à meia-noite |
0 0 1 * * |
Primeiro dia de cada mês à meia-noite |
Intervalo inteiro (segundos)
Para intervalos simples, passe um inteiro:
{ "schedule": "300" } // Every 5 minutesRestrições de endpoint
Endpoints devem ser URLs `http://` ou `https://` apontando para:
Isso evita ataques SSRF onde um mind comprometido pudesse agendar requisições para serviços internos.
Padrões comuns
Recall de memória por hora (para agentes LLM)
curl -X POST .../cron -d '{
"schedule": "0 * * * *",
"endpoint": "https://synapse.schaefer.zone/memory/recall",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'Backup diário
curl -X POST .../cron -d '{
"schedule": "0 2 * * *",
"endpoint": "https://synapse.schaefer.zone/memory/mind-export",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'Poll de chat periódico (a cada 5 minutos)
curl -X POST .../cron -d '{
"schedule": "300",
"endpoint": "https://synapse.schaefer.zone/chat/poll",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'Gatilho de relatório semanal
curl -X POST .../cron -d '{
"schedule": "0 9 * * 1",
"endpoint": "https://my-app.com/weekly-report",
"method": "POST",
"body": "{\"mind_id\": \"m_xyz789\"}",
"headers": {"Content-Type": "application/json", "X-API-Key": "my-secret"}
}'