ScalixScalix Docs
Sign up

Cron

Scheduled jobs with cron expressions — trigger functions or webhooks on schedule

Overview

Scalix Cron schedules recurring jobs using standard cron expressions. Jobs can trigger functions or webhooks, with execution tracking and manual trigger support.

CLI

bash
# Create a schedule: <name> <expression>, action set via --action-type + --config
scalix-cloud cron create daily-cleanup "0 3 * * *" \
  --action-type function \
  --config '{"function_id":"cleanup-old-data"}'
 
# List schedules
scalix-cloud cron list
 
# Manually trigger
scalix-cloud cron trigger daily-cleanup
 
# View execution history
scalix-cloud cron executions daily-cleanup
 
# Delete a schedule
scalix-cloud cron delete daily-cleanup

REST API

Create a Schedule

bash
curl -X POST https://api.scalix.world/v1/cron/schedules \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{
    "name": "daily-cleanup",
    "cron_expression": "0 3 * * *",
    "timezone": "UTC",
    "action_type": "function",
    "action_config": {
      "function_name": "cleanup-old-data",
      "payload": {"days_old": 30}
    }
  }'

Webhook Action

bash
curl -X POST https://api.scalix.world/v1/cron/schedules \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{
    "name": "health-check",
    "cron_expression": "*/5 * * * *",
    "action_type": "webhook",
    "action_config": {
      "url": "https://myapp.com/health",
      "method": "POST",
      "headers": {"X-Source": "scalix-cron"}
    }
  }'

Update a Schedule

bash
curl -X PUT https://api.scalix.world/v1/cron/schedules/{id} \
  -H "Authorization: Bearer $SCALIX_API_KEY" \
  -d '{"cron_expression": "0 6 * * *", "enabled": true}'

Manual Trigger

bash
curl -X POST https://api.scalix.world/v1/cron/schedules/{id}/trigger \
  -H "Authorization: Bearer $SCALIX_API_KEY"

Execution History

bash
curl https://api.scalix.world/v1/cron/schedules/{id}/executions \
  -H "Authorization: Bearer $SCALIX_API_KEY"

Response includes status, trigger time, duration, and any errors.

Cron Expression Format

plaintext
┌───────── minute (0-59)
│ ┌─────── hour (0-23)
│ │ ┌───── day of month (1-31)
│ │ │ ┌─── month (1-12)
│ │ │ │ ┌─ day of week (0-6, Sun=0)
│ │ │ │ │
* * * * *
ExpressionDescription
0 * * * *Every hour
0 9 * * 1-5Weekdays at 9am
*/15 * * * *Every 15 minutes
0 0 1 * *First of every month