LOOMAL
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-2fa
vault.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
}
FieldTypeDescription
codestringCurrent 6-digit TOTP code
remainingnumberSeconds until code rotates
backupCodesRemainingnumberCount 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

StatusCodeDescription
400bad_requestNo TOTP secret found on this credential
404not_foundCredential not found
410expiredCredential has expired

The credential must have a secret field (for TOTP type) or a totp field (for any type with TOTP attached).

On this page