One API for your 2FA codes
2FA codes. One API call.
Send OTP codes via WhatsApp, SMS or email with the aut2fa API. Set allowed channels for your application and track each send's channel, sender and available statuses.
Your app
POST /v1/send
- SMS
Code delivered
+55 31 9••••-9999
Verification code
482 913
- One integration, three channels
- Free test keys
- Prepaid balance, no monthly fee
From your first POST to a verified code
curl https://api.aut2fa.com/v1/send \
-H "Authorization: Bearer ak_live_…" \
-H "Content-Type: application/json" \
-d '{"to": "+5531999999999"}'
# The user typed 482913
curl https://api.aut2fa.com/v1/send/snd_8Kq2wR7tXz/verify \
-H "Authorization: Bearer ak_live_…" \
-H "Content-Type: application/json" \
-d '{"code": "482913"}'import { Aut2fa } from "@aut2fa/node";
const aut2fa = new Aut2fa(process.env.AUT2FA_API_KEY);
const send = await aut2fa.send({ to: "+5531999999999" });
// The user typed 482913
const result = await aut2fa.verify(send.id, { code: "482913" });
console.log(result.valid); // trueuse Aut2fa\Aut2fa;
$aut2fa = new Aut2fa(getenv('AUT2FA_API_KEY'));
$send = $aut2fa->send(['to' => '+5531999999999']);
// The user typed 482913
$result = $aut2fa->verify($send->id, ['code' => '482913']);
var_dump($result->valid); // trueimport "github.com/jhowbhz/aut2fa-go"
client, err := aut2fa.New(os.Getenv("AUT2FA_API_KEY"))
if err != nil {
return err
}
send, err := client.Send(ctx, aut2fa.SendParams{To: "+5531999999999"})
if err != nil {
return err
}
// The user typed 482913
result, err := client.Verify(ctx, send.ID, "482913")
if err != nil {
return err
}
fmt.Println(result.Valid) // trueimport os
from aut2fa import Aut2fa
client = Aut2fa(os.environ["AUT2FA_API_KEY"])
send = client.send(to="+5531999999999")
# The user typed 482913
result = client.verify(send.id, code="482913")
print(result.valid) # TrueCopy the prompt and paste it into Cursor, Claude Code, Codex or your coding agent.
Integrate aut2fa into this project to send and verify OTP/2FA codes. First inspect the stack, authentication flow and existing conventions.
Read https://doc.aut2fa.com and https://aut2fa.com/llms.txt before coding. Confirm the current API contract in the official documentation. If documentation is unavailable, report what is missing rather than inventing endpoints, SDK methods or package names. Use the existing HTTP client when no published SDK is confirmed.
Implementation:
1. Keep AUT2FA_API_KEY in a server-only environment variable. Never expose it to the browser, commit it, or log keys, codes or recipient data. Provide an .env.example with a placeholder.
2. Send with POST https://api.aut2fa.com/v1/send, Authorization: Bearer <key>, Content-Type: application/json, and {"to":"<recipient>"}. Validate and normalize phone numbers to E.164. Confirm supported recipients and optional fields in the docs.
3. Generate an Idempotency-Key per logical send and reuse it for retries of that same request. Store the returned send ID server-side, tied to the current user/session and verification purpose. Never trust an arbitrary send ID from the client.
4. Verify with POST /v1/send/{id}/verify and {"code":"<user input>"}. Read GET /v1/send/{id}/status when needed. Treat delivery and successful verification as separate states. Only accept the documented successful verification response.
5. Build accessible recipient and code forms with loading, pending, success, invalid/expired code, rate-limit and unavailable-service states. Preserve existing UI conventions. Add resend cooldown and server-side attempt limits. Respect Retry-After; avoid blind retries and duplicate sends.
6. Use test keys first. Codes generated by aut2fa in test mode are 000000; do not assume this for client-supplied codes or live keys. Never bypass verification in production.
7. Add meaningful tests for send, verify, errors, idempotent retries, session binding and secret isolation. Mock external requests; do not send real messages in tests.
Deliver working code, setup instructions, required environment variables and a list of changed files. Run the project's tests, lint and typecheck. Report actual results and any documentation assumptions. Do not replace unrelated architecture or publish/deploy automatically.
Use the project's language and code conventions for implementation and interface text.Send status
202 Accepted
snd_8Kq2wR7tXz
- queued
- sending
channel: whatsapp
- sent
from: +55 11 9••••-0142
- delivered
- read
- verified
From request to verified code in three steps
Two calls from your backend. aut2fa handles everything in between.
Send
POST a phone number or e-mail address. You get the send ID right away. aut2fa generates the code unless you pass your own.
POST /v1/send
aut2fa delivers
aut2fa chooses an allowed, active channel and an enabled sender. Your statement records available statuses with timestamps.
GET /v1/send/{id}/status
Verify
When your user types the code, POST it to /verify. The response says if it’s valid and how many attempts are left.
POST /v1/send/{id}/verify
WhatsApp, SMS and email through one API
For phone numbers, aut2fa tries allowed, active channels from lowest to highest price. Email addresses use the email channel. Telegram is not yet available.
- +5531999999999
- WhatsAppSMS
- [email protected]
See what happened to every code
Track the channel, sender and timestamps of each available status. WhatsApp can report delivery and read receipts; SMS and email report provider acceptance.
| Sent at | To | Channel | From | Status |
|---|---|---|---|---|
| 18:05:00 | +55 31 9••••-9999 | +55 11 9••••-0142 | Read at 18:05:04 | |
| 18:04:12 | +55 21 9••••-4410 | SMS | +55 11 9••••-7731 | Delivered at 18:04:15 |
| 18:02:30 | +55 41 9••••-2087 | +55 11 9••••-0388 | Read at 18:02:41 | |
| 18:01:58 | +55 85 9••••-6120 | SMS | +55 11 9••••-7731 | Failed, not charged |
Automatic routing
For each code, aut2fa picks the cheapest channel you allowed and the number that sends it. You don’t manage provider accounts.
Delivery receipts
Track the statuses each channel reports. WhatsApp supports sent, delivered and read receipts; SMS and email acceptance does not confirm recipient delivery.
Rate limits against SMS pumping
Every account has a ceiling on sends per minute. On top of it, turn on limits per application, per minute and per recipient per hour, to stop SMS pumping.
Free test keys
ak_test_keys are free, and codes aut2fa generates in test mode are always000000, so your tests can run the real flow.Idempotency keys
Send an
Idempotency-Keyheader and a retried request returns the original send instead of a second code.Per-channel pricing, no monthly fee
WhatsApp is charged when delivery is confirmed. SMS and email are charged when the provider accepts the send. Failures without a charge return the reserved balance.
Available deliveries and prices
See the price per code for each channel in Brazilian reais and calculate the cost of different quantities.
Free test keys to validate your integration.
SDKs for Node, PHP, Go and Python
Free and open source on GitHub. All four cover the same three endpoints.
Node.js
npm i @aut2fa/nodePHP
composer require aut2fa/aut2fa-phpGo
go get github.com/jhowbhz/aut2fa-goPython
pip install aut2fa
Questions
Which channel will my user get the code on?
Phone numbers receive codes via WhatsApp or SMS; email addresses use the email channel. aut2fa tries allowed, active channels from lowest to highest price. Telegram is not yet available. Your statement shows the channel and sender used.
How do test keys work?
Keys that start with ak_test_ are free, and codes aut2fa generates in test mode are always 000000. Automated tests can run the whole flow without touching your balance.
How much does a code cost?
See the current price of each channel on the pricing page. WhatsApp is charged on delivery or read; SMS and email on provider acceptance. Test mode does not use your balance.
What if a code isn’t delivered?
If a send fails or expires without a charge, its reservation returns to your balance. Accepted SMS and email sends are already charged, even without delivery confirmation; WhatsApp is charged on delivery or read.
How do I pay?
Add balance in the dashboard using Pix or card through Mercado Pago. Prices are in Brazilian reais and there is no subscription.
How do you protect against SMS pumping?
Every account has a ceiling on sends per minute. You can also turn on limits per application: sends per minute and sends per recipient per hour. Requests over a limit get a 429 with a Retry-After header, before anything is sent.
Is it safe to retry a request?
Yes. Use the same Idempotency-Key and request body to get the original send without a new code or duplicate charge.
Can I send my own code?
Yes. Pass it in the code field, or leave the field out and aut2fa generates one. Set locale to en or pt-BR to choose the message language.
Send your first code with a free test key
Create an account, copy your ak_test_ key and run the request above.