Add TOTP device for user
Add a TOTP device for a user and enable TOTP if not already enabled.
POST
/appid-{appId}/recipe/totp/deviceAuthorization
api-keyAPI key · headerrequiredThe core service API token. If you are using a self-hosted core service and you have not generated a token, you can omit the header.
Header parameters
ridstringcdi-versionstringX.Y of the X.Y.Z CDI version.
Request body
application/jsonuserIduserIdrequireddeviceNamestringName of the TOTP device
skewnumberrequiredTime skew in seconds for TOTP validation
periodnumberrequiredTime period in seconds for TOTP code generation
Responses
200Indicates success with the status and secret properties
One of:
object
statusstatusOKAllowed:
OKsecretstringThe TOTP secret key for the device
deviceNamestringName of the created TOTP device
object
statusstringAllowed:
DEVICE_ALREADY_EXISTS_ERROR400error code 400
string401error code 401
string404error code 404
string500error code 500
stringTry it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST "/appid-{appId}/recipe/totp/device" \
-H "api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"deviceName": "My Authy App",
"skew": 0,
"period": 30
}'const response = await fetch("/appid-{appId}/recipe/totp/device", {
method: "POST",
headers: {
"api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"deviceName": "My Authy App",
"skew": 0,
"period": 30
})
});import requests
response = requests.post(
"/appid-{appId}/recipe/totp/device",
headers={
"api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"userId": "fa7a0841-b533-4478-95533-0fde890c3483",
"deviceName": "My Authy App",
"skew": 0,
"period": 30
},
)Response
{
"status": "OK",
"secret": "JBSWY3DPEHPK3PXP",
"deviceName": "d1"
}"string""Invalid API key""Not Found""Internal Error"