openapi: 3.0.3
info:
  title: Multi-Factor Authentication
  description: |-
    Bandwidth's Two-Factor Authentication service

    ## Base Path

    <code>https://mfa.bandwidth.com/api/v1</code>
  contact:
    name: Bandwidth Support
    email: support@bandwidth.com
    url: https://support.bandwidth.com
  termsOfService: https://www.bandwidth.com/legal/terms-of-use-bandwidthcom-web-sites/
  version: 3.1.0
servers:
  - url: https://mfa.bandwidth.com/api/v1
    description: Production
paths:
  /accounts/{accountId}/code/voice:
    post:
      tags:
        - MFA
      summary: Voice Authentication Code
      description: Send an MFA Code via a phone call.
      operationId: generateVoiceCode
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        $ref: '#/components/requestBodies/codeRequest'
      responses:
        '200':
          $ref: '#/components/responses/voiceCodeResponse'
        '400':
          $ref: '#/components/responses/mfaBadRequestError'
        '401':
          $ref: '#/components/responses/mfaUnauthorizedError'
        '403':
          $ref: '#/components/responses/mfaForbiddenError'
        '500':
          $ref: '#/components/responses/mfaInternalServerError'
      x-codeSamples:
        - lang: cURL
          source: >-
            curl 'https://mfa.bandwidth.com/api/v1/accounts/9900000/code/voice'
            \
              -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
              -H 'Content-Type: application/json' \
              -H 'Accept: application/json' \
              -d '{
                "to": "+19195551234",
                "from": "+19195554321",
                "applicationId": "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
                "message": "Your temporary {NAME} {SCOPE} code is {CODE}",
                "digits": 6,
                "scope": "2FA"
              }'
        - lang: C#
          source: |
            using System.Collections.Generic;
            using System.Diagnostics;
            using Bandwidth.Standard.Api;
            using Bandwidth.Standard.Client;
            using Bandwidth.Standard.Model;

            namespace Example
            {
                public class GenerateVoiceCodeExample
                {
                    public static void Main()
                    {
                        Configuration config = new Configuration();
                        config.BasePath = "http://localhost";
                        // Configure HTTP basic authorization: Basic
                        config.Username = "YOUR_USERNAME";
                        config.Password = "YOUR_PASSWORD";

                        var apiInstance = new MFAApi(config);
                        var accountId = 9900000;  // string | Your Bandwidth Account ID.
                        var codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.

                        try
                        {
                            // Voice Authentication Code
                            VoiceCodeResponse result = apiInstance.GenerateVoiceCode(accountId, codeRequest);
                            Debug.WriteLine(result);
                        }
                        catch (ApiException  e)
                        {
                            Debug.Print("Exception when calling MFAApi.GenerateVoiceCode: " + e.Message);
                            Debug.Print("Status Code: " + e.ErrorCode);
                            Debug.Print(e.StackTrace);
                        }
                    }
                }
            }
        - lang: Java
          source: |
            // Import classes:
            import com.bandwidth.sdk.ApiClient;
            import com.bandwidth.sdk.ApiException;
            import com.bandwidth.sdk.Configuration;
            import com.bandwidth.sdk.auth.*;
            import com.bandwidth.sdk.models.*;
            import com.bandwidth.sdk.api.MfaApi;

            public class Example {
              public static void main(String[] args) {
                ApiClient defaultClient = Configuration.getDefaultApiClient();
                defaultClient.setBasePath("http://localhost");
                
                // Configure HTTP basic authorization: Basic
                HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
                Basic.setUsername("YOUR USERNAME");
                Basic.setPassword("YOUR PASSWORD");

                MfaApi apiInstance = new MfaApi(defaultClient);
                String accountId = "9900000"; // String | Your Bandwidth Account ID.
                CodeRequest codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.
                try {
                  VoiceCodeResponse result = apiInstance.generateVoiceCode(accountId, codeRequest);
                  System.out.println(result);
                } catch (ApiException e) {
                  System.err.println("Exception when calling MfaApi#generateVoiceCode");
                  System.err.println("Status code: " + e.getCode());
                  System.err.println("Reason: " + e.getResponseBody());
                  System.err.println("Response headers: " + e.getResponseHeaders());
                  e.printStackTrace();
                }
              }
            }
        - lang: PHP
          source: >
            <?php


            require "vendor/autoload.php";


            api-username = "api-username";

            api-password = "api-pasword";

            12345 = "12345";

            1234-qwer = "1234-qwer";

            +15554443333 = "+15554443333";

            +15553334444 = "+15553334444";


            $config = new BandwidthLib\Configuration(
                array(
                    'multiFactorAuthBasicAuthUserName' => $BW_USERNAME,
                    'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,
                )
            );

            $client = new BandwidthLib\BandwidthClient($config);


            $mfaClient = $client->getMultiFactorAuth()->getMFA();


            $body = new
            BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema();

            $body->from = $BW_MFA_NUMBER;

            $body->to = $USER_NUMBER;

            $body->applicationId = $BW_MFA_VOICE_APPLICATION_ID;

            $body->scope = "scope";

            $body->digits = 6;

            $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}";


            try {
                $mfaClient->createVoiceTwoFactor($BW_ACCOUNT_ID, $body);
            } catch (BandwidthLib\APIException $e) {
                print_r($e->getResponseCode());
            }
        - lang: Python
          source: >
            import bandwidth

            from bandwidth.models.code_request import CodeRequest

            from bandwidth.models.voice_code_response import VoiceCodeResponse

            from bandwidth.rest import ApiException

            from pprint import pprint


            # Defining the host is optional and defaults to http://localhost

            # See configuration.py for a list of all supported configuration
            parameters.

            configuration = bandwidth.Configuration(
                host = "http://localhost"
            )


            # The client must configure the authentication and authorization
            parameters

            # in accordance with the API server security policy.

            # Examples for each auth method are provided below, use the example
            that

            # satisfies your auth use case.


            # Configure HTTP basic authorization: Basic

            configuration = bandwidth.Configuration(
                username = os.environ["USERNAME"],
                password = os.environ["PASSWORD"]
            )


            # Enter a context with an instance of the API client

            with bandwidth.ApiClient(configuration) as api_client:
                # Create an instance of the API class
                api_instance = bandwidth.MFAApi(api_client)
                account_id = '9900000' # str | Your Bandwidth Account ID.
                code_request = bandwidth.CodeRequest() # CodeRequest | MFA code request body.

                try:
                    # Voice Authentication Code
                    api_response = api_instance.generate_voice_code(account_id, code_request)
                    print("The response of MFAApi->generate_voice_code:\n")
                    pprint(api_response)
                except Exception as e:
                    print("Exception when calling MFAApi->generate_voice_code: %s\n" % e)
        - lang: Ruby
          source: >
            require 'time'

            require 'bandwidth-sdk'

            # setup authorization

            Bandwidth.configure do |config|
              # Configure HTTP basic authorization: Basic
              config.username = 'YOUR USERNAME'
              config.password = 'YOUR PASSWORD'
            end


            api_instance = Bandwidth::MFAApi.new

            account_id = '9900000' # String | Your Bandwidth Account ID.

            code_request = Bandwidth::CodeRequest.new({to: '+19195551234', from:
            '+19195554321', application_id:
            '66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1', message: 'Your temporary
            {NAME} {SCOPE} code is {CODE}', digits: 6}) # CodeRequest | MFA code
            request body.


            begin
              # Voice Authentication Code
              result = api_instance.generate_voice_code(account_id, code_request)
              p result
            rescue Bandwidth::ApiError => e
              puts "Error when calling MFAApi->generate_voice_code: #{e}"
            end
        - lang: TypeScript
          source: >
            import {
                MFAApi,
                Configuration,
                CodeRequest
            } from 'bandwidth-sdk';


            const configuration = new Configuration();

            const apiInstance = new MFAApi(configuration);


            let accountId: string; //Your Bandwidth Account ID. (default to
            undefined)

            let codeRequest: CodeRequest; //MFA code request body.


            const { status, data } = await apiInstance.generateVoiceCode(
                accountId,
                codeRequest
            );
  /accounts/{accountId}/code/messaging:
    post:
      tags:
        - MFA
      summary: Messaging Authentication Code
      description: Send an MFA code via text message (SMS).
      operationId: generateMessagingCode
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        $ref: '#/components/requestBodies/codeRequest'
      responses:
        '200':
          $ref: '#/components/responses/messagingCodeResponse'
        '400':
          $ref: '#/components/responses/mfaBadRequestError'
        '401':
          $ref: '#/components/responses/mfaUnauthorizedError'
        '403':
          $ref: '#/components/responses/mfaForbiddenError'
        '500':
          $ref: '#/components/responses/mfaInternalServerError'
      x-codeSamples:
        - lang: cURL
          source: >-
            curl
            'https://mfa.bandwidth.com/api/v1/accounts/9900000/code/messaging' \
              -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
              -H 'Content-Type: application/json' \
              -H 'Accept: application/json' \
              -d '{
                "to": "+19195551234",
                "from": "+19195554321",
                "applicationId": "66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1",
                "message": "Your temporary {NAME} {SCOPE} code is {CODE}",
                "digits": 6,
                "scope": "2FA"
              }'
        - lang: C#
          source: |
            using System.Collections.Generic;
            using System.Diagnostics;
            using Bandwidth.Standard.Api;
            using Bandwidth.Standard.Client;
            using Bandwidth.Standard.Model;

            namespace Example
            {
                public class GenerateMessagingCodeExample
                {
                    public static void Main()
                    {
                        Configuration config = new Configuration();
                        config.BasePath = "http://localhost";
                        // Configure HTTP basic authorization: Basic
                        config.Username = "YOUR_USERNAME";
                        config.Password = "YOUR_PASSWORD";

                        var apiInstance = new MFAApi(config);
                        var accountId = 9900000;  // string | Your Bandwidth Account ID.
                        var codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.

                        try
                        {
                            // Messaging Authentication Code
                            MessagingCodeResponse result = apiInstance.GenerateMessagingCode(accountId, codeRequest);
                            Debug.WriteLine(result);
                        }
                        catch (ApiException  e)
                        {
                            Debug.Print("Exception when calling MFAApi.GenerateMessagingCode: " + e.Message);
                            Debug.Print("Status Code: " + e.ErrorCode);
                            Debug.Print(e.StackTrace);
                        }
                    }
                }
            }
        - lang: Java
          source: |
            // Import classes:
            import com.bandwidth.sdk.ApiClient;
            import com.bandwidth.sdk.ApiException;
            import com.bandwidth.sdk.Configuration;
            import com.bandwidth.sdk.auth.*;
            import com.bandwidth.sdk.models.*;
            import com.bandwidth.sdk.api.MfaApi;

            public class Example {
              public static void main(String[] args) {
                ApiClient defaultClient = Configuration.getDefaultApiClient();
                defaultClient.setBasePath("http://localhost");
                
                // Configure HTTP basic authorization: Basic
                HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
                Basic.setUsername("YOUR USERNAME");
                Basic.setPassword("YOUR PASSWORD");

                MfaApi apiInstance = new MfaApi(defaultClient);
                String accountId = "9900000"; // String | Your Bandwidth Account ID.
                CodeRequest codeRequest = new CodeRequest(); // CodeRequest | MFA code request body.
                try {
                  MessagingCodeResponse result = apiInstance.generateMessagingCode(accountId, codeRequest);
                  System.out.println(result);
                } catch (ApiException e) {
                  System.err.println("Exception when calling MfaApi#generateMessagingCode");
                  System.err.println("Status code: " + e.getCode());
                  System.err.println("Reason: " + e.getResponseBody());
                  System.err.println("Response headers: " + e.getResponseHeaders());
                  e.printStackTrace();
                }
              }
            }
        - lang: PHP
          source: >
            <?php


            require "vendor/autoload.php";


            api-username = "api-username";

            api-password = "api-pasword";

            12345 = "12345";

            1234-asdf = "1234-asdf";

            +15554443333 = "+15554443333";

            +15553334444 = "+15553334444";


            $config = new BandwidthLib\Configuration(
                array(
                    'multiFactorAuthBasicAuthUserName' => $BW_USERNAME,
                    'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,
                )
            );

            $client = new BandwidthLib\BandwidthClient($config);


            $mfaClient = $client->getMultiFactorAuth()->getMFA();


            $body = new
            BandwidthLib\MultiFactorAuth\Models\TwoFactorCodeRequestSchema();

            $body->from = $BW_MFA_NUMBER;

            $body->to = $USER_NUMBER;

            $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID;

            $body->scope = "scope";

            $body->digits = 6;

            $body->message = "Your temporary {NAME} {SCOPE} code is {CODE}";


            try {
                $mfaClient->createMessagingTwoFactor($BW_ACCOUNT_ID, $body);
            } catch (BandwidthLib\APIException $e) {
                print_r($e->getResponseCode());
            }
        - lang: Python
          source: >
            import bandwidth

            from bandwidth.models.code_request import CodeRequest

            from bandwidth.models.messaging_code_response import
            MessagingCodeResponse

            from bandwidth.rest import ApiException

            from pprint import pprint


            # Defining the host is optional and defaults to http://localhost

            # See configuration.py for a list of all supported configuration
            parameters.

            configuration = bandwidth.Configuration(
                host = "http://localhost"
            )


            # The client must configure the authentication and authorization
            parameters

            # in accordance with the API server security policy.

            # Examples for each auth method are provided below, use the example
            that

            # satisfies your auth use case.


            # Configure HTTP basic authorization: Basic

            configuration = bandwidth.Configuration(
                username = os.environ["USERNAME"],
                password = os.environ["PASSWORD"]
            )


            # Enter a context with an instance of the API client

            with bandwidth.ApiClient(configuration) as api_client:
                # Create an instance of the API class
                api_instance = bandwidth.MFAApi(api_client)
                account_id = '9900000' # str | Your Bandwidth Account ID.
                code_request = bandwidth.CodeRequest() # CodeRequest | MFA code request body.

                try:
                    # Messaging Authentication Code
                    api_response = api_instance.generate_messaging_code(account_id, code_request)
                    print("The response of MFAApi->generate_messaging_code:\n")
                    pprint(api_response)
                except Exception as e:
                    print("Exception when calling MFAApi->generate_messaging_code: %s\n" % e)
        - lang: Ruby
          source: >
            require 'time'

            require 'bandwidth-sdk'

            # setup authorization

            Bandwidth.configure do |config|
              # Configure HTTP basic authorization: Basic
              config.username = 'YOUR USERNAME'
              config.password = 'YOUR PASSWORD'
            end


            api_instance = Bandwidth::MFAApi.new

            account_id = '9900000' # String | Your Bandwidth Account ID.

            code_request = Bandwidth::CodeRequest.new({to: '+19195551234', from:
            '+19195554321', application_id:
            '66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1', message: 'Your temporary
            {NAME} {SCOPE} code is {CODE}', digits: 6}) # CodeRequest | MFA code
            request body.


            begin
              # Messaging Authentication Code
              result = api_instance.generate_messaging_code(account_id, code_request)
              p result
            rescue Bandwidth::ApiError => e
              puts "Error when calling MFAApi->generate_messaging_code: #{e}"
            end
        - lang: TypeScript
          source: >
            import {
                MFAApi,
                Configuration,
                CodeRequest
            } from 'bandwidth-sdk';


            const configuration = new Configuration();

            const apiInstance = new MFAApi(configuration);


            let accountId: string; //Your Bandwidth Account ID. (default to
            undefined)

            let codeRequest: CodeRequest; //MFA code request body.


            const { status, data } = await apiInstance.generateMessagingCode(
                accountId,
                codeRequest
            );
  /accounts/{accountId}/code/verify:
    post:
      tags:
        - MFA
      summary: Verify Authentication Code
      description: Verify a previously sent MFA code.
      operationId: verifyCode
      parameters:
        - $ref: '#/components/parameters/accountId'
      requestBody:
        $ref: '#/components/requestBodies/codeVerify'
      responses:
        '200':
          $ref: '#/components/responses/verifyCodeResponse'
        '400':
          $ref: '#/components/responses/mfaBadRequestError'
        '401':
          $ref: '#/components/responses/mfaUnauthorizedError'
        '403':
          $ref: '#/components/responses/mfaForbiddenError'
        '429':
          $ref: '#/components/responses/mfaTooManyRequestsError'
        '500':
          $ref: '#/components/responses/mfaInternalServerError'
      x-codeSamples:
        - lang: cURL
          source: >-
            curl 'https://mfa.bandwidth.com/api/v1/accounts/9900000/code/verify'
            \
              -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
              -H 'Content-Type: application/json' \
              -H 'Accept: application/json' \
              -d '{
                "to": "+19195551234",
                "expirationTimeInMinutes": 3,
                "code": "123456",
                "scope": "2FA"
              }'
        - lang: C#
          source: |
            using System.Collections.Generic;
            using System.Diagnostics;
            using Bandwidth.Standard.Api;
            using Bandwidth.Standard.Client;
            using Bandwidth.Standard.Model;

            namespace Example
            {
                public class VerifyCodeExample
                {
                    public static void Main()
                    {
                        Configuration config = new Configuration();
                        config.BasePath = "http://localhost";
                        // Configure HTTP basic authorization: Basic
                        config.Username = "YOUR_USERNAME";
                        config.Password = "YOUR_PASSWORD";

                        var apiInstance = new MFAApi(config);
                        var accountId = 9900000;  // string | Your Bandwidth Account ID.
                        var verifyCodeRequest = new VerifyCodeRequest(); // VerifyCodeRequest | MFA code verify request body.

                        try
                        {
                            // Verify Authentication Code
                            VerifyCodeResponse result = apiInstance.VerifyCode(accountId, verifyCodeRequest);
                            Debug.WriteLine(result);
                        }
                        catch (ApiException  e)
                        {
                            Debug.Print("Exception when calling MFAApi.VerifyCode: " + e.Message);
                            Debug.Print("Status Code: " + e.ErrorCode);
                            Debug.Print(e.StackTrace);
                        }
                    }
                }
            }
        - lang: Java
          source: |
            // Import classes:
            import com.bandwidth.sdk.ApiClient;
            import com.bandwidth.sdk.ApiException;
            import com.bandwidth.sdk.Configuration;
            import com.bandwidth.sdk.auth.*;
            import com.bandwidth.sdk.models.*;
            import com.bandwidth.sdk.api.MfaApi;

            public class Example {
              public static void main(String[] args) {
                ApiClient defaultClient = Configuration.getDefaultApiClient();
                defaultClient.setBasePath("http://localhost");
                
                // Configure HTTP basic authorization: Basic
                HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
                Basic.setUsername("YOUR USERNAME");
                Basic.setPassword("YOUR PASSWORD");

                MfaApi apiInstance = new MfaApi(defaultClient);
                String accountId = "9900000"; // String | Your Bandwidth Account ID.
                VerifyCodeRequest verifyCodeRequest = new VerifyCodeRequest(); // VerifyCodeRequest | MFA code verify request body.
                try {
                  VerifyCodeResponse result = apiInstance.verifyCode(accountId, verifyCodeRequest);
                  System.out.println(result);
                } catch (ApiException e) {
                  System.err.println("Exception when calling MfaApi#verifyCode");
                  System.err.println("Status code: " + e.getCode());
                  System.err.println("Reason: " + e.getResponseBody());
                  System.err.println("Response headers: " + e.getResponseHeaders());
                  e.printStackTrace();
                }
              }
            }
        - lang: PHP
          source: >
            <?php
              
            require "vendor/autoload.php";


            api-username = "api-username";

            api-password = "api-pasword";

            12345 = "12345";

            1234-asdf = "1234-asdf";

            //$BW_MFA_MESSAGING_APPLICATION_ID =
            getenv("BW_MFA_MESSAGING_APPLICATION_ID");

            //Both voice and messaging application IDs can be used. The verify
            request

            //must have the same ID as the code request.

            +15554443333 = "+15554443333";

            +15553334444 = "+15553334444";


            $config = new BandwidthLib\Configuration(
                array(
                    'multiFactorAuthBasicAuthUserName' => $BW_USERNAME,
                    'multiFactorAuthBasicAuthPassword' => $BW_PASSWORD,
                )
            );

            $client = new BandwidthLib\BandwidthClient($config);


            $mfaClient = $client->getMultiFactorAuth()->getMFA();


            $body = new
            BandwidthLib\MultiFactorAuth\Models\TwoFactorVerifyRequestSchema();

            $body->from = $BW_MFA_NUMBER;

            $body->to = $USER_NUMBER;

            $body->applicationId = $BW_MFA_MESSAGING_APPLICATION_ID;

            //$body->applicationId = 1234-qwer;

            $body->scope = "scope";

            $body->code = "123456"; //This is the user's input to validate

            $body->digits = 6;

            $body->expirationTimeInMinutes = 3;


            try {
                $response = $mfaClient->createVerifyTwoFactor($BW_ACCOUNT_ID, $body);
                print_r($response->getResult()->valid);
            } catch (BandwidthLib\APIException $e) {
                print_r($e->getResponseCode());
            }
        - lang: Python
          source: >
            import bandwidth

            from bandwidth.models.verify_code_request import VerifyCodeRequest

            from bandwidth.models.verify_code_response import VerifyCodeResponse

            from bandwidth.rest import ApiException

            from pprint import pprint


            # Defining the host is optional and defaults to http://localhost

            # See configuration.py for a list of all supported configuration
            parameters.

            configuration = bandwidth.Configuration(
                host = "http://localhost"
            )


            # The client must configure the authentication and authorization
            parameters

            # in accordance with the API server security policy.

            # Examples for each auth method are provided below, use the example
            that

            # satisfies your auth use case.


            # Configure HTTP basic authorization: Basic

            configuration = bandwidth.Configuration(
                username = os.environ["USERNAME"],
                password = os.environ["PASSWORD"]
            )


            # Enter a context with an instance of the API client

            with bandwidth.ApiClient(configuration) as api_client:
                # Create an instance of the API class
                api_instance = bandwidth.MFAApi(api_client)
                account_id = '9900000' # str | Your Bandwidth Account ID.
                verify_code_request = bandwidth.VerifyCodeRequest() # VerifyCodeRequest | MFA code verify request body.

                try:
                    # Verify Authentication Code
                    api_response = api_instance.verify_code(account_id, verify_code_request)
                    print("The response of MFAApi->verify_code:\n")
                    pprint(api_response)
                except Exception as e:
                    print("Exception when calling MFAApi->verify_code: %s\n" % e)
        - lang: Ruby
          source: >
            require 'time'

            require 'bandwidth-sdk'

            # setup authorization

            Bandwidth.configure do |config|
              # Configure HTTP basic authorization: Basic
              config.username = 'YOUR USERNAME'
              config.password = 'YOUR PASSWORD'
            end


            api_instance = Bandwidth::MFAApi.new

            account_id = '9900000' # String | Your Bandwidth Account ID.

            verify_code_request = Bandwidth::VerifyCodeRequest.new({to:
            '+19195551234', expiration_time_in_minutes: 3, code: '123456'}) #
            VerifyCodeRequest | MFA code verify request body.


            begin
              # Verify Authentication Code
              result = api_instance.verify_code(account_id, verify_code_request)
              p result
            rescue Bandwidth::ApiError => e
              puts "Error when calling MFAApi->verify_code: #{e}"
            end
        - lang: TypeScript
          source: >
            import {
                MFAApi,
                Configuration,
                VerifyCodeRequest
            } from 'bandwidth-sdk';


            const configuration = new Configuration();

            const apiInstance = new MFAApi(configuration);


            let accountId: string; //Your Bandwidth Account ID. (default to
            undefined)

            let verifyCodeRequest: VerifyCodeRequest; //MFA code verify request
            body.


            const { status, data } = await apiInstance.verifyCode(
                accountId,
                verifyCodeRequest
            );
components:
  schemas:
    codeRequest:
      type: object
      properties:
        to:
          type: string
          description: The phone number to send the mfa code to.
          pattern: ^\+[1-9]\d{1,14}$
          example: '+19195551234'
        from:
          type: string
          description: The application phone number, the sender of the mfa code.
          pattern: ^\+[1-9]\d{1,14}$
          maxLength: 32
          example: '+19195554321'
        applicationId:
          type: string
          description: The application unique ID, obtained from Bandwidth.
          maxLength: 50
          example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1
        scope:
          type: string
          description: >-
            An optional field to denote what scope or action the mfa code is
            addressing.  If not supplied, defaults to "2FA".
          maxLength: 25
          example: 2FA
        message:
          type: string
          description: >-
            The message format of the mfa code.  There are three values that the
            system will replace "{CODE}", "{NAME}", "{SCOPE}".  The "{SCOPE}"
            and "{NAME} value template are optional, while "{CODE}" must be
            supplied.  As the name would suggest, code will be replace with the
            actual mfa code.  Name is replaced with the application name,
            configured during provisioning of mfa.  The scope value is the same
            value sent during the call and partitioned by the server.
          maxLength: 2048
          example: Your temporary {NAME} {SCOPE} code is {CODE}
        digits:
          type: integer
          description: >-
            The number of digits for your mfa code.  The valid number ranges
            from 2 to 8, inclusively.
          minimum: 4
          maximum: 8
          example: 6
      required:
        - to
        - from
        - applicationId
        - message
        - digits
    voiceCodeResponse:
      type: object
      properties:
        callId:
          type: string
          description: Programmable Voice API Call ID.
          example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85
    messagingCodeResponse:
      type: object
      properties:
        messageId:
          type: string
          description: Messaging API Message ID.
          example: 1589228074636lm4k2je7j7jklbn2
    verifyCodeRequest:
      type: object
      properties:
        to:
          type: string
          description: The phone number to send the mfa code to.
          pattern: ^\+[1-9]\d{1,14}$
          example: '+19195551234'
        scope:
          type: string
          description: >-
            An optional field to denote what scope or action the mfa code is
            addressing.  If not supplied, defaults to "2FA".
          example: 2FA
        expirationTimeInMinutes:
          type: number
          description: >-
            The time period, in minutes, to validate the mfa code.  By setting
            this to 3 minutes, it will mean any code generated within the last 3
            minutes are still valid.  The valid range for expiration time is
            between 0 and 15 minutes, exclusively and inclusively, respectively.
          minimum: 1
          maximum: 15
          example: 3
        code:
          type: string
          description: The generated mfa code to check if valid.
          minLength: 4
          maxLength: 8
          example: '123456'
      required:
        - to
        - expirationTimeInMinutes
        - code
    verifyCodeResponse:
      type: object
      properties:
        valid:
          type: boolean
          description: Whether or not the supplied code is valid.
          example: true
    mfaRequestError:
      type: object
      properties:
        error:
          type: string
          description: A message describing the error with your request.
          example: 400 Request is malformed or invalid
        requestId:
          type: string
          description: The associated requestId from AWS.
          example: 354cc8a3-6701-461e-8fa7-8671703dd898
    mfaUnauthorizedRequestError:
      type: object
      properties:
        message:
          type: string
          description: Unauthorized
          example: Unauthorized
    mfaForbiddenRequestError:
      type: object
      properties:
        message:
          type: string
          description: >-
            The message containing the reason behind the request being
            forbidden.
          example: Missing Authentication Token
  responses:
    voiceCodeResponse:
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/voiceCodeResponse'
    messagingCodeResponse:
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messagingCodeResponse'
    verifyCodeResponse:
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/verifyCodeResponse'
    mfaBadRequestError:
      description: Bad Request
      headers: {}
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/mfaRequestError'
    mfaUnauthorizedError:
      description: Unauthorized
      headers: {}
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/mfaUnauthorizedRequestError'
    mfaForbiddenError:
      description: Forbidden
      headers: {}
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/mfaForbiddenRequestError'
    mfaTooManyRequestsError:
      description: Too Many Requests
      headers: {}
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/mfaRequestError'
    mfaInternalServerError:
      description: Internal Server Error
      headers: {}
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/mfaRequestError'
  parameters:
    accountId:
      in: path
      name: accountId
      required: true
      schema:
        type: string
      description: Your Bandwidth Account ID.
      example: '9900000'
  requestBodies:
    codeRequest:
      description: MFA code request body.
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/codeRequest'
    codeVerify:
      description: MFA code verify request body.
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/verifyCodeRequest'
  securitySchemes:
    Basic:
      type: http
      scheme: basic
      description: >-
        Basic authentication is a simple authentication scheme built into the
        HTTP protocol. To use it, send your HTTP requests with an
        `Authorization` header that contains the word `Basic` followed by a
        space and a Base64-encoded string `username:password`.


        - Example: `Authorization: Basic ZGVtbZpwQDU1dzByZA==`
    OAuth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://api.bandwidth.com/api/v1/oauth2/token
          scopes: {}
security:
  - Basic: []
  - OAuth2: []
tags:
  - name: MFA
