# agent402.tools TOTP Code Generator

> agent402.tools TOTP Code Generator is a paid API for AI agents from agent402.tools, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-14).

Computes the current 6- or 8-digit TOTP one-time password from a base32 secret using RFC 6238 (30s period, SHA-1)

## Facts

- Endpoint: POST https://agent402.tools/api/totp
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-totp-code-generator-f2742bc9
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_Yb54m0gqUjH4buh4Bc4vC

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-totp-code-generator-f2742bc9 -d '<json body>'
```

Example prompt: I need to log into a site that requires a 2FA code — compute the current 6-digit TOTP code from my base32 secret JBSWY3DPEHPK3PXP so I can paste it into the login form.

## When to prefer this

Use this endpoint when an AI agent needs to programmatically complete a TOTP-based 2FA challenge it is authorized to fulfill, especially in automated login or workflow automation scenarios where a software authenticator is needed without a physical device.

## Known failure modes

- Invalid or malformed base32 secret returns an error
- Unsupported digit count (not 6 or 8) may return an error or default behavior
- Clock skew on either side may cause the code to be rejected by the target system
- Missing secret field returns a validation error
- Payment failure (x402) blocks execution

## How this service works

Compute the current TOTP code (RFC 6238, 30s period, SHA-1, 6 digits) from a base32 secret. Useful for agents that must complete 2FA flows they are authorized for.

## Output

Returns the current TOTP one-time password (6 or 8 digits) valid for the current 30-second time window, derived from the provided base32 secret using RFC 6238 with SHA-1.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "digits": {
   "type": "number",
   "description": "6 (default) or 8"
  },
  "secret": {
   "type": "string",
   "description": "Base32 TOTP secret"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "code": "492039",
  "secondsRemaining": 17
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-totp-code-generator-f2742bc9/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
