Skip to main content
The Cron API enables scheduling of recurring jobs using standard 5-field cron expressions. Jobs can trigger AI messages, API calls, or custom payloads at specified intervals.

List Cron Jobs

curl -X GET "http://localhost:8000/api/cron" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "cron_jobs": [
    {
      "id": 1,
      "user_id": "default",
      "name": "daily-standup",
      "cron_expr": "0 9 * * 1-5",
      "tz": "America/New_York",
      "message": "Generate daily standup report",
      "enabled": true,
      "channel": "web",
      "channel_target": "",
      "payload_kind": "agentturn",
      "tlg_call": true,
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}

Endpoint

GET /api/cron
List all cron jobs for the current user.

Response

cron_jobs
object[]
Array of cron jobs
cron_jobs[].id
number
Unique job identifier
cron_jobs[].name
string
Job name (unique per user)
cron_jobs[].cron_expr
string
5-field cron expression (e.g., 0 9 * * 1-5)
cron_jobs[].tz
string
Timezone (e.g., America/New_York)
cron_jobs[].message
string
Message or task to execute
cron_jobs[].enabled
boolean
Whether the job is active
cron_jobs[].channel
string
Delivery channel (e.g., web, telegram)
cron_jobs[].payload_kind
string
Payload type (e.g., agentturn)

Create Cron Job

curl -X POST "http://localhost:8000/api/cron" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "daily-standup",
    "cron_expr": "0 9 * * 1-5",
    "message": "Generate daily standup report",
    "tz": "America/New_York",
    "channel": "web",
    "payload_kind": "agentturn",
    "tlg_call": true
  }'
{
  "id": 1,
  "name": "daily-standup",
  "cron_expr": "0 9 * * 1-5"
}

Endpoint

POST /api/cron
Create a new recurring cron job.

Request Body

name
string
required
Unique job name (per user)
cron_expr
string
required
5-field cron expression (e.g., 0 9 * * 1-5 = weekdays at 9 AM)
message
string
required
Task description or message to execute
tz
string
Timezone (e.g., America/New_York, UTC). Defaults to system timezone.
channel
string
default:"web"
Delivery channel (e.g., web, telegram)
channel_target
string
default:""
Target identifier for the channel (e.g., Telegram chat ID)
payload_kind
string
default:"agentturn"
Payload type for execution
tlg_call
boolean
default:true
Whether to trigger Telegram notification

Response

id
number
Created job ID
name
string
Job name
cron_expr
string
Cron expression

Update Cron Job

curl -X PUT "http://localhost:8000/api/cron/1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "cron_expr": "0 10 * * 1-5",
    "enabled": true
  }'
{
  "ok": true,
  "id": 1,
  "name": "daily-standup",
  "cron_expr": "0 10 * * 1-5",
  "tz": "America/New_York"
}

Endpoint

PUT /api/cron/{job_id}
Update an existing cron job. The job is automatically rescheduled.

Path Parameters

job_id
number
required
Job ID to update

Request Body (all fields optional)

name
string
New job name
cron_expr
string
New cron expression
tz
string
New timezone
message
string
New message/task
enabled
boolean
Enable or disable the job
payload_kind
string
New payload type
tlg_call
boolean
Enable/disable Telegram notifications
channel
string
New channel
channel_target
string
New channel target

Delete Cron Job

curl -X DELETE "http://localhost:8000/api/cron/1" \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "ok": true,
  "id": 1
}

Endpoint

DELETE /api/cron/{job_id}
Delete a cron job and remove it from the scheduler.

Path Parameters

job_id
number
required
Job ID to delete

Cron Expression Format

Asta uses standard 5-field cron expressions:
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of week (0 - 6) (Sunday=0)
│ │ │ │ │
│ │ │ │ │
* * * * *

Examples

ExpressionDescription
0 9 * * 1-5Weekdays at 9:00 AM
30 14 * * *Every day at 2:30 PM
0 */2 * * *Every 2 hours
0 0 1 * *First day of every month at midnight
0 9 * * 1Every Monday at 9:00 AM
*/15 * * * *Every 15 minutes

Special Characters

  • * — Any value
  • */n — Every n units
  • n-m — Range from n to m
  • n,m — Values n and m

Timezone Support

Jobs are scheduled in the specified timezone. If no timezone is provided, the system default is used.
{
  "cron_expr": "0 9 * * *",
  "tz": "America/Los_Angeles"  // Runs at 9 AM Pacific Time
}

Build docs developers (and LLMs) love