Skip to main content
MonoRelay supports two local authentication methods: a simple static access key for single-user or server-to-server deployments, and full user accounts with username and password that each receive a short-lived JWT token.

Access key authentication

The access key is the simplest way to authenticate. Set a key in config.yml under server.access_key, then pass it in every request as either a Bearer token or an X-Access-Key header. No registration or login step is required.
Access key auth is best for automated scripts and internal tooling where you control both ends of the connection. For shared deployments with multiple people, use user accounts instead.
To disable access key authentication entirely and require user accounts, set access_key_enabled: false in config.yml:

User account authentication

User accounts let multiple people access a MonoRelay instance with individual credentials. Each user logs in and receives a JWT token that they include in API requests.

Register an account

Send a POST request to /api/auth/register with a username, email address, and password. The password must be at least 8 characters.
The first user to register automatically becomes a super admin with full administrative privileges.

Log in

Send a POST request to /api/auth/login with your username and password.
The access_token in the response is a JWT that expires after 24 hours (expires_in is in seconds).

Use the token in API requests

Include the token in the Authorization header as a Bearer token on every subsequent request.

Troubleshooting

401 Unauthorized

A 401 Unauthorized response means the request either had no credentials or the credentials were rejected. Common causes:
Tokens expire after 24 hours. Store your credentials securely and re-authenticate when you receive a 401 on a previously working token.