Use to generate a temporary MFA token that can be used in place of other MFA tokens for a set time period. For example, use this token for account recovery when an MFA device has been lost.
Resource URL
https://<subdomain>.onelogin.com/api/2/mfa/users/:user_id/mfa_tokenHeader Parameters
Authorization required string | Set to Set Generate an access token with the API credential pair created using the scope required to call this API. This API can only be called using the |
Content-Type required string | Set to application/json. |
Resource Parameters
user_id required integer | Set to the If you don't know the user's |
Request Parameter
expires_in integer | Set the duration of the token in seconds. Token expiration defaults to 259200 seconds = 72 hours. 72 hours is the max value. |
reusable string | Defines if the token is reusable multiple times within the expiry window. Value defaults to false. If set to |
Sample Request Body
For the sample request, token expires in 300 seconds. The token can be used multiple times within the 300 seconds.
{
"expires_in": "300",
"reusable": true
}Sample Response
- 200 OK
- 401 Unauthorized
- 422 Unprocessable Entity
{
"mfa_token": "25992782",
"expires_at": "2021-07-27T23:25:50Z",
"reusable": false,
"device_id": "user_temp_otp_36216766"
}Typically, this error indicates your access token value is invalid.
{
"statusCode": 401,
"name": "InvalidCredentials",
"message": "Please provide valid credentials"
}The structure of the request payload is correct but it contains an invalid value.
{
"statusCode": 422,
"name": "ValidationError",
"message": "Validations failed",
"details": {
"parameters": []
}
}Response Elements
| Token can function as a temporary MFA token. It can be used to authenticate for any app when valid. |
reusable | true indicates the token can be used multiple times, until it expires. false indicates the token is invalid after a single use or once it expires. Defaults to false. |
expires_at | Defines the expiration time and date for the token. Format is UTC time. |
device_id | A unique identifier for the temp otp device that has been created for this token. |
Postman Collection
Sample Code
cURL
Replace sample values indicated by < > with your actual values.
curl 'https://<subdomain>.onelogin.com/api/2/mfa/users/:user_id/mfa_token' \
-X POST \
-H "Authorization: bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"expires_in":"<300>",
"reusable":"<true>"
}'Have a Question?
Found a problem or a bug? Submit a support ticket.
Looking for walkthroughs or how-to guides? Check out our Knowledge Base.
Have a product idea or request? Share it in our Ideas Portal.