Commands

Endpoint: /api/events/commands/

Execute and manage commands on remote servers.

List commands

Retrieve a paginated list of commands.

Request

GET /api/events/commands/

Query parameters

ParameterTypeDescription
serverUUIDFilter by server ID (exact)
id__instringFilter by command IDs (comma-separated UUIDs, max 100)
shellstringFilter by shell type (exact)
requested_byintegerFilter by requesting user ID (exact)
requested_by_isnullbooleanFilter commands with no requester
is_scheduledbooleantrue for future-scheduled, false for past/immediate
searchstringSearch by server name, command line, or requester name
orderingstringSort field (default: -scheduled_at). Options: added_at, scheduled_at, delivered_at, acked_at, handled_at
pageintegerPage number
page_sizeintegerResults 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:

FieldDescription
added_atCommand created
scheduled_atScheduled execution time
delivered_atSent to the server
acked_atServer acknowledged receipt and began execution
handled_atExecution completed

The status object provides a human-readable summary with text, color, cancellable, and message fields.

Error responses

StatusError codeDescription
400INVALID_COMMANDInvalid command
400EVENT_COMMAND_BULK_LIMIT_EXCEEDEDMore than 100 command IDs passed to id__in
403API_TOKEN_ACL_NOT_ALLOWEDCommand not allowed by token ACL
404COMMAND_NOT_FOUNDCommand not found
409EVENT_COMMAND_ALREADY_SENTCannot cancel (already delivered to server)
503SERVER_NOT_CONNECTEDServer is offline
Last updated: