Using 2FA Email templates
You can use our two-factor authentication (2FA) API with Email to give users another option to suit their preferences or availability for authentication. The 2FA API generates a PIN, sends it to the requested recipient email, and allows you to verify it.
Using Email as an authentication channel provides the following benefits:
- Users can quickly receive authentication codes without access to a mobile device
- It can be a part of a multi-factor authentication system, verifying your users' phone number and email address
- Verifying email addresses in your user journey provides better quality of your email database, allowing you to reach out to your users over a verified channel
The steps for setting up 2FA for email are:
- Set up a Broadcast Template and Content Email Template in the Infobip web interface.
- Set up a 2FA application.
- Set up a 2FA Email message template over the API.
- Send the PIN via email and Verify
Before you start, make sure you have the following:
- Standard Email setup in Infobip
- Access to 2FA API by going through getting started with Infobip API
To learn more about the 2FA API setup, see General 2FA (OTP) setup.
Set up Broadcast Template
To enable the 2FA Service for Email, you first need to create a Broadcast Template:
- Log in to the web interface and go to Moments > Templates.
- Click Content Email Templates, and then click Create Template.
- In the template, include a "pin" placeholder
{$pin}
which is where the PIN is displayed - Alternatively, create a custom attribute called "pin" in People > Configuration > Person Custom Attributes
- When creating the content, create the PIN placeholder from the Placeholder Menu by typing in the PIN and using autocomplete
- In the template, include a "pin" placeholder
- Click Save Content template.
- Go back to Moments > Templates and click Broadcast Templates.
- Click Save Broadcast template.
Important
Make a note of the Broadcast template number. For example, #350140.
Set up 2FA Email message template - API
For this service, there are two endpoints to enable 2FA PIN codes to be sent via email:
- Create 2FA application:
POST /2fa/2/applications
(see 2FA API setup). - Create a 2FA Email message template. Note that
emailTemplateId
is the Broadcast template number (for example, #350140).
POST /2fa/2/applications/{appId}/email/messages
{
"pinType": "NUMERIC",
"pinLength": 4,
"emailTemplateId": 350140
}
- Send a 2FA PIN code over Email:
POST /2fa/2/pin/email
(see Send 2FA PIN code over email). - Verify the 2FA PIN with
POST /2fa/2/pin/{pinId}/verify
(see Verify request).