Authentication Methods
JWT Token Authentication (Recommended)
JWT tokens are short-lived bearer tokens ideal for user sessions and frontend applications. Tokens expire after a configured period and can be refreshed using a refresh token.API Key Authentication
API keys are long-lived credentials ideal for scripts, automations, and third-party integrations. Each user can generate a personal API key that authenticates requests without exposing account credentials.API keys were added in version 0.20.0. Users can generate and revoke their own keys from the profile page. Admin users can manage keys for any user.
JWT Token Authentication
Obtaining a Token
Request a JWT token pair (access + refresh) using your username and password:Response
Using the Access Token
Include the access token in theAuthorization header with the Bearer prefix:
Refreshing Tokens
Access tokens expire after a configured period. Use the refresh token to obtain a new access token:Response
Alternative Login Endpoint
Dispatcharr also provides a custom login endpoint at/api/accounts/auth/login/ that returns the same token pair:
API Key Authentication
API keys provide a simpler authentication method for scripts and automations without the need to handle token expiration.Generating an API Key
Users can generate their personal API key from the profile page in the Dispatcharr UI. Admin users can generate keys for any user.Each user can have only one active API key. Generating a new key automatically revokes the previous one.
Using API Keys
API keys can be provided in two ways:Method 1: Authorization Header (Recommended)
Use theAuthorization header with the ApiKey prefix:
Method 2: X-API-Key Header
Alternatively, use theX-API-Key header:
Revoking API Keys
API keys can be revoked from the user profile page in the Dispatcharr UI. Revocation is immediate—requests using revoked keys will be rejected.API Key Management (Admin)
Admin users can manage API keys for all users via the accounts API:Authentication Errors
401 Unauthorized
Returned when authentication credentials are missing or invalid:403 Forbidden
Returned when authenticated but lacking required permissions:Testing Authentication in Swagger UI
The interactive Swagger UI at/api/swagger/ supports both authentication methods:
Using JWT Tokens
- Click the Authorize button (lock icon) at the top right
- In the “Bearer” section, enter your JWT token (without the “Bearer ” prefix)
- Click Authorize
- All subsequent requests will include the token automatically
Using API Keys
- Click the Authorize button (lock icon) at the top right
- In the “ApiKey” section, enter your API key
- Click Authorize
- All subsequent requests will include the key automatically
Swagger UI automatically adds the “Bearer ” prefix for JWT tokens and formats API keys correctly, so you only need to paste the raw token or key value.
Best Practices
Example: Token Refresh Logic
Implement automatic token refresh in your application:Accounts API Endpoints
Key authentication-related endpoints:| Endpoint | Method | Description |
|---|---|---|
/api/accounts/token/ | POST | Obtain JWT token pair |
/api/accounts/token/refresh/ | POST | Refresh access token |
/api/accounts/auth/login/ | POST | Alternative login endpoint |
/api/accounts/auth/logout/ | POST | Logout (client-side token removal) |
/api/accounts/api-keys/ | GET | List API keys (admin/own keys) |
/api/accounts/api-keys/ | POST | Generate new API key |
/api/accounts/api-keys/{id}/ | DELETE | Revoke API key |
/api/accounts/users/ | GET | List users (requires permissions) |
/api/accounts/permissions/ | GET | List available permissions |
Next Steps
- Explore the API Overview for available endpoints
- Visit the Interactive API Documentation to test endpoints
- Review endpoint-specific documentation for detailed request/response schemas