Skip to main content
Rancher API uses token-based authentication to secure API access. All API requests must include a valid authentication token.

Authentication Methods

Bearer Token Authentication

The primary authentication method uses bearer tokens in the Authorization header:

Basic Authentication

Basic authentication can be used for initial token generation:

Token Types

Rancher supports multiple token types for different use cases.

User Tokens

User tokens are associated with a specific user account:
string
required
The ID of the user who owns this token
string
required
Authentication provider (local, github, activedirectory, etc.)
integer
Token TTL in milliseconds. 0 means never expires
boolean
default:"true"
Whether the token is enabled and can be used
string
Human-readable description of the token’s purpose

Service Account Tokens

Service account tokens are used for automated workflows:
string
required
Name of the service account
string
UID of the service account
string
The actual token value (only returned on creation)

Creating API Tokens

Create User Token via UI

  1. Navigate to User Settings > API & Keys
  2. Click Add Key
  3. Set description and expiration
  4. Save the token securely (shown only once)

Create Token via API

Response

string
The authentication token value. Save this securely - it won’t be shown again.
string
Unique identifier for the token
string
ID of the user who owns this token
string
ISO 8601 timestamp when the token expires
object
Principal information for the token owner

Token Management

List Tokens

Retrieve all tokens for the authenticated user:

Delete Token

Revoke a token:

Update Token

Modify token properties (description, enabled status):

Token Security Best Practices

Set appropriate TTL values for automated workflows. Tokens for CI/CD should expire after the pipeline completes.
Implement token rotation policies, especially for long-lived service accounts.
Use cluster-scoped tokens when possible instead of global admin tokens.
Never commit tokens to version control. Use secret management systems like:
  • Kubernetes Secrets
  • HashiCorp Vault
  • Cloud provider secret managers
Track token activity via audit logs to detect suspicious behavior.

Token Attributes

Token Object Schema

From pkg/apis/management.cattle.io/v3/authn_types.go:30:
string
The actual token value (write-only, only returned on creation)
Principal
Principal representing the authenticated user
array<Principal>
List of group principals the user belongs to
map<string, string>
Additional information from the authentication provider
string
Reference to the user who owns this token
string
Authentication provider (local, github, ldap, etc.)
integer
Time to live in milliseconds. 0 means never expires.
timestamp
Last time the token was used for authentication
boolean
Whether this is a derived token (created automatically)
string
Human-readable description of the token
boolean
Whether the token has expired
string
Cluster scope for cluster-scoped tokens
boolean
default:"true"
Whether the token is active and can be used

API Access Patterns

Cluster-Scoped Access

Create tokens scoped to specific clusters:

Project-Scoped Access

Access resources within a specific project using project membership and RBAC:

Global Access

Global admin tokens can access all resources:
Limit the use of global admin tokens. Use scoped tokens wherever possible.

Troubleshooting Authentication

Common Issues

  • Token may have expired
  • Token may be disabled
  • Authorization header may be malformed
  • Check token format: Bearer token-xxxxx:xxxxxxxxxxxxxxxx
  • User lacks permissions for the requested resource
  • Check RBAC roles and bindings
  • Verify cluster/project membership
  • Allow a few seconds for token propagation
  • Verify the token was copied correctly
  • Check that enabled field is true

Next Steps

Cluster Management

Use your token to manage clusters

RBAC

Learn about role-based access control