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) |
id__in | string | Filter by command IDs (comma-separated UUIDs, max 100) |
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\""Bulk status lookup
When tracking many commands at once (for example, a dashboard or automation polling for results), pass a comma-separated list of command IDs to id__in instead of issuing one GET /api/events/commands/{command_id}/ per command. Set page_size=100 as well: the default page size is 15, so without it a request for more than 15 IDs returns only the first page and a next link rather than every result.
curl "https://your-workspace.us1.alpacon.io/api/events/commands/?id__in=550e8400-e29b-41d4-a716-446655440000,9b52a7c4-13de-48f6-a01b-7f3e5d982c44&page_size=100" \
-H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\""Up to 100 IDs can be requested at once; exceeding this limit returns 400 with EVENT_COMMAND_BULK_LIMIT_EXCEEDED, and any value that is not a valid UUID returns 400. An empty id__in value is ignored: the request behaves as if the parameter were omitted and returns the full accessible list. Results follow the ordering parameter (default: -scheduled_at), not the order of the IDs in the request, so match each result to your list by its id field. IDs for commands you cannot access or that no longer exist are silently excluded; compare the response count with the number of unique IDs you requested to detect exclusions.
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 |
| 400 | EVENT_COMMAND_BULK_LIMIT_EXCEEDED | More than 100 command IDs passed to id__in |
| 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 |