Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Stytch Consumer Authentication TOTP API
version: 2.0.0
description: Stytch's Consumer API for passwordless and password-based authentication. Supports Magic Links, SMS/email/WhatsApp OTP, OAuth social login, TOTP, WebAuthn/Passkeys, Crypto Wallets, Sessions, Users, M2M tokens, Fraud / Device Fingerprinting, Connected Apps (OAuth provider / MCP), Impersonation, IDP, and Consumer RBAC.
contact:
name: Stytch
url: https://stytch.com/docs
license:
name: Proprietary
servers:
- url: https://api.stytch.com
description: Production
- url: https://test.stytch.com
description: Test
tags:
- name: TOTP
paths:
/v1/totps:
post:
summary: Create
operationId: api_totp_v1_Create
tags:
- TOTP
description: Create a new TOTP instance for a user. The user can use the authenticator application of their choice to scan the QR code or enter the secret.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_CreateRequest'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_CreateResponse'
'400':
description: Bad request
'401':
description: Unauthorized
content:
application/json:
example:
status_code: 401
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: unauthorized_credentials
error_message: Unauthorized credentials.
error_url: https://stytch.com/docs/api/errors/401
'429':
description: Too Many Requests
content:
application/json:
example:
status_code: 429
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: too_many_requests
error_message: Too many requests have been made.
error_url: https://stytch.com/docs/api/errors/429
'500':
description: Internal server error
content:
application/json:
example:
status_code: 500
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: internal_server_error
error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
error_url: https://stytch.com/docs/api/errors/500
x-code-samples:
- lang: csharp
label: C#
source: "// POST /v1/totps\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n};\n\nclient.TOTPs.Create(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: go
label: Go
source: "// POST /v1/totps\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/stytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/totps\"\n)\n\nfunc main() {\n\tclient, err := stytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &totps.CreateParams{\n\t\tUserID: \"${userId}\",\n\t}\n\n\tresp, err := client.TOTPs.Create(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
- lang: java
label: Java
source: "// POST /v1/totps\npackage com.example;\n\nimport com.stytch.java.common.StytchResult;\nimport com.stytch.java.consumer.models.totps.CreateRequest;\nimport com.stytch.java.consumer.StytchClient;\n\npublic class Main {\n public static void main(String[] args) {\n StytchClient.configure(\"${projectId}\", \"${secret}\");\n\n CreateRequest params = new CreateRequest();\n params.setUserId(\"${userId}\");\n\n Object result = StytchClient.getTOTPs().create(params);\n if (result instanceof StytchResult.Success) {\n System.out.println(((StytchResult.Success) result).getValue());\n } else {\n System.out.println(((StytchResult.Error) result).getException());\n }\n }\n}"
- lang: kotlin
label: Kotlin
source: "// POST /v1/totps\npackage com.example\n\nimport com.stytch.java.consumer.StytchClient\nimport com.stytch.java.consumer.models.totps.CreateRequest\n\nfun main() {\n StytchClient.configure(\n projectId = \"${projectId}\",\n secret = \"${secret}\",\n )\n\n when (\n val result =\n StytchClient.totps.create(\n CreateRequest(\n userId = \"${userId}\",\n ),\n )\n ) {\n is StytchResult.Success -> println(result.value)\n is StytchResult.Error -> println(result.exception)\n }\n}\n"
- lang: javascript
label: Node.js
source: "// POST /v1/totps\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n};\n\nclient.totps.create(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: php
label: PHP
source: "$response = $client->totps->create([\n 'user_id' => '${userId}',\n]);"
- lang: python
label: Python
source: "# POST /v1/totps\nfrom stytch import Client\n\nclient = Client(\n project_id=\"${projectId}\",\n secret=\"${secret}\",\n)\n\nresp = client.totps.create(\n user_id=\"${userId}\",\n)\n\nprint(resp)\n"
- lang: ruby
label: Ruby
source: "# POST /v1/totps\nrequire 'stytch'\n\nclient = Stytch::Client.new(\n project_id: \"${projectId}\",\n secret: \"${secret}\"\n)\n\nresp = client.totps.create(\n user_id: \"${userId}\"\n \n)\n\nputs resp"
- lang: rust
label: Rust
source: "// POST /v1/totps\nuse stytch::consumer::client::Client;\nuse stytch::consumer::totps::CreateRequest;\n\nfn main() {\n let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n let resp = client.totps.create(\n CreateRequest{\n user_id: \"${userId}\",\n ..Default::default()\n }\n ).await;\n println!(\"The response is {:?}\", resp);\n}"
- lang: bash
label: cURL
source: "# POST /v1/totps\ncurl --request POST \\\n --url https://test.stytch.com/v1/totps \\\n -u '${projectId}:${secret}' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"user_id\": \"${userId}\"\n }'"
/v1/totps/authenticate:
post:
summary: Authenticate
operationId: api_totp_v1_Authenticate
tags:
- TOTP
description: Authenticate a TOTP code entered by a user.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_AuthenticateRequest'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_AuthenticateResponse'
'400':
description: Bad request
'401':
description: Unauthorized
content:
application/json:
example:
status_code: 401
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: unauthorized_credentials
error_message: Unauthorized credentials.
error_url: https://stytch.com/docs/api/errors/401
'429':
description: Too Many Requests
content:
application/json:
example:
status_code: 429
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: too_many_requests
error_message: Too many requests have been made.
error_url: https://stytch.com/docs/api/errors/429
'500':
description: Internal server error
content:
application/json:
example:
status_code: 500
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: internal_server_error
error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
error_url: https://stytch.com/docs/api/errors/500
x-code-samples:
- lang: csharp
label: C#
source: "// POST /v1/totps/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n totp_code: \"${exampleTotpCode}\",\n session_duration_minutes: 60,\n};\n\nclient.TOTPs.Authenticate(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: go
label: Go
source: "// POST /v1/totps/authenticate\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/stytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/totps\"\n)\n\nfunc main() {\n\tclient, err := stytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &totps.AuthenticateParams{\n\t\tUserID: \"${userId}\",\n\t\tTOTPCode: \"${exampleTotpCode}\",\n\t\tSessionDurationMinutes: 60,\n\t}\n\n\tresp, err := client.TOTPs.Authenticate(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
- lang: java
label: Java
source: "// POST /v1/totps/authenticate\npackage com.example;\n\nimport com.stytch.java.common.StytchResult;\nimport com.stytch.java.consumer.models.totps.AuthenticateRequest;\nimport com.stytch.java.consumer.StytchClient;\n\npublic class Main {\n public static void main(String[] args) {\n StytchClient.configure(\"${projectId}\", \"${secret}\");\n\n AuthenticateRequest params = new AuthenticateRequest();\n params.setUserId(\"${userId}\");\n params.setTOTPCode(\"${exampleTotpCode}\");\n params.setSessionDurationMinutes(60);\n\n Object result = StytchClient.getTOTPs().authenticate(params);\n if (result instanceof StytchResult.Success) {\n System.out.println(((StytchResult.Success) result).getValue());\n } else {\n System.out.println(((StytchResult.Error) result).getException());\n }\n }\n}"
- lang: kotlin
label: Kotlin
source: "// POST /v1/totps/authenticate\npackage com.example\n\nimport com.stytch.java.consumer.StytchClient\nimport com.stytch.java.consumer.models.totps.AuthenticateRequest\n\nfun main() {\n StytchClient.configure(\n projectId = \"${projectId}\",\n secret = \"${secret}\",\n )\n\n when (\n val result =\n StytchClient.totps.authenticate(\n AuthenticateRequest(\n userId = \"${userId}\",\n totpCode = \"${exampleTotpCode}\",\n sessionDurationMinutes = 60,\n ),\n )\n ) {\n is StytchResult.Success -> println(result.value)\n is StytchResult.Error -> println(result.exception)\n }\n}\n"
- lang: javascript
label: Node.js
source: "// POST /v1/totps/authenticate\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n totp_code: \"${exampleTotpCode}\",\n session_duration_minutes: 60,\n};\n\nclient.totps.authenticate(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: php
label: PHP
source: "$response = $client->totps->authenticate([\n 'user_id' => '${userId}',\n 'totp_code' => '${exampleTotpCode}',\n 'session_duration_minutes' => 60,\n]);"
- lang: python
label: Python
source: "# POST /v1/totps/authenticate\nfrom stytch import Client\n\nclient = Client(\n project_id=\"${projectId}\",\n secret=\"${secret}\",\n)\n\nresp = client.totps.authenticate(\n user_id=\"${userId}\",\n totp_code=\"${exampleTotpCode}\",\n session_duration_minutes=60,\n)\n\nprint(resp)\n"
- lang: ruby
label: Ruby
source: "# POST /v1/totps/authenticate\nrequire 'stytch'\n\nclient = Stytch::Client.new(\n project_id: \"${projectId}\",\n secret: \"${secret}\"\n)\n\nresp = client.totps.authenticate(\n user_id: \"${userId}\",\n totp_code: \"${exampleTotpCode}\",\n session_duration_minutes: 60\n \n)\n\nputs resp"
- lang: rust
label: Rust
source: "// POST /v1/totps/authenticate\nuse stytch::consumer::client::Client;\nuse stytch::consumer::totps::AuthenticateRequest;\n\nfn main() {\n let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n let resp = client.totps.authenticate(\n AuthenticateRequest{\n user_id: \"${userId}\",\n totp_code: \"${exampleTotpCode}\",\n session_duration_minutes: 60,\n ..Default::default()\n }\n ).await;\n println!(\"The response is {:?}\", resp);\n}"
- lang: bash
label: cURL
source: "# POST /v1/totps/authenticate\ncurl --request POST \\\n --url https://test.stytch.com/v1/totps/authenticate \\\n -u '${projectId}:${secret}' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"user_id\": \"${userId}\",\n \"totp_code\": \"${exampleTotpCode}\",\n \"session_duration_minutes\": 60\n }'"
/v1/totps/recovery_codes:
post:
summary: Recoverycodes
operationId: api_totp_v1_RecoveryCodes
tags:
- TOTP
description: Retrieve the recovery codes for a TOTP instance tied to a User.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_RecoveryCodesRequest'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_RecoveryCodesResponse'
'400':
description: Bad request
'401':
description: Unauthorized
content:
application/json:
example:
status_code: 401
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: unauthorized_credentials
error_message: Unauthorized credentials.
error_url: https://stytch.com/docs/api/errors/401
'429':
description: Too Many Requests
content:
application/json:
example:
status_code: 429
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: too_many_requests
error_message: Too many requests have been made.
error_url: https://stytch.com/docs/api/errors/429
'500':
description: Internal server error
content:
application/json:
example:
status_code: 500
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: internal_server_error
error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
error_url: https://stytch.com/docs/api/errors/500
x-code-samples:
- lang: csharp
label: C#
source: "// POST /v1/totps/recovery_codes\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n};\n\nclient.TOTPs.RecoveryCodes(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: go
label: Go
source: "// POST /v1/totps/recovery_codes\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/stytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/totps\"\n)\n\nfunc main() {\n\tclient, err := stytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &totps.RecoveryCodesParams{\n\t\tUserID: \"${userId}\",\n\t}\n\n\tresp, err := client.TOTPs.RecoveryCodes(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
- lang: java
label: Java
source: "// POST /v1/totps/recovery_codes\npackage com.example;\n\nimport com.stytch.java.common.StytchResult;\nimport com.stytch.java.consumer.models.totps.RecoveryCodesRequest;\nimport com.stytch.java.consumer.StytchClient;\n\npublic class Main {\n public static void main(String[] args) {\n StytchClient.configure(\"${projectId}\", \"${secret}\");\n\n RecoveryCodesRequest params = new RecoveryCodesRequest();\n params.setUserId(\"${userId}\");\n\n Object result = StytchClient.getTOTPs().recoveryCodes(params);\n if (result instanceof StytchResult.Success) {\n System.out.println(((StytchResult.Success) result).getValue());\n } else {\n System.out.println(((StytchResult.Error) result).getException());\n }\n }\n}"
- lang: kotlin
label: Kotlin
source: "// POST /v1/totps/recovery_codes\npackage com.example\n\nimport com.stytch.java.consumer.StytchClient\nimport com.stytch.java.consumer.models.totps.RecoveryCodesRequest\n\nfun main() {\n StytchClient.configure(\n projectId = \"${projectId}\",\n secret = \"${secret}\",\n )\n\n when (\n val result =\n StytchClient.totps.recoveryCodes(\n RecoveryCodesRequest(\n userId = \"${userId}\",\n ),\n )\n ) {\n is StytchResult.Success -> println(result.value)\n is StytchResult.Error -> println(result.exception)\n }\n}\n"
- lang: javascript
label: Node.js
source: "// POST /v1/totps/recovery_codes\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n};\n\nclient.totps.recoveryCodes(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: php
label: PHP
source: "$response = $client->totps->recovery_codes([\n 'user_id' => '${userId}',\n]);"
- lang: python
label: Python
source: "# POST /v1/totps/recovery_codes\nfrom stytch import Client\n\nclient = Client(\n project_id=\"${projectId}\",\n secret=\"${secret}\",\n)\n\nresp = client.totps.recovery_codes(\n user_id=\"${userId}\",\n)\n\nprint(resp)\n"
- lang: ruby
label: Ruby
source: "# POST /v1/totps/recovery_codes\nrequire 'stytch'\n\nclient = Stytch::Client.new(\n project_id: \"${projectId}\",\n secret: \"${secret}\"\n)\n\nresp = client.totps.recovery_codes(\n user_id: \"${userId}\"\n \n)\n\nputs resp"
- lang: rust
label: Rust
source: "// POST /v1/totps/recovery_codes\nuse stytch::consumer::client::Client;\nuse stytch::consumer::totps::RecoveryCodesRequest;\n\nfn main() {\n let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n let resp = client.totps.recovery_codes(\n RecoveryCodesRequest{\n user_id: \"${userId}\",\n ..Default::default()\n }\n ).await;\n println!(\"The response is {:?}\", resp);\n}"
- lang: bash
label: cURL
source: "# POST /v1/totps/recovery_codes\ncurl --request POST \\\n --url https://test.stytch.com/v1/totps/recovery_codes \\\n -u '${projectId}:${secret}' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"user_id\": \"${userId}\"\n }'"
/v1/totps/recover:
post:
summary: Recover
operationId: api_totp_v1_Recover
tags:
- TOTP
description: Authenticate a recovery code for a TOTP instance.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_RecoverRequest'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/api_totp_v1_RecoverResponse'
'400':
description: Bad request
'401':
description: Unauthorized
content:
application/json:
example:
status_code: 401
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: unauthorized_credentials
error_message: Unauthorized credentials.
error_url: https://stytch.com/docs/api/errors/401
'429':
description: Too Many Requests
content:
application/json:
example:
status_code: 429
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: too_many_requests
error_message: Too many requests have been made.
error_url: https://stytch.com/docs/api/errors/429
'500':
description: Internal server error
content:
application/json:
example:
status_code: 500
request_id: request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141
error_type: internal_server_error
error_message: Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.
error_url: https://stytch.com/docs/api/errors/500
x-code-samples:
- lang: csharp
label: C#
source: "// POST /v1/totps/recover\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n recovery_code: \"${exampleTotpRecoveryCode}\",\n session_duration_minutes: 60,\n};\n\nclient.TOTPs.Recover(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: go
label: Go
source: "// POST /v1/totps/recover\npackage main\n\nimport (\n\t\"context\"\n\t\"log\"\n\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/stytchapi\"\n\t\"github.com/stytchauth/stytch-go/v17/stytch/consumer/totps\"\n)\n\nfunc main() {\n\tclient, err := stytchapi.NewClient(\n\t\t\"${projectId}\",\n\t\t\"${secret}\",\n\t)\n\tif err != nil {\n\t\tlog.Fatalf(\"error instantiating client: %v\", err)\n\t}\n\n\tparams := &totps.RecoverParams{\n\t\tUserID: \"${userId}\",\n\t\tRecoveryCode: \"${exampleTotpRecoveryCode}\",\n\t\tSessionDurationMinutes: 60,\n\t}\n\n\tresp, err := client.TOTPs.Recover(context.Background(), params)\n\tif err != nil {\n\t\tlog.Fatalf(\"error in method call: %v\", err)\n\t}\n\n\tlog.Println(resp)\n}\n"
- lang: java
label: Java
source: "// POST /v1/totps/recover\npackage com.example;\n\nimport com.stytch.java.common.StytchResult;\nimport com.stytch.java.consumer.models.totps.RecoverRequest;\nimport com.stytch.java.consumer.StytchClient;\n\npublic class Main {\n public static void main(String[] args) {\n StytchClient.configure(\"${projectId}\", \"${secret}\");\n\n RecoverRequest params = new RecoverRequest();\n params.setUserId(\"${userId}\");\n params.setRecoveryCode(\"${exampleTotpRecoveryCode}\");\n params.setSessionDurationMinutes(60);\n\n Object result = StytchClient.getTOTPs().recover(params);\n if (result instanceof StytchResult.Success) {\n System.out.println(((StytchResult.Success) result).getValue());\n } else {\n System.out.println(((StytchResult.Error) result).getException());\n }\n }\n}"
- lang: kotlin
label: Kotlin
source: "// POST /v1/totps/recover\npackage com.example\n\nimport com.stytch.java.consumer.StytchClient\nimport com.stytch.java.consumer.models.totps.RecoverRequest\n\nfun main() {\n StytchClient.configure(\n projectId = \"${projectId}\",\n secret = \"${secret}\",\n )\n\n when (\n val result =\n StytchClient.totps.recover(\n RecoverRequest(\n userId = \"${userId}\",\n recoveryCode = \"${exampleTotpRecoveryCode}\",\n sessionDurationMinutes = 60,\n ),\n )\n ) {\n is StytchResult.Success -> println(result.value)\n is StytchResult.Error -> println(result.exception)\n }\n}\n"
- lang: javascript
label: Node.js
source: "// POST /v1/totps/recover\nconst stytch = require('stytch');\n\nconst client = new stytch.Client({\n project_id: '${projectId}',\n secret: '${secret}',\n});\n\nconst params = {\n user_id: \"${userId}\",\n recovery_code: \"${exampleTotpRecoveryCode}\",\n session_duration_minutes: 60,\n};\n\nclient.totps.recover(params)\n .then(resp => { console.log(resp) })\n .catch(err => { console.log(err) });"
- lang: php
label: PHP
source: "$response = $client->totps->recover([\n 'user_id' => '${userId}',\n 'recovery_code' => '${exampleTotpRecoveryCode}',\n 'session_duration_minutes' => 60,\n]);"
- lang: python
label: Python
source: "# POST /v1/totps/recover\nfrom stytch import Client\n\nclient = Client(\n project_id=\"${projectId}\",\n secret=\"${secret}\",\n)\n\nresp = client.totps.recover(\n user_id=\"${userId}\",\n recovery_code=\"${exampleTotpRecoveryCode}\",\n session_duration_minutes=60,\n)\n\nprint(resp)\n"
- lang: ruby
label: Ruby
source: "# POST /v1/totps/recover\nrequire 'stytch'\n\nclient = Stytch::Client.new(\n project_id: \"${projectId}\",\n secret: \"${secret}\"\n)\n\nresp = client.totps.recover(\n user_id: \"${userId}\",\n recovery_code: \"${exampleTotpRecoveryCode}\",\n session_duration_minutes: 60\n \n)\n\nputs resp"
- lang: rust
label: Rust
source: "// POST /v1/totps/recover\nuse stytch::consumer::client::Client;\nuse stytch::consumer::totps::RecoverRequest;\n\nfn main() {\n let client = Client::new(\"${projectId}\", \"${secret}\").unwrap();\n let resp = client.totps.recover(\n RecoverRequest{\n user_id: \"${userId}\",\n recovery_code: \"${exampleTotpRecoveryCode}\",\n session_duration_minutes: 60,\n ..Default::default()\n }\n ).await;\n println!(\"The response is {:?}\", resp);\n}"
- lang: bash
label: cURL
source: "# POST /v1/totps/recover\ncurl --request POST \\\n --url https://test.stytch.com/v1/totps/recover \\\n -u '${projectId}:${secret}' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"user_id\": \"${userId}\",\n \"recovery_code\": \"${exampleTotpRecoveryCode}\",\n \"session_duration_minutes\": 60\n }'"
components:
schemas:
api_session_v1_AuthenticationFactorDeliveryMethod:
type: string
enum:
- email
- sms
- whatsapp
- embedded
- oauth_google
- oauth_microsoft
- oauth_apple
- webauthn_registration
- authenticator_app
- oauth_github
- recovery_code
- oauth_facebook
- crypto_wallet
- oauth_amazon
- oauth_bitbucket
- oauth_coinbase
- oauth_discord
- oauth_figma
- oauth_gitlab
- oauth_instagram
- oauth_linkedin
- oauth_shopify
- oauth_slack
- oauth_snapchat
- oauth_spotify
- oauth_steam
- oauth_tiktok
- oauth_twitch
- oauth_twitter
- knowledge
- biometric
- sso_saml
- sso_oidc
- oauth_salesforce
- oauth_yahoo
- oauth_hubspot
- imported_auth0
- oauth_exchange_slack
- oauth_exchange_hubspot
- oauth_exchange_github
- oauth_exchange_google
- impersonation
- oauth_access_token_exchange
- trusted_token_exchange
api_session_v1_OAuthAccessTokenExchangeFactor:
type: object
properties:
client_id:
type: string
description: The ID of the Connected App client.
required:
- client_id
api_user_v1_BiometricRegistration:
type: object
properties:
biometric_registration_id:
type: string
description: The unique ID for a biometric registration.
verified:
type: boolean
description: The verified boolean denotes whether or not this send method, e.g. phone number, email address, etc., has been successfully authenticated by the User.
required:
- biometric_registration_id
- verified
api_session_v1_InstagramOAuthFactor:
type: object
properties:
id:
type: string
provider_subject:
type: string
email_id:
type: string
required:
- id
- provider_subject
api_session_v1_SteamOAuthFactor:
type: object
properties:
id:
type: string
provider_subject:
type: string
email_id:
type: string
required:
- id
- provider_subject
api_session_v1_GitLabOAuthFactor:
type: object
properties:
id:
type: string
provider_subject:
type: string
email_id:
type: string
required:
- id
- provider_subject
api_totp_v1_CreateRequest:
type: object
properties:
user_id:
type: string
description: The `user_id` of an active user the TOTP registration should be tied to. You may use an `external_id` here if one is set for the user.
expiration_minutes:
type: integer
format: int32
description: The expiration for the TOTP instance. If the newly created TOTP is not authenticated within this time frame the TOTP will be unusable. Defaults to 1440 (1 day) with a minimum of 5 and a maximum of 1440.
description: Request type
required:
- user_id
api_session_v1_SAMLSSOFactor:
type: object
properties:
id:
type: string
description: The unique ID of an SSO Registration.
provider_id:
type: string
description: Globally unique UUID that identifies a specific SAML Connection.
external_id:
type: string
description: The ID of the member given by the identity provider.
required:
- id
- provider_id
- external_id
api_session_v1_LinkedInOAuthFactor:
type: object
properties:
id:
type: string
provider_subject:
type: string
email_id:
type: string
required:
- id
- provider_subject
api_session_v1_BitbucketOAuthFactor:
type: object
properties:
id:
type: string
provider_subject:
type: string
email_id:
type: string
required:
- id
- provider_subject
api_session_v1_ImpersonatedFactor:
type: object
properties:
impersonator_id:
type: string
description: For impersonated sessions initiated via the Stytch Dashboard, the `impersonator_id` will be the impersonator's Stytch Dashboard `member_id`.
impersonator_e
# --- truncated at 32 KB (77 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/stytch/refs/heads/main/openapi/stytch-totp-api-openapi.yml