跳到正文
OTP Run

验证码

在 WhatsApp 里发送验证码。 秒级送达,自动校验。

OTP Run 生成验证码,用用户的语言通过 WhatsApp 发送;若 WhatsApp 未能及时确认送达,则回退到 Telegram,并校验用户输入的内容。验证码绝不以明文存储。

免费套餐包含一个 WhatsApp 号码,无需绑定银行卡。

你将获得

  • 渠道自动回退

    如果 WhatsApp 在几秒内没有确认送达,同一个验证码会转到 Telegram。无论在哪里被读到,都是同一个验证码、同一次校验。

  • 点击即验证

    不发送验证码,而是给用户一个链接:用户点击后,从自己的 WhatsApp 把验证码发给你。无需发出消息,你的号码也没有风险。

  • 内置安全机制

    验证码哈希存储,限制错误尝试次数,设置有效期,并按手机号和 IP 地址限流,防范短信泵攻击和暴力破解。

无需代码即可接入

如果你的应用基于 Supabase,就不用写代码:只需一项设置,手机号登录就改由 WhatsApp 发送验证码。

基于 Supabase 的应用

  1. 在 OTP Run 中打开你的项目,进入“集成”,选择 Supabase,点击“创建”,复制 Hook 地址。

  2. 在 Supabase 中依次打开 Authentication、Hooks、Send SMS,选择 HTTPS 并粘贴该地址。

  3. 在 Supabase 中生成密钥,粘贴回 OTP Run,然后在两边都保存这个 Hook。

  4. 开启手机号登录:Authentication、Sign In / Providers、Phone。

  5. 你应用里的代码保持不变。验证码由 Supabase 生成和校验,OTP Run 从你的 WhatsApp 号码发出。

复制给 Lovable、Cursor 或 Claude Code 的任务

把它粘贴到编程助手的对话框里,它就会为你加上手机号登录。任务用英文书写,因为工具对英文理解得最好。

适用于 Lovable 和 Bolt
Add phone number login with Supabase Auth. Use supabase.auth.signInWithOtp({ phone }) to send the code and supabase.auth.verifyOtp({ phone, token, type: 'sms' }) to check it. Build two screens: a phone input with the country code, and a 6-digit code input with a resend button after 60 seconds. Codes are delivered by a Supabase Send SMS hook that is already configured, so do not add Twilio or any other SMS provider code.
适用于 Cursor、Claude Code 及其他编程助手
Add WhatsApp login codes using the OTP Run Verify API. Read https://otprun.com/llms-full.txt first. Work on the server only: POST https://otprun.com/v1/verifications with the header Authorization: Bearer ${OTPRUN_API_KEY} and the body {"to": phone} creates a verification and sends the code; POST https://otprun.com/v1/verifications/{id}/check with {"code": code} checks it, and only status "verified" means success. Keep OTPRUN_API_KEY in server environment variables and never send it to the browser. Create two server routes, /api/otp/start and /api/otp/check, a phone form and a code form. Read the verified phone from GET /v1/verifications/{id} (field to_phone) on the server, then sign the user in with the session mechanism the app already has.

代码中的样子

用手机号创建验证,显示验证码输入框,然后校验用户输入的内容。结果为通过、错误、已过期或已锁定。

发送并校验验证码
curl -X POST https://otprun.com/v1/verifications \
  -H "Authorization: Bearer $OTPRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":"+77010000000","app_name":"Acme"}'

curl -X POST https://otprun.com/v1/verifications/$ID/check \
  -H "Authorization: Bearer $OTPRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"482913"}'

如何开始

  1. 免费创建账号并复制项目 API 密钥。

  2. 绑定一个 WhatsApp 号码,或使用 OTP Run 的 Telegram 机器人。

  3. 用户注册时调用 POST /v1/verifications,用户输入验证码时调用 POST /v1/verifications/{id}/check。

常见问题

相比短信为什么更便宜?

通过你绑定的 WhatsApp 号码和 Telegram 发送验证码都没有按条费用。你只需支付固定月费,而不是每条短信几分钱。

如果用户没有 WhatsApp 怎么办?

项目的路由策略会转到下一个渠道,默认是 Telegram。你也可以用 POST /v1/numbers/check 提前检查号码。

验证码支持哪些语言?

消息模板内置 24 种语言,你也可以自己编写文本,用占位符插入验证码、应用名称和有效期。

验证码有效多久?

默认五分钟。可设置为 30 秒到 15 分钟,验证码长度 4 到 8 位,并可设置尝试次数。

绑定号码,今天就发出第一条消息。

免费,无需银行卡。你随时可以在手机上解除号码绑定。

免费绑定我的号码