Creating Jobs
Creating Jobs
Cron Job
Fires on a 5- or 6-field cron expression. The timezone field controls which clock the expression is evaluated against (defaults to UTC). The target.method field defaults to POST and can be omitted in all schedule types.
curl -X POST https://api.travila.ai/api/v1/scheduler/create-job \
-H "X-API-Key: sk_your_key_here" \
-H "X-On-Behalf-Of: user_123" \
-H "Content-Type: application/json" \
-d '{
"name": "Daily digest",
"schedule_type": "SCHEDULE_TYPE_CRON",
"cron_expression": "0 9 * * 1-5",
"timezone": "America/New_York",
"target": {
"url": "https://your-api.example.com/jobs/daily-digest",
"kind": "digest",
"payload": { "report": "daily" }
}
}'
Common cron expressions:
| Expression | Meaning |
|---|---|
0 9 * * 1-5 | Weekdays at 9:00 AM |
*/15 * * * * | Every 15 minutes |
0 0 1 * * | First day of each month at midnight |
@daily | Shorthand for 0 0 * * * |
@hourly | Shorthand for 0 * * * * |
One-Shot Job
Fires exactly once at the given timestamp. Use RFC 3339 format.
curl -X POST https://api.travila.ai/api/v1/scheduler/create-job \
-H "X-API-Key: sk_your_key_here" \
-H "X-On-Behalf-Of: user_123" \
-H "Content-Type: application/json" \
-d '{
"name": "Send welcome email",
"schedule_type": "SCHEDULE_TYPE_ONCE",
"scheduled_at": "2026-06-10T14:00:00Z",
"target": {
"url": "https://your-api.example.com/jobs/welcome",
"kind": "notification",
"payload": { "user_id": "usr_abc123" }
}
}'
Recurring Interval Job
Fires every N seconds. Minimum interval is 60 seconds.
curl -X POST https://api.travila.ai/api/v1/scheduler/create-job \
-H "X-API-Key: sk_your_key_here" \
-H "X-On-Behalf-Of: user_123" \
-H "Content-Type: application/json" \
-d '{
"name": "Sync cache",
"schedule_type": "SCHEDULE_TYPE_RECURRING_INTERVAL",
"interval_seconds": 300,
"target": {
"url": "https://your-api.example.com/jobs/cache-sync",
"kind": "maintenance"
}
}'
Response
All three types return the created Schedule resource directly — the same flat shape returned by get-job, pause-job, and resume-job:
{
"schedule_id": "sched_a1b2c3d4e5f60718",
"name": "Daily digest",
"state": "SCHEDULE_STATE_ACTIVE",
"schedule_type": "SCHEDULE_TYPE_CRON",
"cron_expression": "0 9 * * 1-5",
"timezone": "America/New_York",
"next_trigger_at": "2026-06-04T13:00:00Z",
"trigger_count": 0,
"failure_count": 0,
"created_at": "2026-06-03T14:00:00Z"
}