See api-docs Menu

Enroll an Authentication Factor


Use this API to initiate enrollment for user with a given authentication factor.

If the authentication factor requires confirmation to complete, then the device will have an status of pending otherwise it will have a status of accepted (corresponding to devices that are either pending confirmation or not)

To change the state of the device to be accepted, the registration id, and the `otp` would need to be sent to the Verify a Factor endpoint.

For OneLogin Voice, the end user must type the OTP code into the phone, and verification can be complted using this Verify a Factor endpoint.

The API supports enrollment of support for SMS, Voice, Email, Google Authenticator, and OneLogin Protect. Other factors can be enrolled manually by the user.

Resource URL

https://<subdomain>/api/2/mfa/users/<user_id>/registrations

Header Parameter

Authorization

required

string

Set to bearer:<access_token>.

Set <access_token> to the access token you generated using the Generate Token API.

The access token must have been generated using an API credential pair created using the scope required to call this API. This API can be called using the Manage All scope.

Resource Parameter

user_id

required

integer

Set to the id of the user.

If you don’t know the user’s id, use the Get Users API call to return all users and their id values.

Request Parameters

factor_id

required

integer

The identifier of the factor to enroll the user with.

See Get Available Factors for a list of possible id values.

display_name

required

string

A name for the users device

expires_in

string

Defaults to 120. Valid values are: 120-900 seconds.

verified

boolean

Defaults to false. The following factors support verified = true as part of the initial registration request: OneLogin SMS, OneLogin Voice, OneLogin Email. When using verified = true it is critical that the supported factors have pre-verified values, most likely imported from an existing directory or by the users themselvdes.

Factors such as Authenticator and OneLogin Protect do not support verification = true as the user interaction is required to verify the factor.

redirect_to

string

Optional. Only applies to Email MagicLink factor.

Redirects MagicLink success page to specified URL after 2 seconds. Email must already be configured by the user.

custom_message

string

Optional. Only applies to SMS factor.

A message template that will be sent via SMS. Max length of the message after template items are inserted is 160 characters including the OTP code. SMS must already be configured by the user.

The following template variables can be included in the message.

  • {{otp_code}} - The security code.
  • {{otp_expiry}} - The number of minutes until the one time code expires.

Request Body

{
    "factor_id": 58959,
    "display_name": "OneLogin SMS"
}

Sample Responses

OneLogin SMS

[
  {
    "id": "a89ea78d-59fd-4ec2-8b62-b6796ff9e7b3",
    "status": "pending",
    "auth_factor_name": "SMS",
    "type_display_name": "OneLogin SMS",
    "user_display_name": "OneLogin SMS",
    "expires_at": "2020-07-21T17:27:34Z"
  }
]
  
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Protect

[
  {
    "id": "36c6cf4c-a315-46ce-81f9-a91a475488cf",
    "status": "pending",
    "auth_factor_name": "OneLogin",
    "type_display_name": "OneLogin Protect",
    "user_display_name": "OneLogin Protect",
    "factor_data": {
        "verification_token": "01-1912451",
        "totp_url": "otpauth://totp/bsimons:brandon.simons%2Badmin%40onelogin.com?secret=01-1912451"
    }
  ]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Voice

[
  {
      "id": "500b41d2-4c6d-4fb3-928b-44d8c0afa19b",
      "status": "pending",
      "auth_factor_name": "OneLogin Voice",
      "type_display_name": "OneLogin Voice",
      "user_display_name": "OneLogin Voice",
      "expires_at": "2020-07-21T18:11:54Z",
      "factor_data": {
          "verification_token": "144613"
      }
  }
]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

OneLogin Email

[
  {
      "id": "83bf1253-2011-4f75-aa67-c100330156f5",
      "status": "pending",
      "auth_factor_name": "OneLogin Email",
      "type_display_name": "OneLogin Email",
      "user_display_name": "OneLogin Email",
      "expires_at": "2020-07-21T18:14:09Z"
  }
]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

Authenticator

[
  {
      "id": "922f6f3b-424a-43eb-aafb-3f45596f0fc5",
      "status": "pending",
      "auth_factor_name": "Google Authenticator",
      "type_display_name": "Authenticator",
      "user_display_name": "Authenticator",
      "factor_data": {
          "verification_token": "d5j3sck2s7hh3nxzkxj5p7nt5yk2a75d",
          "totp_url": "otpauth://totp/brandon.simons%2Badmin%40onelogin.com?secret=d5j3sck2s7hh3nxzkxj5p7nt5yk2a75d&issuer=bsimons"
      }
  }
  ]
{
    "statusCode": 401,
    "name": "InvalidCredentials",
    "message": "Please provide valid credentials"
}

Response Elements

status

accepted : factor has been verified. pending: registered but has not been verified.

default True = is user’s default MFA device for OneLogin.
expires_at A short lived token that is required to Verify the Factor. This token expires based on the expires_in parameter passed in.
auth_factor_name "Official" authentication factor name, as it appears to administrators in OneLogin.
type_display_name Authentication factor display name as it appears to users upon initial registration, as defined by admins at Settings > Authentication Factors.
user_display_name Authentication factor display name assigned by users when they enroll the device.
id MFA device identifier.
factor_data Array of factor specific properties. For example, the token or totp code for OneLogin Protect.
verification_token The token which can be used to verify the factor registration.
totp_url OTP Url that can be leveraged for any authenticator that supports the key uri format. Url can be used with client libraries to display QR Code for streamlined end-user registration.

Postman Collection

Replace sample variables indicated by {{ }} with your actual values.

Download for the MFA API

Sample Code

cURL

Replace sample values indicated by < > with your actual values.

curl 'https://<subdomain>/api/2/mfa/users/<user_id>/registrations' \
-X POST \
-H "Authorization: bearer: <access_token>" \
-H "Content-Type: application/json" \
-d '{
  "factor_id": 16282,
  "display_name":  "Rich's Phone"
}'

Have a Question?

Found a problem or a bug? Submit a support ticket.

Looking for walkthroughs or how-to guides on OneLogin's user and admin features? Check out the documentation in our Knowledge Base.

Have a product idea or request? Share it with us in our Ideas Portal.