Quick Start: All API requests require authentication via API key in the
Authorization header:Authentication Overview
All data in Stateset is private by default, requiring authentication for every API request. We support multiple authentication methods:Supported Authentication Methods
API Keys
Best for server-to-server communication and backend integrations
JWT Tokens
Ideal for user-specific access and session management
OAuth 2.0
Perfect for third-party integrations and partner access
Webhook Signatures
Secure webhook delivery with HMAC signatures
API Key Authentication
Key Types and Permissions
Creating API Keys
- Navigate to Settings → API Keys in your dashboard
- Click Create New Key
- Select key type and permissions
- Copy and securely store your key
Using API Keys
Restricted API Keys
Create keys with specific permissions for enhanced security: Create the key from the StateSet Dashboard and select only the permissions it needs — for exampleorders:read and customers:read for a read-only integration — along with an expiry date.
JS SDK support for programmatic API-key management has not shipped yet.
JWT Token Authentication
JWT tokens provide secure, stateless authentication for user sessions.JWT Token Structure
GraphQL API Authentication
GraphQL Endpoint Access
Stateset GraphQL API requires authentication via HTTP headers:GraphQL Request Example
OAuth 2.0 Authentication
For third-party integrations and partner access, we support OAuth 2.0:OAuth Flow
1
Authorization Request
2
Token Exchange
3
Use Access Token
Available Scopes
Role-Based Access Control (RBAC)
User Roles and Permissions
Stateset implements fine-grained permissions using role-based access control:Permission Matrix
Custom Permissions with Session Variables
Implement fine-grained access control using session variables:JWT Claims Structure
Permission Checks
Webhook Authentication
Webhook Signature Verification
All webhooks from Stateset are signed for security:Security Best Practices
API Key Security
API Key Security
- Store keys in environment variables, never in code
- Use different keys for different environments
- Rotate keys regularly (every 90 days recommended)
- Use restricted keys with minimal permissions
- Monitor key usage for anomalies
Token Management
Token Management
- Implement short token lifetimes (15-30 minutes)
- Use refresh tokens for long-lived sessions
- Store tokens securely (httpOnly cookies)
- Implement token revocation
- Log all authentication events
Network Security
Network Security
- Always use HTTPS for API calls
- Implement IP allowlisting for production
- Use VPN or private networks when possible
- Enable CORS with specific origins
- Implement rate limiting per API key
Authentication Examples
React Hook with Authentication
Python Authentication Manager
Troubleshooting Authentication
Common Issues and Solutions
Debug Authentication
Next Steps: Create your first API request →