Authentication overview
API authentication
Bearer tokens for programmatic access
Web authentication
Cookie-based sessions for browser access
Obtaining a bearer token
To access protected API endpoints, you must first obtain a bearer token by authenticating with your username and password.Login endpoint
The login endpoint path can be customized in your configuration file under
app.login_endpoint. The default is /api/v1/login.Your username
Your password
Bearer token for authentication (null on error)
Error message if authentication failed (null on success)
400 - Bad request
400 - Bad request
401 - Bad credentials
401 - Bad credentials
Using bearer tokens
Once you have a bearer token, include it in theAuthorization header of your API requests.
Authorization header format
Token validation errors
When making authenticated requests, you may encounter these errors:400 - Missing Authorization header
400 - Missing Authorization header
400 - Invalid Authorization format
400 - Invalid Authorization format
400 - Empty token
400 - Empty token
401 - Bad token
401 - Bad token
401 - User not active
401 - User not active
401 - User not permitted
401 - User not permitted
401 - User not admin
401 - User not admin
Token lifetime
Tokens have a configurable lifetime set in your application’s configuration:There is no token logout or revocation endpoint. To invalidate all tokens before their expiration, the application’s secret key must be changed in the configuration.
Authentication decorators
The API uses several authentication and authorization decorators to protect endpoints:login_api_usr_required
Validates the bearer token and extracts the user ID. Returns 400/401 errors if the token is missing or invalid.Used by: All protected API endpoints
require_api_usr_is_active
Ensures the authenticated user’s account is active. Returns 401 if the user is inactive.Used by: Most moderation and admin endpoints
require_api_usr_permissions
Checks that the user has specific permissions. Admin users automatically pass this check.Used by: Endpoints requiring specific permissions (e.g.,
report_read, user_create)Optional authentication
Some endpoints support optional authentication using theapi_usr_authenticated decorator:
/api/v1/{board}/catalog.json/api/v1/{board}/thread/{thread_id}.json/api/v1/{board}/{page_num}.json
Security configuration
Authentication behavior is configured in the[moderation.auth] section of your config file:
Password security
User passwords are hashed using the scrypt algorithm with a 16-byte salt:Best practices
Store tokens securely
Never expose tokens in URLs, logs, or client-side code
Use HTTPS
Always use HTTPS in production to protect tokens in transit
Rotate tokens regularly
Implement token refresh or re-authentication for long-running applications
Monitor rate limits
Track login attempts to avoid hitting the 3 requests/day limit
Troubleshooting
Rate limit exceeded on login
Rate limit exceeded on login
The login endpoint is limited to 3 requests per day. If you’re locked out:
- Wait 24 hours for the rate limit to reset
- Contact an administrator to adjust the rate limit configuration
- Check your application for authentication retry loops
Token works initially but fails later
Token works initially but fails later
Your token has likely expired. Check the
bearer_duration configuration and implement token refresh logic in your application.Authorization header not recognized
Authorization header not recognized
User has correct permissions but still gets 401
User has correct permissions but still gets 401
Check if the user account is active. Inactive users cannot access protected endpoints even with valid tokens and permissions.
Related resources
API overview
View all available API endpoints
User management
Learn about managing users and permissions