BSG utilizes HTTP cookies (and similar or complementary technologies) to 1) make this website safe, functional, and accessible (through the use of mandatory cookies) and 2) understand how you use our website (through the use of optional cookies) in order to improve your experience and to provide you with personalized content.

The information in the cookie text files may be related to your personal preferences or your device and is intended to make the site operate according to your expectations. The information contained in cookies does not usually identify your identity directly but is helpful in providing you with a more personalized user experience.

In accordance with the requirements of the General Data Protection Regulation (GDPR) privacy and security law that governs how the personal data of individuals in the EU may be processed and transferred, we provide you the possibility to prohibit the use of certain types of cookies when you use our website.

Read our Cookie Notice and the Privacy Policy for detailed information on how BGS collects and uses cookies. Please note that prohibiting the use of certain types of cookies may affect your interaction with the website and limit the accessibility of services we offer you. Choose the appropriate category below to learn more and to disable cookies.

Accept All cookies*
*Recommended for comfortable use of the site
Accept only necessary cookies
Accept only selected cookies
Necessary cookies
Social media
Analytics
Marketing
Developer Docs
Number Intelligence

2FA API

BSG 2FA API is a RESTful API for two-factor user authentication on a website or web application: you can use it to confirm a transaction, and user contact information, as a second factor in user authentication, and more.

BSG 2FA API provides a choice of channel for sending a one-time password (OTP) to a user: SMS or Viber. Connect the channel you need in your personal account on the “Settings” page of the “2FA” section and start working with the BSG 2FA API.

Please note: 2FA API is not available for use in DEMO account modes (modes in which your account data is not verified).

Make sure that you have entered all the necessary data in your account settings in order to use the 2FA service.

Available HTTP Methods

Send One-time password

This API call is used to generate and send a one-time password to a user in an SMS or Viber message. Please note: authentication of recipients who are in the SMS or Viber stop list in your contact book is not possible using the corresponding method. (That is, if the recipient is in the SMS stop list, then when requesting authentication using the SMS method, the one-time password will not be sent, and you will receive an error in response).

To send One-time password make a request to this URL:

POST https://one-api.bsg.world/api/2fa/authentications/otp

Be reliable. Use 2FA
Get Started

Request parameters

Parameter Requires Type Default Description
channel Yes string No A channel for sending a one-time password. Possible values: “SMS”, “Viber”.
sender Yes string No Sender’s name:from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces);3 to 15 characters for the sender’s numeric name.
recipient Yes integer No The phone number of the recipient of the one-time password. 9 to 15 digits without the + sign. 3 to 15 characters for the sender’s numeric name.
template_id Yes string No Unique identifier of the template with the Approved status. It’s not allowed to specify the template ID in other statuses. The template ID must be from 1 to 9 digits.
code_digits Yes integer No The length of the numeric code, from 3 to 9 digits.
code_lifetime Yes integer No The password expiration time after which the password becomes invalid. An integer from 30 seconds to 300 seconds.
code_max_tries Yes integer No The number of password verification attempts.An integer from 1 to 5.
sender_alt No string No Used only for the Viber channel to alternatively send a one-time code in SMS (if it was not possible to send the code in a Viber message, for example, if the recipient is not a Viber user).The name or number of the SMS sender. String up to 15 characters:from 3 to 11 characters for the sender’s alphanumeric name (Latin letters, symbols, numbers, spaces);3 to 15 characters for the sender’s numeric name.

Request example


{ 

  "recipient": "61401629754", 
  "channel": "string", 
  "sender": "SENDER", 
  "sender_alt": "SENDER_ALT", 
  "template_id": "12", 
  "code_lifetime": 300, 
  "code_max_tries": 3, 
  "code_digits": 5 

}

Response parameters

Parameter Type Description
id string The ID of the generated authentication.
recipient string Number of the recipient of the message with a one-time code.
status string Authentication status. Possible values: pending (authentication session successfully created and pending).
channel string Authentication channel selected for sending the one-time code
sender string Sender name.
sender_alt string/ null SMS sender name.
message_text string Message text.
code_lifetime integer OTP expiration date.
code_max_tries integer The number of OTP check attempts.
code_digits integer The number of digits in the OTP.
price float Authentication cost. At the time of creating the authentication, 0 is indicated.
currency string The three-letter code of the currency in which the value is indicated. Corresponds to the user’s account currency.
country_code string The country code of the recipient of the one-time password according to the ISO 3166-1 alpha-2 standard.
expired_at string Date and time when the authentication expires in ISO 8601 format.
created_at string The date and time of the authentication session were created in ISO 8601 format.
finished_at null Date and time when the authentication session was closed. At the time of creating the authentication, the value “null” is indicated.

Response example

Response in case of successful request:


{
  "data": {
    "id": "bf4381c8-9d4a-4705-bd28-f89a830b7f96",
    "recipient": "380979965073",
    "status": "pending",
    "channel": "sms",
    "sender": "SENDER",
    "sender_alt": "SENDER_ALT",
    "message_text": "Your verification code: {code}",
    "code_lifetime": 300,
    "code_max_tries": 3,
    "code_digits": 5,
    "price": "0,02",
    "currency": "USD",
    "country_code": "UA",
    "expired_at": "2023-01-04 18:37:06",
    "created_at": "2023-01-04 17:37:06"
    "finished_at": "2023-01-04 17:37:06"
  }
}

Codes of errors

Code Error Description
404 User channel not found This error can occur when the channel is specified incorrectly. Please ensure that you are using the correct channel and try again.
404 Template not found This error can occur when the template identifier is specified incorrectly or the specified template is not present in the system. Please ensure that you are using the correct template identifier and try again.
422 Invalid template status This error occurs when the provided template identifier in the request does not match the “Approved” status.
402 Insufficient funds Insufficient funds to send OTP. Please top up your account.
422 Exists on the stop list We’re unable to send message as the phone number of recipient is currently in stop list.
422 User channel inactive The message sending method is disabled. Please enable method in your personal account and try again.
422 This action is available for the account of your type only for your manager phone number. To send OTP code is not allowed in Demo account mode.
422 Authentication limit with status pending This error can occur when total authentication limit with status “pending” is exceeded for your account.
422 Total authentication limit This error can occur when total authentication limit is exceeded for your account.
422 Template is not available This error occurs when you try to create authentication using a template that is only available in the test mode of your account. Please choose a different template.

Resend the one-time code

Used to resend the one-time password to the recipient: a new one-time password is generated and sent in the message, and the previous one becomes invalid. When resending, already saved data is used to generate the OTP from the request https://one-api.bsg.world/api/2fa/authentications/otp

This API call is available only if the current authentication is not completed before its expiration date (the authentication validity period is specified in each 2FA API response).

To resend the one-time code send request to this URL:

POST https://one-api.bsg.world/api/2fa/authentications/otp/{id}/resend

Be reliable. Use 2FA
Get Started

Request parameters

Parameter Requires Type Default Description
id Yes string No Authentication ID received in response to https://one-api.bsg.world/api/2fa/authentications/otp The maximum length is 36 characters.

Response parameters

Parameter Type Description
id string The ID of the generated authentication.
recipient string Number of the recipient of the message with a one-time code.
status string Authentication status. Possible values: pending (authentication session successfully created and pending).
channel string Authentication channel selected for sending the one-time code
sender string Sender name.
sender_alt string/ null SMS sender name.
message_text string Message text.
code_lifetime integer OTP expiration date.
code_max_tries integer The number of OTP check attempts.
code_digits integer The number of digits in the OTP.
price float Authentication cost. At the time of creating the authentication, 0 is indicated.
currency string The three-letter code of the currency in which the value is indicated. Corresponds to the user’s account currency.
country_code string The country code of the recipient of the one-time password according to the ISO 3166-1 alpha-2 standard.
expired_at string Date and time when the authentication expires in ISO 8601 format.
created_at string The date and time of the authentication session were created in ISO 8601 format.
finished_at null Date and time when the authentication session was closed. At the time of creating the authentication, the value “null” is indicated.

Response example

Response in case of successful request:


{
  "data": {
    "id": "bf4381c8-9d4a-4705-bd28-f89a830b7f96",
    "recipient": "380979965073",
    "status": "pending",
    "channel": "sms",
    "sender": "SENDER",
    "sender_alt": "SENDER_ALT",
    "message_text": "Your verification code: {code}",
    "code_lifetime": 300,
    "code_max_tries": 3,
    "code_digits": 5,
    "price": "0,02",
    "currency": "USD",
    "country_code": "UA",
    "expired_at": "2023-01-04 18:37:06",
    "created_at": "2023-01-04 17:37:06"
    "finished_at": "2023-01-04 17:37:06"
  }
}

Codes of errors

Code Error Description
422 Authentication failed status This error can occur when attempting to resend the OTP code for an authentication session that has already been completed with a ‘failed’ status. Resending the OTP code is only possible when the authentication session is in the ‘pending’ status.
422 Authentication canceled status This error can occur when attempting to resend the OTP code for an authentication session that has already been completed with a ‘canceled’ status. Resending the OTP code is only possible when the authentication session is in the ‘pending’ status.
422 Authentication expired This error can occur when attempting to resend the OTP code for an authentication session that has already been completed with an ‘expired’ status. Resending the OTP code is only possible when the authentication session is in the ‘pending’ status
404 Authentication not found This error can occur when the authentication identifier is specified incorrectly or the specified authentication is not present in the system. Please ensure that you are using the correct authentication identifier and try again.

Check one-time Code

The API call is used to verify that the one-time password you received from the user matches the one sent by BSG.

To Check one-time Code send request to this URL:

POST https://one-api.bsg.world/api/2fa/authentications/otp/{id}/verify

Request parameters

Parameter Requires Type Default Description
id Yes string No Authentication ID received in response to https://one-api.bsg.world/api/2fa/authentications/otp The maximum length is 36 characters.
access_code Yes integer No The one-time password received by the user through the specified channel or alternative channel (optional) in the generation request that needs to be validated.An integer from 3 to 9 digits.

Response parameters

An example of a response if the code is incorrect:


{
  "errors": [
    {
      "message": "The code does not match the expected value"
    }
  ]
}

If the one-time code is correct:

Parameter Type Description
id string The ID of the generated authentication.
recipient string Number of the recipient of the message with a one-time password.
status string Authentication status. Possible values: verified (the code was successfully verified, and the session was closed with a successful result).
channel string Channel for authentication.
sender string Sender name.
sender_alt string SMS sender name.
message_text string Message text.
code_lifetime integer OTP expiration date.
code_max_tries integer The number of OTP check attempts.
code_digits integer The number of digits in the OTP.
price float Authentication cost (excluding the cost of sent messages).
currency string The three-letter code of the currency in which the value is indicated. Corresponds to the user’s account currency.
country_code string Receiver’s country code according to ISO 3166-1 alpha-2.
expired_at string Date and time when the authentication session expires in ISO 8601 format.
created_at string The date and time of the authentication session were created in ISO 8601 format.
finished_at string Date and time when the authentication session was closed in ISO 8601 format.

Response example


{
  "data": {
    "id": "bf4381c8-9d4a-4705-bd28-f89a830b7f96",
    "recipient": "380979965073",
    "status": "pending",
    "channel": "sms",
    "sender": "SENDER",
    "sender_alt": "SENDER_ALT",
    "message_text": "Your verification code: {code}",
    "code_lifetime": 300,
    "code_max_tries": 3,
    "code_digits": 5,
    "price": "0,02",
    "currency": "USD",
    "country_code": "UA",
    "expired_at": "2023-01-04 18:37:06",
    "created_at": "2023-01-04 17:37:06"
    "finished_at": "2023-01-04 17:37:06"
  }
}

Codes of errors

Code Error Description
404 Authentication not found This error can occur when the authentication identifier is specified incorrectly or the specified authentication is not present in the system. Please ensure that you are using the correct authentication identifier and try again.
404 The code does not match the expected value The error occurs when the provided code does not match the value that was sent to the recipient’s number.
422 Access code expired Your OTP password has expired. OTP password is no longer valid.
422 Authentication verifying attempts limit This error can occur when attempts limit is exceeded for authentication session.

Cancel the authentication session

Used to cancel the authentication process. In this case, authentication must be in the Pending status.

To cancel the authentication session send request to this URL:

POST https://one-api.bsg.world/api/2fa/authentications/{id}/cancel

Request parameters

Parameters Requires Type Default Description
id Yes string No Authentication ID received in response to https://one-api.bsg.world/api/2fa/authentications/otp The maximum length is 36 characters.

Response parameters

Parameter Type Description
id string The ID of the generated authentication.
recipient string Number of the recipient of the message with the OTP code.
status string Authentication status. Possible values: canceled.
channel string Channel for authentication.
sender string Sender’s name.
sender_alt string Alternate SMS sender name
message_text string Message text.
code_lifetime integer OTP expiration date.
code_max_tries integer The number of OTP check attempts.
code_digits integer The number of digits in the OTP.
price float Authentication session cost. If authentication is canceled, the cost will be 0.
currency string The three-letter code of the currency in which the cost is indicated.
country_code string Receiver’s country code according to ISO 3166-1 alpha-2.
expired_at string Date and time when the authentication session expires in ISO 8601 format.
created_at string The date and time of the authentication session was created in ISO 8601 format.
finished_at string Date and time when the authentication session was closed in ISO 8601 format.

Response example

Response in case of successful request:


{
  "data": {
    "id": "bf4381c8-9d4a-4705-bd28-f89a830b7f96",
    "recipient": "380979965073",
    "status": "canceled",
    "channel": "sms",
    "sender": "SENDER",
    "sender_alt": "SENDER_ALT",
    "message_text": "Your verification code: {code}",
    "code_lifetime": 300,
    "code_max_tries": 3,
    "code_digits": 5,
    "price": "0,02",
    "currency": "USD",
    "country_code": "UA",
    "expired_at": "2023-01-04 18:37:06",
    "created_at": "2023-01-04 17:37:06"
    "finished_at": "2023-01-04 17:37:06"
  }
}

Possible errors

Code Error Description
404 Authentication not found This error can occur when the authentication identifier is specified incorrectly or the specified authentication is not present in the system. Please ensure that you are using the correct authentication identifier and try again.
422 Authentication failed status This error can occur when attempting to cancel an authentication session that is already completed with a “failed” status. It is only possible to cancel an authentication session while it is in the “pending” status.
422 Authentication expired This error can occur when attempting to cancel an authentication session that is already completed with an “expired” status. It is only possible to cancel an authentication session while it is in the “pending” status.

Check authentication status

Use to get information about the current authentication status by specifying its identifier.

To check authentication status send request to this URL:

GET https://one-api.bsg.world/api/2fa/authentications/{id}

Be reliable. Use 2FA
Get Started

Request parameters

Parameter Requires Type Default Description
id Yes string No Authentication ID received in response to https://one-api.bsg.world/api/2fa/authentications/otp . The maximum length is 36 characters.

Response parameters

Parameter Type Description
id string Authentication ID created at the request of the user.
recipient string OTP message recipient number (specified by the user in the authentication request)
status string Authentication status. Possible values:pending – authentication has been created and is in the pending state;verified – authentication successful (code successfully verified);expired – authentication has expired;failed – authentication failed;canceled – authentication has been canceled.
channel string Authentication channel. Possible values: SMS, Viber.
sender string The name of the sender (specified by the user in the authentication request).
sender_alt string Alternative sender name for sending SMS (specified by the user in the authentication request).
code_lifetime integer OTP expiration date (specified by the user in the authentication request).
code_max_tries integer Number of OTP verification attempts (specified by the user in the authentication request).
code_digits integer The number of digits in the OTP (specified by the user in the authentication request).
price string Authentication cost (excluding the cost of sent messages). The amount must be displayed with 7 decimal places.
currency string The three-letter code of the currency in which the value is indicated.
country_code string Receiver’s country code according to ISO 3166-1 alpha-2.
expired_at string The expiration date of the authentication session.
created_at string The date and time of the authentication were created in ISO 8601 format.
finished_at string Date and time when authentication was closed in ISO 8601 format.
messages array Array of message objects:
messages[]id string The unique ID of the message.
messages[]recipient string The recipient’s phone number.
messages[]status string Message status. Possible values:delivered – the message was sent;accepted – message accepted for sending;undelivered – the message was not delivered.
messages[]channel string The channel for sending the message. Possible values: SMS or Viber.
messages[]sender string The name of the sender of the message.
messages[]text string Message text.
messages[]price float Message cost.
messages[]currency string The three-letter code of the currency in which the value is indicated.
messages[]sent_at string The date and time of the message were sent in ISO 8601 format.
messages[]created_at string The date and time the message was created in ISO 8601 format.

Response example

Response in case of successful request:


{

  "data": {

      "id": "ea5db413-e368-4952-b745-cc2030210c49", 
      "recipient": "380501403813", 
      "status": "verified", 
      "channel": "sms", 
      "sender": "testsms", 
      "sender_alt": "string", 
      "message_text": "Your BSG 2FA confirmation code is {code}. Do not share this with anyone else.", 
      "code_lifetime": 30, 
      "code_max_tries": 5, 
      "code_digits": 6, 
      "price": 50.25, 
      "currency": "EUR", 
      "country_code": "FR", 
      "expired_at": "2022-04-28 14:21:16", 
      "created_at": "2022-04-28 14:21:16", 
      "updated_at": "2022-04-28 14:21:16", 
      "finished_at": "2022-04-28 14:21:16", 

      "messages": [

        { 
          "id": "1ed32701-5d4f-6cfa-ba06-9db3aa8bab68", 
          "recipient": "61401629754", 
          "status": "accepted", 
          "channel": "sms", 
          "sender": "SENDER", 
          "price": 0.0642918, 
          "currency": "EUR", 
          "sent_at": "2022-04-18 11:00:30", 
          "created_at": "2022-04-18 10:55:35" 

        } 

      ] 

  } 

}

Possible errors

Code Error Description
404 Authentication not found This error can occur when the authentication identifier is specified incorrectly or the specified authentication is not present in the system. Please ensure that you are using the correct authentication identifier and try again.

Get a list of authentication sessions

Use to get a list of authentications for a period.

To get a list of authentication sessions make a request to this URL:

GET https://one-api.bsg.world/api/2fa/authentications

Be reliable. Use 2FA
Get Started

Request parameters

Parameter Requires Type Default Description
page[offset] No integer 0 Get auths starting at offset.
page[limit] No integer 10 The number of authentications in the response. Possible values are from 10 to 500.
filter[from] Yes string Period start date (date and time when the authentication session was created) in ISO 8601 format.
filter[to] Yes string End date of the period (date and time when the authentication was created) in ISO 8601 format.
filter[ids] No string Authentication ID. The maximum number is 3.
filter[status] No string Possible values: “pending”, “verified”, “expired”, “failed”, “canceled”.
filter[channel] No string Possible values: “ SMS ”, “ Viber ”.
filter[recipient] No string The phone number to which you want to send the OTP code. 9 to 15 digits.
filter[country_code] No string Beneficiary country code according to ISO 3166-1 alpha-2
way No string asc Sort options: asc, desc
sort No string created_at Sort by: id, status, channel, recipient, created_at, finished_at, country_code.

Response parameters

Parameter Type Description
list array An array of authentication objects.
list[]id string The ID of the generated authentication.
list[]recipient string Number of the recipient of the message with the OTP code.
list[]status string Authentication status. Possible values:pending – authentication has been created and is in the pending state;verified – authentication successful (one-time password successfully verified);expired – authentication has expired;failed – authentication failed;canceled – authentication has been canceled.
list[]channel string Channel for authentication.
list[]sender string Sender’s name.
list[]sender_alt string Alternative sender name for SMS.
list[]code_lifetime integer The expiration date of the one-time password.
list[]code_max_tries integer The number of attempts to verify the one-time password.
list[]code_digits integer The number of digits in the one-time password.
list[]price float Authentication session cost.
list[]currency string The three-letter code of the currency in which the authentication cost is indicated.
list[]country_code string Receiver’s country code according to ISO 3166-1 alpha-2.
list[]expired_at string The expiration date of the authentication in ISO 8601 format.
list[]created_at string The date and time of the authentication was created in ISO 8601 format.
list[]finished_at string Date and time when authentication was closed in ISO 8601 format.
list[]messages array Array of message objects:
list[]messages[]id string The unique ID of the message.
list[]messages[]recipient string The recipient’s phone number.
list[]messages[]status string Message status. Possible values:delivered – the message was sent;accepted – message accepted for sending;undelivered – the message was not delivered.
list[]messages[]sender string The name of the sender of the message.
list[]messages[]text string Message text.
list[]messages[]price float Message cost.
list[]messages[]currency string Currency of the account in which the cost is indicated. Corresponds to the user’s account currency.
list[]messages[]sent_at string The date and time of the message was sent in ISO 8601 format.
list[]messages[]created_at string The date and time the message was created in ISO 8601 format.
total integer The total number of authentications.

Response example

Response in case of successful request:


{
  "data": {
    "list": [
      {
      "id": "ea5db413-e368-4952-b745-cc2030210c49",
      "recipient": "380501403813",
      "status": "verified",
      "channel": "sms",
      "sender": "testsms",
      "sender_alt": "string",
      "message_text": "Your BSG 2FA confirmation code is {code}. Do not share this with anyone else.",
      "code_lifetime": 30,
      "code_max_tries": 5,
      "code_digits": 6,
      "price": 50.25,
      "currency": "EUR",
      "country_code": "FR",
      "expired_at": "2022-04-28 14:21:16",
      "created_at": "2022-04-28 14:21:16",
      "updated_at": "2022-04-28 14:21:16",
      "finished_at": "2022-04-28 14:21:16",
      "messages": [
        {
          "id": "1ed32701-5d4f-6cfa-ba06-9db3aa8bab68",
          "recipient": "61401629754",
          "status": "accepted",
          "channel": "sms",
          "sender": "SENDER",
          "price": 0.0642918,
          "currency": "EUR",
          "sent_at": "2022-04-18 11:00:30",
          "created_at": "2022-04-18 10:55:35"
        }
      ]
    },
    "total": 100
  }
}

Create a message template

This method creates a new message template used for sending the OTP code.

Please note that after creating the template, it is moderated. This template will be available for sending messages with the OTP code only after moderation. Once it’s ready, its status will be changed from Requested to Approved.

To create a message template make a request to this URL:

POST https://one-api.bsg.world/api/2fa/authentications/templates

Request parameters

Parameter Requires Type Default Description
name Yes string Name of the template.  A string of 3 to 50 characters.
countries Yes string Two-letter country code(s) for which the created template must apply. Sending messages with the OTP code will only be possible if the recipient’s number belongs to the country you specify for the template.
text Yes string Text of the message template.  A string of 9 to 70 characters for any encoding (Cyrillic, Latin).  The text must contain one variable for the OTP code – {code2fa}, which will be automatically replaced with the OTP code when the message is sent.

Request example


{   

   "name": "template name",   

   "countries": ["UA","PT","AD","IT"],   

   "text": "test code is {code2fa}" 

}

Response parameters

Parameter Type Description
template_id string Unique, automatically generated by a system identifier of the template within the 2FA service.
name string Name of the template.
text string The text of the template message.
countries string List of countries for which the template is created.
status string Status of the template. After template creation, the status of the template will always be “requested.”
updated_at string Date and time of the last change of the template in ISO 8601 format.

Response example

Response in case of successful request:


{

"data": {

     "template_id": 515,

     "name": "template name",

     "text": "test code is {code2fa}",

     "countries": [

             "AD",

             "IT",

             "PT",

             "UA"

           ],

     "status": "requested",

     "updated_at": "2023-06-30 14:52:58"

    }

}

Possible errors

Code Error Description
422 The number of requests to create a template is limited to 10. Please wait for the manager approve before making a new request. You can have no more than 10 templates with the current status “Requested”. If you already have 10 templates with this status, you need to delete one of them to create a new template. Additionally, if any of the existing templates transitions to the “Approved” or “Rejected” status, it also frees up space for creating a new template.
422 The variable {code2fa} is required in the text This error occurs when the message template text does not contain the required variable {code2fa} or the variable syntax is incorrect. This variable is intended for inserting the actual OTP code into the message text.
422 The {code2fa} variable must occur only once in the text This error occurs when multiple occurrences of the {code2fa} variable are found in the message template text. Please check the entire template text and remove any additional occurrences of the variable.
422 This action is not available for the account of your type Creating a message template for sending OTP codes is not allowed in Demo and Test account mode.
422 User has a template with the identical name! The template with the specified name in the parameter ‘name’ already exists. Please use names that are distinct from your existing templates.

Delete a message template

This method deletes the message template for sending the OTP code based on its unique identifier.

To delete a message template make a request to this URL:

DELETE https://one-api.bsg.world/api/2fa/authentications/templates/{template_id}

Request parameters

Parameter Requires Type Default Description
template_id Yes string No The ID of the message template that you want to delete. From 1 to 9 digits.

Response parameters

If the request is successful, it returns the answer –- Successfully removed.

Codes of errors

Code Error Description
422 Default template is not available for deletion This error occurs when attempting to delete a template that is set as the default template. The default template cannot be deleted.
404 Template not found This error can occur when the template identifier is specified incorrectly or the specified template is not present in the system. Please ensure that you are using the correct template identifier and try again.

Retrieve the list of templates

This method returns a list of message templates for sending OTR code, allowing you to filter them by various parameters.

To retrieve the list of templates make a request to this URL:

GET https://one-api.bsg.world/api/2fa/authentications/templates

Request parameters

Parameter Requires Type Default Description
page[offset] Нет integer 0 Get 2FA templates starting with offset.
page[limit] Нет integer 10 The number of 2FA templates in the response.
filter[ids] Нет array($string) The list of template IDs.
filter[status] Нет string Possible values: requested, rejected, approved.
way Нет string asc Sort options: asc, desc
sort Нет string updated_at Sorting by template_id, status, name, updated_at.

Response parameters

Parameter Type Description
template_id string Unique identifier of the template.
name string The name of the template.
text string The text of the message
countries string List of countries for which the template is created.
status string The status of the template. Possible values:
  • Requested – the template was created successfully and is waiting for approval. You cannot use the template in this status to send the code to the OTR.
  • Rejected – the template has been rejected. You cannot use the template to send the code to the OTP.
  • Approved – the template has been approved and is available for sending messages with the OTP code.
updated_at string Date and time when the template was created or last modified. The display format is ISO 8601: yyyy-mm-dd hh:mm:ss.
total integer A total number of templates that meet the search conditions.

Example of response

Response in case of a successful request:


{

   "data": [

      {

         "template_id": "49",

         "name": "string",

         "countries": [

            "AD",

            "IT",

            "PT",

            "UA"

         ],

         "text": "Your BSG 2FA confirmation code is {code2fa}.",

         "status": "approved",

         "updated_at": "2022-04-18 10:55:35"

      }

   ],

   "total": 1,

   }

}

2FA errors:

One API errors responses:

1.1. Access code expired

1.2. Access code not found

1.3. Authentication canceled status

1.4. Authentication expired

1.5. Authentication failed status

1.6. Authentication invalid status

1.7. Authentication limit with status pending

1.8. Total authentication limit

1.9. Authentication verifying attempts limit

1.10. Authentication not found

1.11. Authentication price not found

1.12. Insufficient funds

1.13. Recipient exists on the stop list

1.14. Authentication channel inactive

1.15. Authentication channel not found

1.16. Template not found

1.17. Default template is not available for deletion

1.18. User has a template with the identical name!

1.19. This action is not available for the account of your type.

1.20. The {code2fa} variable must occur only once in the text

1.21. The variable {code2fa} is required in the text

1.22. The number of requests to create a template is limited to 10. Please wait for the manager approve before making a new request.


{
  "errors": [
    {
      "message": "ERROR_MESSAGE_1"
    }
  ]
}

2. OneAPI validation errors:


{
  "message": "The given data was invalid.",
  "errors": {
    "<FIELD_1>": [
      "<VALIDATION_ERROR_1>"
    ], ...

    "<FIELD_N>": [
      "<VALIDATION_ERROR_N>"
    ]
  }
}

3. OneAPI to 2FA integration errors:

3.1. Raw error 2FA Service response is empty.

3.2. Raw error 2FA Service response has an incorrect content.

3.3. Error 2FA Service response is empty.

3.4. Error 2FA Service response structure is incorrect.

3.5. 2FA Service getting error response error.

3.6. 2FA Service getting successful response error.

3.7. 2FA Service getting response error.

3.8. 2FA Service error.

3.9. 2FA Service getting error response error.

3.10. 2FA Service getting successful response error.

3.11. 2FA Service getting response error.


{
  "message": "<ERROR_MESSAGE>",
  "errors": [
    ...
  ]
}

Interested in a special offer?

Ready to reach further?
Let’s talk

I agree to BSG privacy policy
Submit

Useful Materials

What Is Number Verifier — And Why It’s More Than Just an “HLR Lookup”

30% of SMS fail — not because of content, but numbers. Verify before you send.

10 Awesome Back-to-School Marketing Ideas 2025

The start of the school year: when parents trade in their summer margaritas for the

What Is CPaaS? Communications Platform as a Service

Talking to customers these days is more than just emails or phone calls. Businesses need