Cron & Scheduler
ตั้งเวลาการเรียก API แบบ recurring — cron jobs ที่ทำงานตามตารางเวลา เหมาะสำหรับ sync และการแจ้งเตือนเป็นคาบ
Cron & Scheduler
Cron API ช่วยให้คุณตั้งเวลาการเรียก HTTP แบบ recurring ไปยัง Synapse endpoint (หรือ external HTTPS endpoint) เหมาะสำหรับ sync เป็นคาบ, การแจ้งเตือน, และงานบำรุงรักษา
Endpoints
POST /cron
สร้าง task ที่ตั้งเวลาไว้
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"}
}'Response:
{
"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
รายการ task ที่ตั้งเวลาไว้ทั้งหมด
curl -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cronDELETE /cron/:id
ลบ task ที่ตั้งเวลาไว้
curl -X DELETE -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cron/cron_001PUT /cron/:id/toggle
เปิดหรือปิดใช้งาน task โดยไม่ลบ
curl -X PUT -H "Authorization: Bearer YOUR_MIND_KEY" \
https://synapse.schaefer.zone/cron/cron_001/toggleรูปแบบ Schedule
Standard cron (5 fields)
┌───── minute (0-59)
│ ┌───── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌───── month (1-12)
│ │ │ │ ┌───── day of week (0-6, 0=Sunday)
│ │ │ │ │
* * * * *ตัวอย่าง:
| Schedule | ความหมาย |
|---|---|
0 * * * * |
ทุกชั่วโมง |
*/15 * * * * |
ทุก 15 นาที |
0 9 * * 1-5 |
9 โมงเช้าวันธรรมดา |
0 0 * * 0 |
เที่ยงคืนทุกวันอาทิตย์ |
0 0 1 * * |
เที่ยงคืนวันแรกของทุกเดือน |
Integer interval (วินาที)
สำหรับช่วงเวลาง่าย ๆ ให้ส่ง integer:
{ "schedule": "300" } // ทุก 5 นาทีข้อจำกัดของ Endpoint
Endpoint ต้องเป็น URL แบบ `http://` หรือ `https://` ที่ชี้ไปยัง:
สิ่งนี้ป้องกัน SSRF attack ที่ mind ที่ถูกโจมตีอาจตั้งเวลา request ไปยัง internal service
รูปแบบทั่วไป
การ recall memory รายชั่วโมง (สำหรับ LLM agent)
curl -X POST .../cron -d '{
"schedule": "0 * * * *",
"endpoint": "https://synapse.schaefer.zone/memory/recall",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'สำรองข้อมูลรายวัน
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 chat เป็นคาบ (ทุก 5 นาที)
curl -X POST .../cron -d '{
"schedule": "300",
"endpoint": "https://synapse.schaefer.zone/chat/poll",
"method": "GET",
"headers": {"Authorization": "Bearer YOUR_MIND_KEY"}
}'ทริกเกอร์รายงานรายสัปดาห์
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"}
}'