microsrv:~$
Console

Personal Access Tokens (PAT)

Creating and managing Personal Access Tokens (PAT) for OpenTofu, Terraform, REST API, and CI/CD automation.

What are Personal Access Tokens (PAT)?

Personal Access Tokens (PAT) are secret authentication credentials designed for programmatic interaction with the microsrv cloud platform.

Tokens are used for:

  • Infrastructure as Code with OpenTofu and Terraform (using the official provider microsrv-cloud/microsrv).
  • Automated continuous delivery pipelines (CI/CD: GitHub Actions, GitLab CI, Woodpecker CI).
  • Direct REST API calls and CLI scripting via microsrvctl.

All tokens begin with the sel_ prefix and operate with the permissions of your user account across your current and newly created projects.


Step-by-Step: Generating a Token in the Console

Step 1. Navigate to Access Tokens

  1. Sign in to the microsrv Console.
  2. In the navigation sidebar under Access, select Access Tokens (or browse directly to /access-tokens).

Step 2. Create a New Token

  1. On the tokens overview page, click Create Token (top right or directly at /access-tokens/create).
  2. Fill in the token parameters:
    • Token Name: Provide a descriptive purpose (for example, opentofu-production, github-actions-deploy, or local-workstation). This label helps you track where credentials are deployed.
    • Expires in (days): Specify the token lifetime:
      • 0 — never expires (indefinite).
      • From 1 to 3650 days — time-bound token with automatic expiry. Regular token rotation (e.g. 90 or 180 days) is strongly recommended for CI/CD environments.
  3. Click Create Token.

Step 3. Securely Save the Token

Once generated, the secret plaintext value is revealed:

[!WARNING] The plaintext token value is shown exactly once upon creation! It cannot be retrieved or viewed again after leaving this page.

  1. Click Copy Token.
  2. Store the token immediately in a secure password manager, CI/CD secret manager, or encrypted credential store.
  3. Click Done to return to the tokens list.

Using Your Token

Environment Variable for OpenTofu / Terraform

For seamless integration with OpenTofu and Terraform, set the MICROSRV_TOKEN environment variable in your terminal session or CI runner:

export MICROSRV_TOKEN="sel_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

The microsrv provider automatically reads this environment variable during tofu plan and tofu apply.

Provider Configuration Block

You can also pass the token explicitly via the token argument in your HCL provider block:

provider "microsrv" {
  endpoint = "https://api.microsrv.ru"
  token    = var.microsrv_token
}

[!IMPORTANT] Never commit plaintext access tokens to Git repositories. Always supply credentials via environment variables (MICROSRV_TOKEN) or encrypted variables.

REST API Calls

For direct REST API requests, pass the token in the standard Authorization header:

curl -H "Authorization: Bearer sel_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     https://api.microsrv.ru/api/v1/projects

Revocation and Rotation

If a token is compromised or no longer required:

  1. Open Console -> Access Tokens.
  2. Locate the token by its label, creation timestamp, or prefix.
  3. Click Revoke and confirm the dialog.
  4. Any requests using the revoked token are rejected immediately.

Next Steps