Commands
Endpoint: /api/events/commands/
Execute and manage commands on remote servers.
List
List commands
Retrieve a paginated list of commands.
Request
GET /api/events/commands/Query parameters
| Parameter | Type | Description |
|---|---|---|
server | UUID | Filter by server ID (exact) |
shell | string | Filter by shell type (exact) |
requested_by | integer | Filter by requesting user ID (exact) |
requested_by_isnull | boolean | Filter commands with no requester |
is_scheduled | boolean | true for future-scheduled, false for past/immediate |
search | string | Search by server name, command line, or requester name |
ordering | string | Sort field (default: -scheduled_at). Options: added_at, scheduled_at, delivered_at, acked_at, handled_at |
page | integer | Page number |
page_size | integer | Results per page (default: 15, max: 100) |
Response
{
"count": 85,
"next": "https://your-workspace.us1.alpacon.io/api/events/commands/?page=2",
"previous": null,
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"shell": "system",
"line": "df -h",
"success": true,
"result": "Filesystem Size Used Avail Use% Mounted on\n/dev/xvda1 20G 8.5G 11G 46% /",
"status": {
"text": "Success",
"color": "success",
"cancellable": false,
"message": "Finished at 2024-01-15 10:30:45"
},
"response_delay": 0.125,
"elapsed_time": 0.023,
"added_at": "2024-01-15T10:30:44Z",
"server": "7e3984de-49ab-4cc6-bcdf-21fbd35858b8",
"username": "ubuntu",
"groupname": "alpacon",
"requested_by": {
"id": 1,
"username": "admin",
"email": "admin@example.com"
},
"scheduled_at": "2024-01-15T10:30:44Z"
}
]
}Example
curl "https://your-workspace.us1.alpacon.io/api/events/commands/?ordering=-scheduled_at&page_size=20" \
-H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\""Command status lifecycle
Each command progresses through a series of timestamps:
| Field | Description |
|---|---|
added_at | Command created |
scheduled_at | Scheduled execution time |
delivered_at | Sent to the server |
acked_at | Server acknowledged receipt and began execution |
handled_at | Execution completed |
The status object provides a human-readable summary with text, color, cancellable, and message fields.
Error responses
| Status | Error code | Description |
|---|---|---|
| 400 | INVALID_COMMAND | Invalid command |
| 403 | API_TOKEN_ACL_NOT_ALLOWED | Command not allowed by token ACL |
| 404 | COMMAND_NOT_FOUND | Command not found |
| 409 | EVENT_COMMAND_ALREADY_SENT | Cannot cancel (already delivered to server) |
| 503 | SERVER_NOT_CONNECTED | Server is offline |