# V2 # Totp ## Get Code `client.v2.totp.getCode(stringsecretID, RequestOptionsoptions?): 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 - `secretID: string` ### Returns - `TotpGetCodeResponse` - `code?: string` The current TOTP code - `expires_in?: number` Seconds until this code rotates - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const response = await client.v2.totp.getCode('550e8400-e29b-41d4-a716-446655440000'); console.log(response.code); ``` # Secrets ## Create `client.v2.totp.secrets.create(SecretCreateParamsbody, RequestOptionsoptions?): 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 - `body: SecretCreateParams` - `algorithm?: "SHA1" | "SHA256" | "SHA512"` Hash algorithm - `"SHA1"` - `"SHA256"` - `"SHA512"` - `digits?: 6 | 8` Code length - `6` - `8` - `issuer?: string` Service name (e.g. "GitHub", "Google") - `label?: string` Human-readable label for this secret (e.g. "GitHub - agent@example.com"). Required unless `uri` is provided. - `period?: number` Rotation period in seconds - `secret?: string` Base32-encoded TOTP secret. Omit to auto-generate one. - `uri?: string` Full `otpauth://totp/...` URI from a QR code. Overrides all other fields if provided. ### Returns - `SecretCreateResponse` - `status?: string` - `totp_secret?: TotpSecret` - `id?: string` Unique identifier for this TOTP secret - `algorithm?: "SHA1" | "SHA256" | "SHA512"` Hash algorithm used - `"SHA1"` - `"SHA256"` - `"SHA512"` - `created_at?: string` - `digits?: number` Code length (6 or 8) - `issuer?: string | null` Service name - `label?: string` Human-readable label - `period?: number` Rotation period in seconds - `secret?: string` Base32 secret — only returned on creation, never on list/get ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const secret = await client.v2.totp.secrets.create(); console.log(secret.status); ``` ## List `client.v2.totp.secrets.list(RequestOptionsoptions?): SecretListResponse` **get** `/api/v2/totp/secrets` List all stored TOTP secrets for the account. The encrypted secret values are never returned. ### Returns - `SecretListResponse` - `status?: string` - `totp_secrets?: Array` - `id?: string` Unique identifier for this TOTP secret - `algorithm?: "SHA1" | "SHA256" | "SHA512"` Hash algorithm used - `"SHA1"` - `"SHA256"` - `"SHA512"` - `created_at?: string` - `digits?: number` Code length (6 or 8) - `issuer?: string | null` Service name - `label?: string` Human-readable label - `period?: number` Rotation period in seconds - `secret?: string` Base32 secret — only returned on creation, never on list/get ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const secrets = await client.v2.totp.secrets.list(); console.log(secrets.status); ``` ## Delete `client.v2.totp.secrets.delete(stringsecretID, RequestOptionsoptions?): SecretDeleteResponse` **delete** `/api/v2/totp/secrets/{secret_id}` Permanently delete a stored TOTP secret. ### Parameters - `secretID: string` ### Returns - `SecretDeleteResponse` - `status?: string` ### Example ```typescript import SendblueAPI from 'sendblue'; const client = new SendblueAPI({ apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted }); const secret = await client.v2.totp.secrets.delete('550e8400-e29b-41d4-a716-446655440000'); console.log(secret.status); ```