Service tokens

Issue a service token to an application for Alpacon API access.

Token controls

A service token is a credential issued to an application so it can authenticate to the Alpacon API. You can restrict its scopes, IP addresses, request rate, and access hours. Every change is audited.

Create and manage tokens from the application’s Tokens tab.

Issue a token

Before issuing a token, give the application a global role that covers the required scopes. For commands, assign the application an existing server account, or set its default account and have Alpacon create it on first use; see Provisioning. Alpacon creates the account on a Linux server with a current agent. The token can run only as an account the application owns, never as root. See the service-token setup guide for the account and role steps.

Select Create token on the application’s Tokens tab, or New token on the Applications list and pick the application there. Creating a token takes up to four steps. The Access rules step appears only when the permissions reach servers, commands, or files.

  1. Purpose: confirm the Application, which is already filled in when you start from its tab. Set the token’s Name, an optional description, and when it Expires. Choose 30 days, 90 days, 365 days, or Custom for a specific time; the default is 30 days. The workspace’s maximum lifetime for personal and registration tokens does not apply to service tokens.
  2. Permissions: start from an Access template that matches the job, such as a deploy pipeline or a read-only observer, then add or remove permissions. To start from scratch, choose Pick permissions yourself. You can pick only permissions the application’s roles allow. See the scopes reference.
  3. Access rules: choose the servers the token may reach, and optionally narrow the commands and file paths it may use. These rules are prepared now and applied after the token is created; see Apply prepared access rules.
  4. Review: check every choice and whether the token works right away or waits for approval. When approval needs a reason, fill in Reason for the approver. Then select Create token.

On the step before Review, Restrictions (optional) holds:

  • IP whitelist: allowed IP addresses or CIDR ranges.
  • Rate limit: requests per time unit, such as 1,000 per hour. Leaving it unset uses 1000/hour.
  • Allowed hours and Allowed days: enter the hours in your display time zone; they are stored in UTC.

One-time key

The key appears once, right after you create the token, including when the token still needs approval. It starts with alpst- and is hidden until you select Show. Use Copy or Download to put it into secure storage, then check I’ve stored the key somewhere safe to close the dialog. A pending key cannot authenticate. If you lose the key, ask someone with rotation permission to rotate the token after it is approved.

Apply prepared access rules

A token takes access rules only while it is active, not while it awaits approval or is disabled. The rules from the Access rules step wait under Prepared access rules on the token’s Access rules tab. Once the token is active, right away or after approval, open that tab and select Apply. Prepared rules are kept only in the browser you created the token in, for 7 days; apply them from that browser, or add the rules by hand.

Risk and approval

A token is active at once only when an account with the admin role requests low-risk scopes from the web console. Every other request waits for approval in the web console. Command and file-transfer scopes always wait. Medium- and high-risk requests require a reason.

A Superuser or an approver for the request can approve it in Approvals. The requester may approve unless an approval policy forbids it. A request expires after 7 days. The API returns 201 for immediate activation and 202 for a pending request; the pending response includes the key and approval_request_id. Before using the key, confirm activation_state: "active" and enabled: true on the service-token detail API.

Changes to scopes, expiry, rotation policy, IP restrictions, rate limit, allowed hours or days, and re-enabling a token always wait for approval, including changes submitted by an admin in the web console. Existing values remain in effect until approval. A reason is required when the resulting scopes are medium or high risk. Changes to the name and description apply immediately.

Token detail

  • Overview: what the token can do, its status, expiry, usage, and recent changes.
  • Access rules: allowed servers, commands, and file operations, and any prepared rules waiting to be applied. Add rules once the token is active.
  • Security: IP, rate, and time restrictions, plus emergency access. Changes are audited and follow the approval rules above.
  • History: every change to the token, including creation, activation, changes, rotation, disabling, deletion, and emergency access.
  • Activity: API calls made with the token.

On Alpacon Cloud, add commands under Pre-approved commands on the Access rules tab. This requires membership in Command ACL admins, separate from the workspace role, even for a Superuser. Ask a member for access if the card is restricted. Choose Connect if the console asks to connect. Command ACL writes through the API are refused with 405 command_acl_moved. See the ACL reference.

Rotate, disable, and expire

Rotation needs no approval. It replaces the key immediately, so update the CI secret in the same step. There is no overlap when both keys work. Rotation resets expiry to the current time plus the rotation policy: 30, 90, 180, or 365 days, with a default of 90 days. The new expiry can be earlier than the old one.

Rotating requires service_token:rotate and permission to manage the token; your global roles must also cover its stored scopes. Being the application’s maintainer alone does not grant rotation permission. Pending and disabled tokens cannot be rotated. A service token cannot rotate itself. See the rotation API.

Disabling takes effect immediately. Re-enabling needs approval. Expiry warnings arrive 7 days and 1 day before expiry; an expired token stops authenticating and is deleted 7 days later. Check the expiry and replace the key before a scheduled job needs it.

What a token can access

Use a service token for non-interactive commands through alpacon exec or the commands API, and for file uploads and downloads through the file-transfer commands. These operations need the matching scopes and access rules, but no work session.

A service token cannot:

  • Open, join, share, or invite someone to an interactive Websh session.
  • Open or reconnect a tunnel or browser editor, or open interactive WebFTP or Kubernetes sessions. These operations return 403 auth_interactive_channel_requires_presence.
  • Manage service tokens, personal API tokens, login sessions, token history, or ACL rules, including its own credentials and rules. These management routes return 403 permission_denied.
  • Create a work session or read its target-account choices (400 work_session_principal_not_supported), or approve or reject requests (403).
  • Use the users or applications management API (401).
  • Run as root or another account the application does not own.

Sign in as a person for interactive work and administration. Requesting an explicit interactive scope while issuing a service token returns 400 service_token_scope_not_mintable; a wildcard does not grant interactive access either.

Privileged commands

On Alpacon Cloud, service-token sudo is allowed below Critical, including unassessed commands, and refused at Critical unless the workspace is Advisory. In Advisory, it is not refused for risk at any level, and the decision is recorded. Outside Advisory, a workspace token_exec rule can tighten the risk threshold. The workspace sudo setting must be on; otherwise sudo is refused with workspace_sudo_with_mfa_disabled. Sudo does not wait for a human reviewer, and sudo policies never apply to a service token. Automatic elevation is recorded in Privilege elevation against the application.

On a default self-hosted installation, every service-token sudo attempt is refused with sudo_command_not_authorized. Use a signed-in user’s authorized workflow for privileged work there.

The command rule must match the line submitted, including its sudo prefix. On Cloud, use the token’s pre-approved commands. Read Token command matching when configuring access, and keep entries as narrow as the job permits.

Break-glass (emergency access)

Emergency access in the Security tab temporarily lifts the token’s IP and time restrictions. Rate limits and access-control rules still apply. Only Superusers can activate it, for 1–8 hours, with a reason; the default duration is 4 hours. Deactivating it restores the restrictions immediately. Both actions are audited.

Last updated: