Overview
listmonk uses HTTP Basic Authentication for API requests. All API endpoints (except public endpoints) require authentication with a valid username and password.Authentication Methods
Session-Based (Web UI)
The web dashboard uses session-based authentication with cookies. After logging in through the web interface, your session is maintained for subsequent requests.HTTP Basic Auth (API)
For programmatic API access, use HTTP Basic Authentication with your listmonk username and password. Format:username:password encoded in Base64 in the Authorization header.
Making Authenticated Requests
Using cURL
The simplest way to authenticate with cURL is using the-u flag:
Using Different Languages
- Python
- Node.js
- Go
- PHP
User Types
listmonk supports two types of users, defined in the database schema:Regular Users
- Type:
user - Purpose: Human users who log in to the web dashboard
- Features: Can have 2FA enabled, full dashboard access
- Status: Can be
enabledordisabled
API Users
- Type:
api - Purpose: Programmatic API access without 2FA
- Features: Designed for machine-to-machine communication
- Status: Can be
enabledordisabled
Creating Users
Initial Admin User
On first installation, you’ll create a super admin user through the setup wizard athttp://localhost:9000/admin.
Adding Users via API
Create additional users with the users API:Creating API Users
For programmatic access without 2FA:Role-Based Access Control
listmonk implements fine-grained permissions through roles. Each user is assigned a role that defines which API endpoints and features they can access.Permission Format
Permissions follow the pattern:resource:action
Examples:
subscribers:get- View subscriberssubscribers:manage- Create, update, delete subscriberscampaigns:get- View campaignscampaigns:manage- Create, update campaignssettings:manage- Modify system settings
Checking User Permissions
Get the current user’s profile and permissions:A role with
["*"] in permissions has full access to all resources.OIDC Authentication
listmonk supports OpenID Connect (OIDC) for single sign-on with providers like Google, Azure AD, Okta, and Keycloak.Configuration
Configure OIDC in yourconfig.toml:
OIDC Login Flow
- User clicks “Login with OIDC” on the login page
- Redirected to OIDC provider for authentication
- After successful authentication, redirected back to listmonk
- If
auto_create_usersis enabled, a new user account is created automatically - User is logged in with assigned default role
Provider Setup Examples
Google OIDC
Google OIDC
- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Set authorized redirect URI:
http://your-listmonk/api/auth/oidc/callback - Use these settings:
Azure AD OIDC
Azure AD OIDC
- Register an application in Azure AD
- Set redirect URI:
http://your-listmonk/api/auth/oidc/callback - Use these settings:
Two-Factor Authentication (2FA)
Regular users can enable TOTP-based 2FA for enhanced security.Enabling 2FA
- Log in to the dashboard
- Navigate to Settings → Profile
- Click Enable Two-Factor Authentication
- Scan the QR code with an authenticator app (Google Authenticator, Authy, etc.)
- Enter the verification code to confirm
2FA Login Flow
When 2FA is enabled:- Enter username and password
- Enter the 6-digit TOTP code from your authenticator app
- Successfully logged in
Security Best Practices
Use Strong Passwords
Generate long, random passwords for API users. Consider using a password manager or secrets vault.
Rotate Credentials
Regularly rotate passwords, especially for API users and after team member departures.
Limit Permissions
Assign roles with minimum required permissions. Avoid giving all users admin access.
Use HTTPS
Always use HTTPS in production to encrypt credentials in transit. Never send credentials over plain HTTP.
Separate API Users
Create dedicated API users for each integration rather than sharing credentials.
Enable 2FA
Require 2FA for all regular users with administrative access.
Troubleshooting
401 Unauthorized
Problem: API returns 401 Unauthorized Solutions:- Verify username and password are correct
- Check that the user account is enabled (status:
enabled) - Ensure credentials are properly encoded in Base64
- For API users, ensure type is set to
apiif 2FA is required for regular users
403 Forbidden
Problem: API returns 403 Forbidden Solutions:- User authenticated but lacks permission for the requested resource
- Check the user’s role and permissions
- Verify the role has the required permission (e.g.,
subscribers:manage) - Super admin role with
["*"]permission has access to all resources
OIDC Login Fails
Problem: OIDC authentication redirects fail Solutions:- Verify
provider_urlis correct and accessible - Check that redirect URI is registered with the OIDC provider
- Ensure
client_idandclient_secretare correct - Check listmonk logs for detailed error messages
Next Steps
API Overview
Learn about response formats and pagination
Manage Subscribers
Start using the Subscribers API