Start typing to search.

API Reference

Verify TOTP code

View Markdown

Completes login by verifying the TOTP code. Sets the full session cookie on success.

POST /api/auth/verify-totp

Completes login by verifying the TOTP code. Sets the full session cookie on success.

Operation ID: verifyTotp

Authentication

No authentication is required.

Request body

The request body is required.

application/json

  • Type: object
  • Properties:
    • code (string, required)

Success responses

200

TOTP verified, session established

Content type: application/json

  • Type: object
  • Properties:
    • success (boolean)

Error responses

400

Missing pending session cookie or TOTP code. Messages distinguish the two cases so the client can recover (re-login vs re-enter code).

401

Not authenticated

Content type: application/json

  • Reference: Error
    • Type: object
    • Properties:
      • error (string)
        • Example: NOT_FOUND
      • message (string)
        • Example: Resource not found

Example:

{
  "error": "AUTH_ERROR",
  "message": "Not authenticated"
}

429

Too many requests

Content type: application/json

  • Reference: Error
    • Type: object
    • Properties:
      • error (string)
        • Example: NOT_FOUND
      • message (string)
        • Example: Resource not found

Example:

{
  "error": "RATE_LIMITED",
  "message": "Too many failed TOTP attempts. Try again later."
}

Examples

cURL

curl --request POST \
  --url 'https://your-envoy.example.com/api/auth/verify-totp' \
  --header 'Content-Type: application/json' \
  --data '{
  "code": "string"
}'

JavaScript (fetch)

const response = await fetch('https://your-envoy.example.com/api/auth/verify-totp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "code": "string"
  }),
});
 
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);