Skip to main content
Quick Start: All API requests require authentication via API key in the Authorization header:
Stateset provides multiple authentication methods to secure your API access, including API keys, JWT tokens, and OAuth 2.0 for different use cases.

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

  1. Navigate to Settings → API Keys in your dashboard
  2. Click Create New Key
  3. Select key type and permissions
  4. Copy and securely store your key
API keys are shown only once. Store them securely and never expose secret keys in client-side code.

Using API Keys

Restricted API Keys

Create keys with specific permissions for enhanced security:

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

  • 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
  • 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
  • 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 →