Developers

How to add OTP verification to your app

September 2026 · 6 min read

One-time passcodes are the simplest way to prove a user controls a phone number — for signup, login, or approving a sensitive action. With Bremlio it's two API calls, and the hard parts (generating the code, delivering it, expiring it, locking out brute force) are handled for you.

Step 1 — send the code

const { verification_id } = await fetch(
  "https://api.bremlio.com/v1/otp/send", {
    method: "POST",
    headers: { "X-Api-Key": KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ to: "+447700900123" })
  }).then(r => r.json());
// store verification_id against the pending session

Step 2 — verify what the user typed

const { verified } = await fetch(
  "https://api.bremlio.com/v1/otp/verify", {
    method: "POST",
    headers: { "X-Api-Key": KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ verification_id, code: userInput })
  }).then(r => r.json());
if (verified) { /* authenticate the user */ }

The failure cases most integrations miss

Build without spending credits

Configure a test number so the flow runs end to end with a fixed code and no carrier send — ideal for local development and CI.

Add OTP today

25 free credits to test the full send-and-verify flow.

Create free account →