Skip to main content
Session tokens provide temporary, policy-restricted access to StackOne APIs without exposing your API keys in frontend code or external systems.

Overview

Session tokens let you:
  • Restrict API access - Define exactly which endpoints and operations the token can access
  • Secure frontend integrations - Use tokens in client-side code without exposing API keys
  • Scope by account - Limit tokens to specific linked accounts or providers
  • Control duration - Set expiration times for token validity
Generate session tokens server-side using your API key, then pass them to frontend code, webhooks, or third-party systems.

How Session Tokens Work

1

Create token server-side

Your backend calls the StackOne API with your API key and a policy definition
2

Receive scoped token

StackOne returns a session token restricted by your policy
3

Use token in restricted context

Pass the token to frontend code, webhooks, or external systems where API keys shouldn’t be exposed
4

Token enforces policy

The session token only allows the operations defined in your policy

Policy-Based Restrictions

Session tokens use the scopes field to define granular access control policies. Each permission rule uses glob patterns to match resources.

Permission Structure

Permission Fields

Each permission rule must specify exactly one of: tools, operation, or accounts. All rules are deny-by-default - you must explicitly allow access.

Glob Pattern Examples

Session Configuration

Additional fields control session behavior:
Policies are defined when creating the session token. Once created, a token’s permissions cannot be expanded - you must generate a new token with broader permissions.

Creating Session Tokens

API Endpoint

Create session tokens via the POST /sessions endpoint:

Common Use Cases

Using Session Tokens

After creating a session token, use it in place of your API key for authentication:
Session tokens use Bearer authentication (Authorization: Bearer TOKEN) while API keys use Basic authentication. This makes them easy to identify and rotate independently.

Managing Session Tokens

List Sessions

Retrieve all active session tokens:

Get Session Details

Retrieve information about a specific session:

Update Session Permissions

Modify the scopes of an existing session:

Revoke Session

Immediately invalidate a session token:
Revoking a session immediately invalidates the token. Any API calls using that token will fail with a 401 error.

Customizing the Hub Behavior