Delivery channels for any second factor
By the end you can
- Describe a delivery channel as one HTTP request you define, or an email through the server's mail settings
- Build a channel with placeholders, credentials and a success check
- Preview and test a channel without risk, and read its last result
- Set an ordered failover list per user type, and route device-login codes through channels
Why channels exist
Every deployment sends second-factor messages differently: one uses an SMS gateway with a URL, another WhatsApp Cloud API, another Telegram or Slack. Authcha does not keep a list of supported providers to wait for. A delivery channel is one HTTP request that you describe, so any service with an HTTP API works. A message can be a one-time code, a passkey approval link or an enrollment link.
Open Integrations → Delivery Channels. With no channel defined, nothing changes: codes still go through OTP Delivery, the WhatsApp and SMS service that ships with Authcha. A channel takes over only when you add one.
Build a channel
- Add channel, then pick a starting point (Twilio SMS, Twilio WhatsApp, WhatsApp Cloud API, Telegram bot, Slack webhook, generic webhook, an SMS gateway that takes a URL, an email API) or Custom API. A preset only fills in the form. Every field stays editable.
- Fill in the credentials. They are stored encrypted and are never shown again. They need
PKI_KEY_ENCRYPTION_KEYin.env, and without it the console refuses to store a credential. - Save, then Test.
What you describe
| Field | Meaning |
|---|---|
| Method and URL | POST for most providers, GET for gateways that take everything in the URL. Host and port are fixed. Placeholders may appear in the path and query |
| Headers | Any header you need. The caller sets Host and Content-Length itself |
| Query values | Added to the URL and escaped for you |
| Sign in with | Nothing, a bearer token, or basic (user and password) |
| Body | None, JSON, form fields or plain text |
| Who it is sent to | Which detail of the user it needs: mobile number, email, linked chat, user name, or none for a shared destination such as a Slack channel. A user without that detail is skipped, and the next channel is tried |
| OK from HTTP ... to ... | The status range that means "accepted". Default 200 to 299 |
| Response field | A JSON Pointer such as /ok and the value it must have. For providers that answer 200 even on refusal (Telegram answers {"ok": false}) |
| Timeout and retries | 1 to 30 seconds, and up to 3 more attempts after a network error, HTTP 429 or a 5xx. Other failures are not retried |
| Certificate authority | Optional PEM. When set, only that authority is trusted for this destination |
Placeholders
Write {{name}} where a value goes. Single braces are plain text, so a JSON body needs no escaping.
| Placeholder | Value |
|---|---|
{{message}} | The finished text: "Your sign-in code is 482913. Valid for 5 minutes." |
{{otp}}, {{code}}, {{link}}, {{purpose}}, {{expiry}} | The parts of the message |
{{mobile}}, {{email}}, {{chat_id}}, {{username}} | The recipient |
{{kind}} | otp, link, enroll or test |
{{secret.NAME}} | A credential you stored. Add the base64 filter after the name to get the same value base64 encoded (used for basic-auth style headers) |
Every value is escaped for the place it lands: JSON string content in a JSON body, URL-encoded in a form body or query, and a control character is refused in a header. A user name or purpose line therefore cannot add a field, end a string or inject a header. Settings are checked when you save: an unknown placeholder, JSON that is not valid once filled in, or a missing credential is refused with the reason.
Examples
- Telegram:
POST https://api.telegram.org/bot{{secret.token}}/sendMessage, body{"chat_id":"{{chat_id}}","text":"{{message}}"}, recipient linked chat, response field/okequal totrue. - An SMS gateway that wants everything in the URL: method
GET, URLhttps://sms.example.com/api/send, query valuesapikey={{secret.key}},to={{mobile}},text={{message}}, body none. - Slack:
POST https://hooks.slack.com/services/{{secret.path}}, body{"text":"{{username}}: {{message}}"}, recipient none. - Email through this server's mail settings: choose that option under How it is sent. There is no request to describe: the message goes to the user's email address through the mail server set under Integrations → Email.
Safety rules that always apply
- Plain HTTP is off by default. An on-premises gateway that speaks only HTTP needs Allow plain HTTP (not encrypted) on that channel, and the console then shows an Unencrypted HTTP label on it at all times.
- The address of this server and link-local addresses (including cloud metadata) are always refused, and redirects are never followed.
- Error text never contains the URL or a credential.
Test before you rely on it
Test opens a dialog for a recipient. Preview request shows the exact request that would be sent, with credentials hidden, and sends nothing. Send test delivers a real message and reports what the provider answered. The channel's last result (sent or failed, and why) shows on its card.
Who gets which channel, and failover
Under Who gets which channel, each user type has an ordered list. A message tries the channels top to bottom and stops at the first that accepts it. A channel is skipped, not failed, when the user has no number, address or chat for it. A user type with no list of its own uses the Default list, and with no list at all the OTP Delivery service is used. A common order is WhatsApp, then SMS, then email.
Codes from your network devices
One-time codes for device logins are made and sent by the RADIUS server. To send them through channels, set OTP_VIA_CHANNELS=true in .env and recreate freeradius. FreeRADIUS then posts each code to the console, on this server only and with the same bearer token it already uses. With this on, a user with no mobile number can still get a code through a channel that uses their email or linked chat. Passkey approval links, enrollment links, the captive portal's codes and identity-provider codes use channels as soon as one exists, with no setting.
Limits
One HTTP request per message, so a provider that needs a token fetched on every send (an OAuth exchange) is not supported; use a long-lived key. Text only. The response is judged by status and one JSON field. Providers that report delivery later by callback are treated as accepted when they accept the request.
LabHands-on
Needs your own install. The demo does not send messages.
- Open Integrations → Delivery Channels and look at the presets.
- Add a Slack webhook or generic webhook channel pointing at a test receiver you control. Store the secret, then Preview request and check the credentials are hidden.
- Click Send test and confirm the receiver gets the message. Read the channel's last result.
- Break it on purpose: use a wrong status range or a missing placeholder. Read how the console refuses it.
- Add a second channel, then set an ordered list for one user type. Remove a user's number and confirm the first channel is skipped and the second is used.
- Set
OTP_VIA_CHANNELS=true, recreatefreeradius, and sign in to a device as a user with an email but no number.
Check yourselfQuiz
Cheat sheetKeep this
- Integrations → Delivery Channels. One channel = one HTTP request (or email via the server's SMTP).
- Placeholders:
{{message}},{{otp}},{{mobile}},{{email}},{{chat_id}},{{username}},{{secret.NAME}}. Escaped per place. - Credentials: encrypted, never shown, need
PKI_KEY_ENCRYPTION_KEY. - Success: status range and optional response field pointer.
- Preview (no send) then Send test. Read Last result.
- Order per user type: WhatsApp, SMS, email. Missing detail = skipped.
- Devices:
OTP_VIA_CHANNELS=true+ recreatefreeradius. - Plain HTTP: opt-in, labelled Unencrypted HTTP. Own address and link-local always refused. No redirects.
- Read more: Delivery channels.