Skip to content
Get Started

Get current TOTP code

v2.totp.get_code(strsecret_id) -> TotpGetCodeResponse
GET/api/v2/totp/code/{secret_id}

Generate the current 6- or 8-digit TOTP code for a stored secret, along with how many seconds remain until it rotates.

ParametersExpand Collapse
secret_id: str
ReturnsExpand Collapse
class TotpGetCodeResponse:
code: Optional[str]

The current TOTP code

expires_in: Optional[int]

Seconds until this code rotates

status: Optional[str]

Get current TOTP code

import os
from sendblue_api import SendblueAPI

client = SendblueAPI(
    api_key=os.environ.get("SENDBLUE_API_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SENDBLUE_API_API_SECRET"),  # This is the default and can be omitted
)
response = client.v2.totp.get_code(
    "550e8400-e29b-41d4-a716-446655440000",
)
print(response.code)
{
  "code": "482031",
  "expires_in": 14,
  "status": "OK"
}
Returns Examples
{
  "code": "482031",
  "expires_in": 14,
  "status": "OK"
}