API tokens

Endpoint: /api/auth/tokens/

Manage API tokens for programmatic access to the Alpacon API. Each token is scoped to the authenticated user and can be restricted with fine-grained permission scopes.

API tokens cannot be used to manage other API tokens. Only session-based (login) authentication can create, update, or delete tokens.

List API tokens

Retrieve a paginated list of API tokens for the authenticated user.

Request

GET /api/auth/tokens/

Query parameters

ParameterTypeDescription
namestringFilter by exact token name
enabledbooleanFilter by enabled status
remote_ipstringFilter by exact remote IP address
searchstringSearch across name, user_agent, and remote_ip
orderingstringSort order (added_at, updated_at, -updated_at). Default: -updated_at
pageintegerPage number
page_sizeintegerResults per page (default: 15, max: 100)

Response

{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "CI/CD pipeline",
      "enabled": true,
      "scopes": ["server:*", "event:*"],
      "updated_at": "2025-01-15T10:30:00Z",
      "expires_at": "2025-12-31T23:59:59Z"
    },
    {
      "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
      "name": "Monitoring",
      "enabled": true,
      "scopes": ["*"],
      "updated_at": "2025-01-10T08:00:00Z",
      "expires_at": null
    }
  ]
}

Example

curl -X GET "https://your-workspace.us1.alpacon.io/api/auth/tokens/?enabled=true" \
  -H "Authorization: token=\"alpat-xxxxxxxxxxxxxxxxxx\""

Error responses

StatusError codeDescription
400INVALID_REQUESTInvalid parameters
401UNAUTHORIZEDNot authenticated
404NOT_FOUNDToken not found
409API_TOKEN_EXISTSToken name already exists (unique per user)