Authentication Methods
The API supports two types of authentication:- OAuth2 Login Sessions - For web applications and interactive use
- API Tokens - For programmatic access and automation
OAuth2 Flow
Creating an OAuth2 Session
To authenticate a user via Discord OAuth2, you’ll need to:- Direct users to Discord’s OAuth2 authorization URL with the
identifyandguildsscopes - Handle the OAuth2 callback with the authorization code
- Exchange the code for a session token
POST /oauth2
The OAuth2 authorization code from Discord
The redirect URI used in the OAuth2 flow. Must be in the allowed redirects list.
Optional PKCE code verifier for enhanced security (required for app logins)
The Discord user ID
The session token to use for API authentication
The unique session identifier (UUID)
ISO 8601 timestamp when the session expires
Partial user information (only returned on OAuth2 login)
Session Types
- login: Standard web login session (1 hour expiry)
- app_login: Application login with PKCE (14 days expiry)
- api: API token with custom expiry
API Tokens
API tokens provide long-lived authentication for programmatic access.Creating an API Token
You must have an existing authenticated session to create API tokens.Create API Token
POST /sessions
A descriptive name for the API token
Must be “api” (only API tokens can be created via this endpoint)
Expiry time in seconds (must be between 0 and 9223372036854775)
Using Authentication
Once you have a session token or API token, include it in theAuthorization header:
Authenticated Request
Get Current Session
Retrieve information about your authenticated session: Endpoint:GET /sessions/@me
Get Session Info
The authenticated user’s Discord ID
The session ID
User state (e.g., “normal”, “banned”)
Session type (“login”, “app_login”, or “api”)
Security Notes
Error Handling
Authentication errors return appropriate HTTP status codes:- 401 Unauthorized: Missing or invalid authentication token
- 403 Forbidden: User is banned or lacks required permissions
- 400 Bad Request: Invalid request format or parameters