Overview
All API endpoints require authentication via one of two methods:- API Key Authentication - Bearer token for programmatic access
- JWT Authentication - Session-based authentication for web dashboard
Authentication Methods
API Key Authentication
Use theDUCKLING_API_KEY environment variable to authenticate API requests.
Header Format:
The API key is set via the
DUCKLING_API_KEY environment variable in your deployment configuration.JWT Authentication (Web Dashboard)
For web-based authentication, obtain a JWT token by logging in.POST /api/login
Obtain a JWT token for authenticated sessions.Admin username (configured via
ADMIN_USERNAME environment variable)Admin password (configured via
ADMIN_PASSWORD environment variable)JWT token to use in subsequent requests
Token expiration duration (default: 7 days)
GET /api/check-auth
Verify authentication status and token validity. Request Example:POST /api/logout
Logout endpoint for session cleanup (JWT is stateless, so client must discard token). Request Example:Authentication Headers
Once authenticated, include the token in all subsequent requests: Using API Key:Public Endpoints
The following endpoints do not require authentication:POST /api/login- Login endpointGET /api/check-auth- Check authentication statusGET /openapi.json- OpenAPI specification
Protected Endpoints
All other endpoints require authentication, including:- Health & monitoring endpoints (
/health,/status,/metrics) - Synchronization endpoints (
/sync/*) - Data access endpoints (
/api/query,/api/tables/*) - Database management endpoints (
/api/databases/*) - Automation endpoints (
/automation/*)
Error Responses
401 Unauthorized
Missing or invalid authentication credentials
403 Forbidden
Valid authentication but insufficient permissions
Security Best Practices
- Use HTTPS in production - Never send credentials over unencrypted HTTP
- Rotate API keys regularly - Update the
DUCKLING_API_KEYenvironment variable periodically - Set strong admin passwords - Use complex passwords for
ADMIN_PASSWORD - Monitor authentication attempts - Review logs for suspicious activity
- Use short-lived tokens - JWT tokens expire after 7 days by default
Environment Variables
Configure authentication via environment variables:If
DUCKLING_API_KEY is not set, API key authentication will be disabled. JWT authentication via login is always available.