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)
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\""

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
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