Consumer Authentication

/

API reference

/

Time-based one-time passcodes (TOTP)

/

Authenticate

Authenticate TOTP

POSThttps://test.stytch.com/v1/totps/authenticate

Authenticate a TOTP code entered by a user.


Body parameters


user_id*string

totp_code*string

session_custom_claimsmap<string, any>

session_duration_minutesint

session_jwtstring

session_tokenstring

Response fields


status_codeint

request_idstring

totp_idstring

sessionobject

session_jwtstring

session_tokenstring

userobject

user_idstring
curl --request POST \
  --url https://test.stytch.com/v1/totps/authenticate \
  -u 'PROJECT_ID:SECRET' \
  -H 'Content-Type: application/json' \
  -d '{
    "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
    "totp_code": "576831"
  }'

RESPONSE

200
{
  "status_code": 200,
  "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
  "totp_id": "totp-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c",
  "session": null,
  "session_jwt": "",
  "session_token": "",
  "user": {...},
  "user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
}

Common Error Types