DylogDocs

Two-factor

TOTP, email codes and backup codes.

POST
/api/auth/two-factor/disable

Use this endpoint to disable two factor authentication.

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/disable" \  -H "Content-Type: application/json" \  -d '{    "password": "string"  }'
{  "status": true}
POST
/api/auth/two-factor/enable

Enable two factor authentication. Pass method 'totp' (default) to set up an authenticator app (returns TOTP URI and backup codes), or 'otp' to enable email/SMS-based codes immediately.

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/enable" \  -H "Content-Type: application/json" \  -d '{    "password": "string"  }'
{  "method": "otp",  "totpURI": "string",  "backupCodes": [    "string"  ]}
POST
/api/auth/two-factor/generate-backup-codes

Generate new backup codes for two-factor authentication

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/generate-backup-codes" \  -H "Content-Type: application/json" \  -d '{    "password": "string"  }'
{  "status": true,  "backupCodes": [    "string"  ]}
POST
/api/auth/two-factor/get-totp-uri

Use this endpoint to get the TOTP URI

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/get-totp-uri" \  -H "Content-Type: application/json" \  -d '{    "password": "string"  }'
{  "totpURI": "string"}
POST
/api/auth/two-factor/send-otp

Send two factor OTP to the user

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/send-otp" \  -H "Content-Type: application/json" \  -d '{}'
{  "status": true}
POST
/api/auth/two-factor/verify-backup-code

Verify a backup code for two-factor authentication

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/verify-backup-code" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "user": {    "id": "string",    "email": "user@example.com",    "emailVerified": true,    "name": "string",    "image": "http://example.com",    "twoFactorEnabled": true,    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  },  "session": {    "token": "string",    "userId": "string",    "createdAt": "2019-08-24T14:15:22Z",    "expiresAt": "2019-08-24T14:15:22Z"  }}
POST
/api/auth/two-factor/verify-otp

Verify two factor OTP

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/verify-otp" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "token": "string",  "user": {    "id": "string",    "email": "user@example.com",    "emailVerified": true,    "name": "string",    "image": "http://example.com",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}
POST
/api/auth/two-factor/verify-totp

Verify two factor TOTP

Authorization

bearerAuth
AuthorizationBearer <token>

Session token from the set-auth-token response header (bearer plugin)

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/auth/two-factor/verify-totp" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "status": true}