Overview
The Scalekit API uses OAuth 2.0 Client Credentials flow for authentication. This flow is designed for server-to-server authentication where your application needs to access the API on its own behalf.Obtain API Credentials
Before you can authenticate, you need to obtain your API credentials from the Scalekit Dashboard:- Log in to the Scalekit Dashboard
- Navigate to API Config section
- Copy your credentials:
- Environment URL
- Client ID
- Client Secret
Set Environment Variables
Store your credentials as environment variables:Request Access Token
Exchange your client credentials for an access token:Token Response
The token endpoint returns an access token that you’ll use for subsequent API requests:The JWT access token to use in API requests. Include this in the Authorization header.
Always
Bearer for OAuth 2.0 Client Credentials flow.Number of seconds until the token expires (typically 86399 seconds / 24 hours).
OAuth scopes granted to this token.
Make Authenticated Requests
Include the access token in the Authorization header for all API requests:Token Management
Token Expiration
Access tokens expire after 24 hours (86399 seconds). The Scalekit SDKs automatically handle token refresh, but if you’re making raw API calls, you’ll need to:- Track token expiration using the
expires_invalue - Request a new token before the current one expires
- Update your Authorization header with the new token
Token Security
Authentication Errors
Common authentication errors and solutions:| Error Code | Error | Solution |
|---|---|---|
| 401 | Token empty | Include the Authorization header with a valid Bearer token |
| 401 | Invalid credentials | Verify your client_id and client_secret are correct |
| 401 | Token expired | Request a new access token |
| 403 | Insufficient permissions | Verify your API credentials have the necessary scopes |
Next Steps
Authorization URL
Generate authorization URLs for SSO flows
Token Exchange
Exchange authorization codes for user tokens