2FA Service
Using 2FA Email templates

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:

  1. Set up a Broadcast Template and Content Email Template in the web interface.
  2. Set up 2FA application.
  3. Setup a 2FA Email message template over the API.
  4. Send the PIN via email and Verify.

Before you start, make sure that you have the following:

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:

  1. Log in to the web interface and go to MomentsTemplates.
  2. Click Content Email Templates, and then click Create Template. Email template for Email 2FA
    • 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.
  3. Click Save Content Template.
  4. Go back to MomentsTemplates and click Broadcast Templates. Broadcast template for Email 2FA
    • In the top-right corner, change the channel to Email.
    • In the Content section, select Choose a Template.
    Choose email template for Email 2FA
    • Add the Content Email Template you created.
  5. 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:

  1. Create a 2FA application (opens in a new tab)POST /2fa/2/applications

  2. Create a 2FA Email message template. Note that emailTemplateId is the Broadcast template number (for example, #350140).

    json
     
       POST  /2fa/2/applications/{appId}/email/messages
          {
          "pinType": "NUMERIC",
          "pinLength": 4,
          "emailTemplateId": 350140
          }
     
  3. Send a 2FA PIN code over Email with POST /2fa/2/pin/email (see Send 2FA PIN code over email (opens in a new tab))

  4. Verify the 2FA PIN with POST /2fa/2/pin/\{pinId\}/verify (see Verify request (opens in a new tab))

Need assistance

Explore Infobip Tutorials

Encountering issues

Contact our support

What's new? Check out

Release Notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use