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
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 thescopes 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:Creating Session Tokens
API Endpoint
Create session tokens via thePOST /sessions endpoint:
- TypeScript
- Python
- cURL
Common Use Cases
Read-only access to all tools
Read-only access to all tools
Access to specific accounts only
Access to specific accounts only
Allow reads, deny writes
Allow reads, deny writes