> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agent-loadout.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TOTP Codes API: Get Authenticator Codes from the Vault

> Store an authenticator seed alongside a login or API key and retrieve its current code with the TOTP endpoint or get_totp_code.

If you store a TOTP secret in the vault, the agent can retrieve its current authenticator code without retrieving the seed. This lets you automate logins that require two-factor authentication. The vault calculates the code and reports how long it remains valid.

## Get the current TOTP code

`POST /api/v1/vault/:id/totp` returns the current authenticator code for a credential with TOTP configured. Requires **vault:use**, and the credential must be marked agent-readable.

The equivalent MCP tool is `get_totp_code`.

```bash title="Get a TOTP code" theme={null}
curl -s -X POST https://agent-loadout.com/api/v1/vault/<CREDENTIAL_ID>/totp \
  -H "Authorization: Bearer $AGENT_LOADOUT_TOKEN"
```

### Response fields

**code** `string`

The current authenticator code. Keep it as a string to preserve leading zeroes.

**item\_id** `string`

The credential used to generate the code.

**expires\_in** `number`

Seconds until the current code expires.

**digits** `number`

Number of digits in the code, as configured by the authenticator seed or URI.

> [!NOTE]
>
> The raw TOTP secret is **never** returned by any endpoint after it is stored. Only the current code is accessible, and every call is recorded in the org's audit history.

## Store a TOTP secret

TOTP is an optional field on a `login` or `api_key` credential. Pass the base32 seed or `otpauth://totp/...` URI as `totp` when creating or updating it. Creating and updating require **vault:write**.

To add TOTP to an existing credential, send only `totp` in `PATCH /api/v1/vault/:id`, or use `update_credential` with `credential_id` and `totp`. The `secret` field changes the password or API key and must not be used for an authenticator seed. The examples below use a sample seed; replace it with the one issued for your account.

```bash title="Create a login with TOTP and a generated password" theme={null}
curl -s -X POST https://agent-loadout.com/api/v1/vault \
  -H "Authorization: Bearer $AGENT_LOADOUT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Hosting portal","kind":"login","generate":true,"allowed_origins":["https://hosting.example"],"totp":"JBSWY3DPEHPK3PXP"}'
```

```bash title="Add TOTP to an existing credential" theme={null}
curl -s -X PATCH https://agent-loadout.com/api/v1/vault/<CREDENTIAL_ID> \
  -H "Authorization: Bearer $AGENT_LOADOUT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"totp":"JBSWY3DPEHPK3PXP"}'
```

## MCP tool

From a chat client, use the `get_totp_code` tool directly:

| Tool | Scope required | Description |
| - | - | - |
| `get_totp_code` | vault:use | Current authenticator code for a stored TOTP secret |

> [!TIP]
>
> Retrieve a code just before using it. Keep authenticator codes and credential values out of logs and chat transcripts.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.