Skip to content

Activate Soft OTP ​

Activates SmartOTP on a device and returns the client secret key plus the TOTP configuration the SDK needs to generate codes.

Endpoint ​

http
POST /api/v1/saas-sotp/activate
Content-Type: application/json
json
{
  "partner_id": "{{partner_id}}",
  "partner_key": "{{partner_key}}",
  "user_id": "{{user_id}}",
  "device_id": "{{device_id}}",
  "device_os": "{{device_os}}",
  "app_version": "{{app_version}}",
  "registration_id": "{{registration_id}}",
  "activation_key": "{{activation_key}}",
  "push_token": "{{push_token}}",
  "token": "{{token}}",
  "metadata": {
    "ios": "test",
    "version": "test"
  }
}

Parameters:

ParamTypeRequiredDefaultDescription
partner_idstringYes—The partner id.
partner_keystringYes—The partner key.
user_idstringYes—The user id.
push_tokenstringYes—The client Firebase token, used to push the challenge key from server to client.
tokenstringYes—The registration token generated by Register.
activation_keystringYes—The activation key generated by Register. It behaves like an OTP code — call Register again for a fresh one before retrying.
registration_idstringNo—The registration ID from Register.
device_idstringNo—The device UUID.
device_osstringNo—The device operating system.
app_versionstringNo—The client app version.
metadataobjectNo—Additional key-value information to store with the activation.

Returns: ActivateResponse

INFO

The endpoint is /api/v1/saas-sotp/activate. Contact the CAKE team if you get a 404.

Sample Request ​

bash
curl --location --request POST '<BASE_URL>/saas-sotp/activate' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data-raw '{
    "partner_id": "{{partner_id}}",
    "partner_key": "{{partner_key}}",
    "user_id": "{{user_id}}",
    "device_id": "{{device_id}}",
    "device_os": "{{device_os}}",
    "app_version": "{{app_version}}",
    "registration_id": "{{registration_id}}",
    "activation_key": "{{activation_key}}",
    "push_token": "{{push_token}}",
    "token": "{{token}}",
    "metadata": {
      "ios": "test",
      "version": "test"
    }
  }'

Response ​

json
{
  "success": true,
  "code": 1,
  "message": "success",
  "data": {
    "key": "fake_client_secret_key",
    "period": 15,
    "algorithm": "HmacSHA512",
    "length": 6,
    "type": "totp",
    "issuer": "SOTP"
  }
}
FieldTypeDescription
successboolRequest status.
codeintThe status code — 1 on success.
data.keystringThe client secret key used to generate OTPs.
data.periodintThe number of seconds an OTP stays valid.
data.algorithmstringThe HMAC algorithm — HmacSHA512.
data.lengthintThe number of digits in an OTP code.
data.typestringThe type of soft OTP — totp.
data.issuerstringThe issuer that generated the OTP.

WARNING

key is the client secret. Hand it straight to the SDK, which stores it behind the user's PIN — never log it, never persist it server-side alongside the user record, and never return it to any caller other than the activating device. Anyone holding it can generate valid basic OTPs indefinitely.

Errors ​

CodeDescription
3Parameter invalid
103Thông tin Partner không chính xác — Partner details are incorrect.
121Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
123Yêu cầu vượt giới hạn. Vui lòng thử lại sau ít phút. — Request limit exceeded.
124OTP không hợp lệ — Invalid OTP. The activation_key did not match.
125OTP hết hạn sử dụng — OTP expired. Call Register for a new activation key.
126Có lỗi xảy ra vui lòng thử lại — An error occurred, please retry.
129Token không hợp lệ — Invalid token.

Next Steps ​

  • Validate OTP — verify the first code generated from this secret
  • Sync Time — reconcile the device clock before generating codes

Developers