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",
"scheduleType": "SCHEDULE_TYPE_CRON",
"cronExpression": "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",
"scheduleType": "SCHEDULE_TYPE_ONCE",
"scheduledAt": "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",
"scheduleType": "SCHEDULE_TYPE_RECURRING_INTERVAL",
"intervalSeconds": 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:
{
"scheduleId": "sched_a1b2c3d4e5f60718",
"name": "Daily digest",
"state": "SCHEDULE_STATE_ACTIVE",
"scheduleType": "SCHEDULE_TYPE_CRON",
"cronExpression": "0 9 * * 1-5",
"timezone": "America/New_York",
"nextTriggerAt": "2026-06-04T13:00:00Z",
"createdAt": "2026-06-03T14:00:00Z"
}
triggerCount and failureCount are absent here because they are zero — protojson
omits unset, empty, zero and false fields rather than sending null. Once the job has
fired they appear, and because they are 64-bit integers they arrive as strings:
"triggerCount": "42".