OTP
The /otp endpoint generates and verifies one-time passwords (TOTP/HOTP), compatible with Google Authenticator and Aegis.
curl -X POST \ "https://api.moxon.dev/v5/otp" \ -H "Content-Type: application/json" \ -d '{}'Send the request to see the response here.
The request body must be JSON:
action"secret" | "generate" | "verify"requiredAction to perform:
secret,generate, orverifysecretstringconditionalBase32 secret key (required for
generateandverify)codestringconditionalOTP code to verify (required for
verify)labelstringoptionalAccount label for the
otpauth://URI (used withsecretaction)issuerstringoptionalIssuer name for the
otpauth://URI (used withsecretaction)algorithm"sha1" | "sha256" | "sha512"optionalHMAC algorithm:
sha1(default),sha256, orsha512digits"6" | "8"optionalCode length:
6(default) or8period"15" | "30" | "60"optionalTOTP period in seconds:
15,30(default), or60counternumberoptionalHOTP counter (integer). If provided, HOTP mode is used instead of TOTP
| Action | Description |
|---|---|
secret | Generates a new random base32 secret and returns an otpauth:// URI ready for QR code scanning |
generate | Generates the current OTP code. Without counter: TOTP (time-based). With counter: HOTP (deterministic) |
verify | Verifies a code with a ±1 period tolerance window. Returns valid and a drift offset (0, +1, or -1) |
Implements RFC 4226 (HOTP) and RFC 6238 (TOTP). Compatible with Google Authenticator and Aegis.
secret action:
secretstringBase32-encoded secret key
uristringotpauth://URI for QR code generation
generate action:
codestringGenerated OTP code
typestringtotporhotp
verify action:
validbooleanWhether the code is valid
driftnumberTime drift detected (0, +1, or -1)
If parameters are missing or invalid, the API will return an error:
- 400
Action is requiredTheactionparameter is missing - 400
Action must be one of: secret, generate, verifyTheactionvalue is not valid - 400
Secret is requiredThesecretparameter is missing - 400
Code is requiredThecodeparameter is missing forverify - 400
Digits must be 6 or 8Thedigitsvalue is not valid - 400
Period must be one of: 15, 30, 60Theperiodvalue is not valid - 400
Algorithm must be one of: sha1, sha256, sha512Thealgorithmvalue is not supported - 400
Counter must be a non-negative integerThecountervalue is invalid
Last updated on May 27, 2026