SDK / API ReferenceVault
Get TOTP Code
Generate a 6-digit TOTP code from a stored credential
Scope: vault:read
Returns the current TOTP code and seconds remaining. The secret is never exposed.
Request
import { Loomal } from "@loomal/sdk";
const loomal = new Loomal({ apiKey: process.env.LOOMAL_API_KEY! });
const { code, remaining } = await loomal.vault.totp("github-2fa");import os
from loomal import Loomal
loomal = Loomal(api_key=os.environ["LOOMAL_API_KEY"])
result = loomal.vault.totp("github-2fa")loomal vault totp github-2favault.totp(name="github-2fa")Available through @loomal/mcp — see MCP setup.
curl https://api.loomal.ai/v0/vault/github-2fa/totp \
-H "Authorization: Bearer loid-your-api-key"Response
{
"code": "482916",
"remaining": 18,
"backupCodesRemaining": 8
}| Field | Type | Description |
|---|---|---|
code | string | Current 6-digit TOTP code |
remaining | number | Seconds until code rotates |
backupCodesRemaining | number | Count of single-use backup codes stored on this credential. 0 when none are stored. The codes themselves are never returned here — fetch them via GET /v0/vault/:name (data.backupCodes). |
Errors
| Status | Code | Description |
|---|---|---|
400 | bad_request | No TOTP secret found on this credential |
404 | not_found | Credential not found |
410 | expired | Credential has expired |
The credential must have a secret field (for TOTP type) or a totp field (for any type with TOTP attached).