Actions & Execution
Actions are start/stop operations executed against cloud resources — either triggered automatically by schedules or manually through the API.
How Execution Works
- An action intent is created (by scheduler or manual API call)
- The intent is queued in Redis for processing
- The executor picks up the intent and calls the cloud provider API
- The result (success/failure) is recorded as an execution log
- State transitions are tracked in the state history
Idempotent Actions
All start/stop operations are idempotent. Starting an already-running resource or stopping an already-stopped resource will succeed without error. This makes retries safe.
Action Statuses
| Status | Description |
|---|---|
pending | Action is queued, waiting to be processed |
running | Action is being executed against the cloud provider |
succeeded | Action completed successfully |
failed | Action failed — check errorMessage for details |
Manual Action
Trigger a start or stop action on a specific resource outside of any schedule.
POST
/actionsSubmit a manual start or stop action.
Requestbash
curl -X POST https://zopnight.com/api/actions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"type": "stop",
"resourceUID": "i-0abc123def456",
"provider": "aws",
"resourceType": "aws-ec2",
"cloudAccountID": "ca_abc123",
"region": "us-east-1"
}'Responsejson
{
"data": {
"actionID": "act_xyz789",
"status": "queued"
}
}Bulk Action
Start or stop all resources in a resource group with a single request. Resources are processed according to their execution tier and order.
POST
/actions/bulkSubmit a bulk action for a resource group.
Requestbash
curl -X POST https://zopnight.com/api/actions/bulk \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"type": "start",
"groupID": "grp_abc123"
}'Responsejson
{
"data": {
"bulkActionID": "bulk_xyz789",
"status": "queued",
"total": 4
}
}Get Action Status
GET
/actions/{actionID}Check the status of a submitted action.
Responsejson
{
"data": {
"id": "act_xyz789",
"resourceUID": "i-0abc123def456",
"provider": "aws",
"cloudAccountID": "ca_abc123",
"region": "us-east-1",
"action": "stop",
"reason": "manual",
"status": "succeeded",
"startedAt": "2025-01-20T10:00:05Z",
"completedAt": "2025-01-20T10:00:12Z",
"createdAt": "2025-01-20T10:00:00Z"
}
}Get Bulk Action Status
GET
/actions/bulk/{bulkActionID}Check the status of a bulk action.
Responsejson
{
"data": {
"id": "bulk_xyz789",
"groupID": "grp_abc123",
"type": "start",
"status": "completed",
"total": 4,
"completed": 4,
"failed": 0,
"createdAt": "2025-01-20T10:00:00Z"
}
}State History
Query the state transition history for resources. This provides an audit trail of when resources were started or stopped and why.
GET
/state-historyGet resource state transition history with pagination.
Query Parameters
| Parameter | Description |
|---|---|
resourceUID | Filter by specific resource |
page | Page number |
limit | Items per page |
Responsejson
{
"data": [
{
"id": "sh_001",
"resourceUID": "i-0abc123def456",
"state": "stopped",
"changedAt": "2025-01-20T18:00:00Z",
"changedBy": "schedule:sch_abc123"
},
{
"id": "sh_002",
"resourceUID": "i-0abc123def456",
"state": "started",
"changedAt": "2025-01-21T08:00:00Z",
"changedBy": "schedule:sch_abc123"
}
]
}changedBy Values
schedule:sch_...— triggered by a schedulemanual— manually triggered via API or UIoverride:ovr_...— triggered by an override