Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Schedules API

Schedules create jobs automatically on a cron-based interval.

Cron Format

mininq uses the cron crate, which supports a 7-field format:

sec  min  hour  day-of-month  month  day-of-week  year

The year field is optional. Common examples:

ExpressionMeaning
0 */5 * * * *Every 5 minutes
0 0 * * * *Every hour
0 0 9 * * *Daily at 09:00
0 30 2 * * MonMondays at 02:30
0 0 0 1 * *First day of each month

Note: The first field is seconds, not minutes. 0 * * * * * means “every minute at second 0.”


POST /schedules

Create a recurring schedule.

Request body:

FieldTypeRequiredDefaultDescription
cron_expressionStringyesCron expression (see format above)
callback_urlStringyesHTTP(S) URL to POST
queue_nameStringno"default"Target queue for generated jobs
payloadObjectno{}JSON payload for generated jobs
max_retriesi32no3Max retries for generated jobs
timeout_msi32no30000Timeout for generated jobs (ms)
enabledboolnotrueWhether the schedule is active

Example:

curl -X POST http://localhost:6390/schedules \
  -H "Content-Type: application/json" \
  -d '{
    "cron_expression": "0 */5 * * * *",
    "callback_url": "https://example.com/cleanup",
    "queue_name": "maintenance",
    "payload": {"task": "expire_sessions"}
  }'

Response: 201 Created

{
  "id": "019...",
  "queue_name": "maintenance",
  "cron_expression": "0 */5 * * * *",
  "callback_url": "https://example.com/cleanup",
  "payload": "{\"task\":\"expire_sessions\"}",
  "max_retries": 3,
  "timeout_ms": 30000,
  "enabled": 1,
  "last_run_at": null,
  "next_run_at": "2024-01-15T10:05:00.000",
  "created_at": "2024-01-15T10:00:00.000",
  "updated_at": "2024-01-15T10:00:00.000"
}

GET /schedules

List all schedules.

curl http://localhost:6390/schedules

Response: 200 OK — array of schedule objects, ordered by created_at DESC.


GET /schedules/

Get a single schedule.

curl http://localhost:6390/schedules/019...

Response: 200 OK — schedule object. 404 if not found.


PUT /schedules/

Update a schedule. Only provided fields are changed. If cron_expression is updated, next_run_at is automatically recomputed.

Request body:

FieldTypeDescription
queue_nameStringTarget queue
cron_expressionStringCron expression (recomputes next run)
callback_urlStringCallback URL
payloadObjectJSON payload
max_retriesi32Max retries
timeout_msi32Timeout (ms)
enabledboolEnable/disable the schedule

Example:

curl -X PUT http://localhost:6390/schedules/019... \
  -H "Content-Type: application/json" \
  -d '{"enabled": false}'

Response: 200 OK — updated schedule object. 404 if not found. 400 if no fields provided.


DELETE /schedules/

Delete a schedule.

curl -X DELETE http://localhost:6390/schedules/019...

Response: 200 OK

{
  "status": "deleted",
  "id": "019..."
}

Returns 404 if not found.