Token Format
Tokens must follow this format:lightd_ad2f7fc49ed640429c450e14ed07c8d5
Tokens must be at least 20 characters long (including the lightd_ prefix).
Required Headers
All protected routes require these headers:Token Management CLI
View Current Token
Generate New Random Token
Set Custom Token
Token Storage
Tokens are stored inconfig.json:
Programmatic Token Generation
Generate Token with TTL
15m- 15 minutes1h- 1 hour30s- 30 seconds7d- 7 days
Single-Use Tokens
Setremove_on_use: true to create tokens that expire after first use:
Token Validation
Tokens are validated on every request:- Must start with
lightd_ - Must match token in config.json or exist in token database
- Must not be expired (for programmatic tokens)
- Automatically removed if
remove_on_use: true
Token Cleanup
Expired tokens are automatically cleaned up every 5 minutes by the daemon.Public Routes
These routes don’t require authentication:GET /api/v1/public/ping- Health check
Example Authenticated Request
Security Best Practices
Store tokens securely
Store tokens securely
Use environment variables or secrets managers instead of hardcoding tokens in your application code.
Use short TTLs
Use short TTLs
For temporary access, use short-lived tokens (15m-1h) to minimize security risk.
Rotate master token regularly
Rotate master token regularly
Use
--token reset to generate a new master token periodically.WebSocket authentication
WebSocket authentication
For WebSocket connections, pass the token as a query parameter:
ws://host/ws/:id?token=<token>