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_id": "fn_1a2b3c4d"
    }
  }'

The function is invoked with the fixed payload {"trigger": "cron", "project_id": "<your project>"} — there is no custom-payload key, and action_config takes the function's id (not its name).

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",
      "secret": "optional-hmac-secret",
      "headers": {"X-Source": "scalix-cron"}
    }
  }'

Webhook deliveries are always POST (a method key is ignored). When secret is set, each delivery carries x-scalix-signature: sha256=<hex HMAC-SHA256 of the raw body> — verify it. The URL must be public http/https (SSRF-guarded at create and per delivery).

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