Create TOTP device
Creates an unverified totp device
POST
/{apiBasePath}/totp/deviceAuthorization
AuthorizationBearer token · headerrequiredReturned as the "st-access-token" header from sign-in and refresh endpoints and present on requests that update the access token payload
or
sAccessTokenAPI key · cookierequiredThis is an HTTPOnly cookie, set by sign-in and refresh endpoints and present on requests that update the access token
Path parameters
apiBasePathstringrequiredIts value depends on the apiBasePath set by the user
Header parameters
ridstringThe TOTP recipe ID
anti-csrftokenThis will only be here if enabled by the user.
Request body
application/jsondeviceNamestringResponses
200Information about the created (unverified) device. Based on the this,
the user can add the device to their TOTP app and verify it.
One of:
object
statusstatusOKSuccess status indicator
Allowed:
OKdeviceNamestringqrCodeStringstringsecretstringobject
statusstringAllowed:
DEVICE_ALREADY_EXISTS_ERRORgeneralErrorResponse
statusstringError status code
Allowed:
GENERAL_ERRORmessagestringError message
403A claim validation error happened during factor setup
One of:
object
messagestringError message
claimValidationErrorsobject[]List of claim validation errors
Show propertiesHide properties
Array of
objectidstringThe claim ID
reasonobjectThe reason for the validation error
object
messagestringError message
claimValidationErrorsobject[]List of claim validation errors
Show propertiesHide properties
Array of
objectidstringThe claim ID
reasonstringThe reason for the validation error
404Resource not found error
string500Internal server error
stringTry it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST "/auth/totp/device" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"deviceName": "asdf123"
}'const response = await fetch("/auth/totp/device", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"deviceName": "asdf123"
})
});import requests
response = requests.post(
"/auth/totp/device",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"deviceName": "asdf123"
},
)Response
{
"status": "OK",
"deviceName": "asfd123",
"qrCodeString": "otpauth://totp/Supertokens:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Supertokens",
"secret": "JBSWY3DPEHPK3PXP"
}{
"message": "invalid claim",
"claimValidationErrors": [
{
"id": "st-ev",
"reason": {
"message": "wrong value",
"expectedValue": true,
"actualValue": false
}
}
]
}"Not Found""Internal Error"