# V2 # Totp ## Get 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. ### Parameters - `secret_id: str` ### Returns - `class TotpGetCodeResponse: …` - `code: Optional[str]` The current TOTP code - `expires_in: Optional[int]` Seconds until this code rotates - `status: Optional[str]` ### Example ```python 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) ``` # Secrets ## Create `v2.totp.secrets.create(SecretCreateParams**kwargs) -> SecretCreateResponse` **post** `/api/v2/totp/secrets` Store an encrypted TOTP secret for your account. Agents can use this instead of a phone-based authenticator app. Provide either: - A `uri` (the `otpauth://` URI from a QR code scan), which auto-populates all fields - A base32 `secret` with optional `label`, `issuer`, `algorithm`, `digits`, and `period` ### Parameters - `algorithm: Optional[Literal["SHA1", "SHA256", "SHA512"]]` Hash algorithm - `"SHA1"` - `"SHA256"` - `"SHA512"` - `digits: Optional[Literal[6, 8]]` Code length - `6` - `8` - `issuer: Optional[str]` Service name (e.g. "GitHub", "Google") - `label: Optional[str]` Human-readable label for this secret (e.g. "GitHub - agent@example.com"). Required unless `uri` is provided. - `period: Optional[int]` Rotation period in seconds - `secret: Optional[str]` Base32-encoded TOTP secret. Omit to auto-generate one. - `uri: Optional[str]` Full `otpauth://totp/...` URI from a QR code. Overrides all other fields if provided. ### Returns - `class SecretCreateResponse: …` - `status: Optional[str]` - `totp_secret: Optional[TotpSecret]` - `id: Optional[str]` Unique identifier for this TOTP secret - `algorithm: Optional[Literal["SHA1", "SHA256", "SHA512"]]` Hash algorithm used - `"SHA1"` - `"SHA256"` - `"SHA512"` - `created_at: Optional[datetime]` - `digits: Optional[int]` Code length (6 or 8) - `issuer: Optional[str]` Service name - `label: Optional[str]` Human-readable label - `period: Optional[int]` Rotation period in seconds - `secret: Optional[str]` Base32 secret — only returned on creation, never on list/get ### Example ```python 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 ) secret = client.v2.totp.secrets.create() print(secret.status) ``` ## List `v2.totp.secrets.list() -> SecretListResponse` **get** `/api/v2/totp/secrets` List all stored TOTP secrets for the account. The encrypted secret values are never returned. ### Returns - `class SecretListResponse: …` - `status: Optional[str]` - `totp_secrets: Optional[List[TotpSecret]]` - `id: Optional[str]` Unique identifier for this TOTP secret - `algorithm: Optional[Literal["SHA1", "SHA256", "SHA512"]]` Hash algorithm used - `"SHA1"` - `"SHA256"` - `"SHA512"` - `created_at: Optional[datetime]` - `digits: Optional[int]` Code length (6 or 8) - `issuer: Optional[str]` Service name - `label: Optional[str]` Human-readable label - `period: Optional[int]` Rotation period in seconds - `secret: Optional[str]` Base32 secret — only returned on creation, never on list/get ### Example ```python 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 ) secrets = client.v2.totp.secrets.list() print(secrets.status) ``` ## Delete `v2.totp.secrets.delete(strsecret_id) -> SecretDeleteResponse` **delete** `/api/v2/totp/secrets/{secret_id}` Permanently delete a stored TOTP secret. ### Parameters - `secret_id: str` ### Returns - `class SecretDeleteResponse: …` - `status: Optional[str]` ### Example ```python 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 ) secret = client.v2.totp.secrets.delete( "550e8400-e29b-41d4-a716-446655440000", ) print(secret.status) ```