Schedules
Schedules define when cloud resources should be automatically started or stopped using cron expressions.
How Scheduling Works
- Create a schedule with one or more cron entries (each specifying start or stop)
- Attach individual resources or resource groups to the schedule
- The scheduler evaluates all crons every minute
- When a cron fires, action intents are queued for execution
- The executor processes the queue and calls cloud provider APIs
Timezone Support
Cron Expression Format
ZopNight 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)
│ │ │ │ │
* * * * *Common Patterns
| Pattern | Expression | Description |
|---|---|---|
| Business Hours Start | 0 8 * * 1-5 | Start at 8:00 AM on weekdays |
| Business Hours Stop | 0 18 * * 1-5 | Stop at 6:00 PM on weekdays |
| Night Shutdown | 0 22 * * * | Stop at 10:00 PM every day |
| Morning Startup | 0 6 * * 1-5 | Start at 6:00 AM on weekdays |
| Weekend Shutdown | 0 20 * * 5 | Stop at 8:00 PM on Friday |
| Weekend Startup | 0 7 * * 1 | Start at 7:00 AM on Monday |
Create Schedule
/schedulesCreate a new schedule with cron entries.
curl -X POST https://zopnight.com/api/schedules \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Business Hours",
"description": "Start resources at 8 AM, stop at 6 PM on weekdays",
"timezone": "America/New_York",
"crons": [
{
"cronExpression": "0 8 * * 1-5",
"action": "start"
},
{
"cronExpression": "0 18 * * 1-5",
"action": "stop"
}
]
}'{
"data": {
"id": "sch_abc123",
"name": "Business Hours",
"description": "Start resources at 8 AM, stop at 6 PM on weekdays",
"timezone": "America/New_York",
"crons": [
{
"id": "cron_001",
"cronExpression": "0 8 * * 1-5",
"action": "start"
},
{
"id": "cron_002",
"cronExpression": "0 18 * * 1-5",
"action": "stop"
}
],
"resources": [],
"groups": [],
"createdBy": "user@company.com",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z"
}
}List Schedules
/schedulesList all schedules for your organization.
Get Schedule
/schedules/{scheduleID}Get a schedule with its cron entries, attached resources, and groups.
Update Schedule
/schedules/{scheduleID}Update schedule name, description, timezone, or cron entries.
curl -X PUT https://zopnight.com/api/schedules/sch_abc123 \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Extended Business Hours",
"timezone": "America/New_York",
"crons": [
{
"cronExpression": "0 7 * * 1-5",
"action": "start"
},
{
"cronExpression": "0 20 * * 1-5",
"action": "stop"
}
]
}'Delete Schedule
/schedules/{scheduleID}Delete a schedule. All resource and group attachments are removed.
Attach Resource
/schedules/{scheduleID}/resources/{resourceID}Attach an individual resource to a schedule.
The resource will be started/stopped according to the schedule's cron entries.
Detach Resource
/schedules/{scheduleID}/resources/{resourceID}Remove a resource from a schedule.
Attach Resource Group
/schedules/{scheduleID}/groups/{groupID}Attach a resource group to a schedule. All resources in the group will follow the schedule.
Group Execution Order
Detach Resource Group
/schedules/{scheduleID}/groups/{groupID}Remove a resource group from a schedule.
Schedule Object
| Field | Type | Description |
|---|---|---|
id | string | Unique schedule ID |
name | string | Schedule display name |
description | string | Optional description |
timezone | string | IANA timezone (e.g., America/New_York) |
crons | CronEntry[] | List of cron entries with actions |
resources | AttachedResource[] | Directly attached resources |
groups | Group[] | Attached resource groups |
createdBy | string | Email of the creator |
createdAt | string | ISO 8601 creation timestamp |
updatedAt | string | ISO 8601 last update timestamp |