---
title: "Create Code Generator"
method: POST
path: "/v1/2fa"
tags: ["Two Factor Authentication"]
---

# Create Code Generator

`POST /v1/2fa`

This endpoint allows you to create a Code Generator to configure the number of characters of the security code (<code>codeLength</code>), expiration time of the code in minutes (<code>expirationMinutes</code>), the delivery channel where the code will be sent (SMS or Email) and the message body with the code placeholder that is sent to end users (<code>text</code>).If you want to send the code by SMS channel, you need to provide a specific sender (<code>shortcode</code>) to be user on an SMS messange sent to the end user.In case of sending the code by Email channel, you need to provide a specific sender (<code>from</code>) to be used on an Email message sent to the end user.Note: You must be registered in a delivery channel from which the message will be sent to get a valid short code (SMS) or a valid email sender.

## Request body

- TwoFactorCreateRequestBody
  - `codeLength` integer, required — character length to generate codes
  - `expirationMinutes` integer, required — minutes to expire a code
  - `channels` ChannelDTO[], required — two factor authentication pair channel-from
    - `subject` string — subject for email channel
    - `shortcode` string — shortcode for SMS channel
    - `from` string — from for email channel
    - `text` string — two factor authentication message
    - `placeholder` string — whatsapp template placeholder
    - `address` string — Sender mobilenumber for Whatsapp channel
    - `templateName` string — Whatsapp message template name
    - `templateId` string — Whatsapp message template id
    - `templateLanguage` string — Whatsapp message template language
    - `type` 'SMS' | 'EMAIL' | 'WHATSAPP' | 'SMS' | 'EMAIL' | 'WHATSAPP' — two factor authentication channel

## Response `201`

2FA Interaction Created

- TwoFactorResponse
  - `meta` MetadataDTO
    - `timestamp` integer, required — Transaction's date in timestamp
    - `transactionId` string, required — Id for the current transaction (Endpoint's call)
    - `explain` string — Explain string in case of failure
  - `data` TwoFactorDTO — two factor configuration information
    - `id` integer, required — two factor configuration id
    - `codeLength` integer, required — character length to generate codes
    - `expirationMinutes` integer, required — minutes to expire a code
    - `channels` ChannelDTO[], required — two factor authentication pair channel-from
      - `subject` string — subject for email channel
      - `shortcode` string — shortcode for SMS channel
      - `from` string — from for email channel
      - `text` string — two factor authentication message
      - `placeholder` string — whatsapp template placeholder
      - `address` string — Sender mobilenumber for Whatsapp channel
      - `templateName` string — Whatsapp message template name
      - `templateId` string — Whatsapp message template id
      - `templateLanguage` string — Whatsapp message template language
      - `type` 'SMS' | 'EMAIL' | 'WHATSAPP' | 'SMS' | 'EMAIL' | 'WHATSAPP' — two factor authentication channel

## Other responses

- `401` — User not allowed
- `403` — Forbidden Access
- `422` — Unprocessable Entity
- `500` — Internal Server Error

---

[API](https://skmtc.net/messangi/apis/raven.md) · [All operations](https://skmtc.net/messangi/apis/raven/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/messangi/raven/versions/c87f398fa338/schema)
