WhatsApp OTP

一次性验证码, 通过 WhatsApp 发送。

配置时间:
Cursor

WhatsApp 验证通过身份验证模板消息将验证码发送到用户的 WhatsApp 账户:内容丰富,从 Bird 托管的企业号码发送,使用您选择的身份(默认为 Bird Verify,或 Authifly),并通过用户日常使用的应用送达。它是同一按国家/地区计费方案中的可选通道,因此验证可以优先使用 WhatsApp,同时将 SMS 作为备用。

verify.ts
200 · pending
import { BirdClient } from "@messagebird/sdk";

const bird = new BirdClient({
  apiKey: process.env.BIRD_API_KEY!,
});

// Send the code, then check it by recipient.
await bird.verify.verifications.create({
  to: { phone_number: "+15551234567" },
}).safe();

const { data, error } = await bird.verify.verifications.check({
  to:   { phone_number: "+15551234567" },
  code: userInput,
}).safe();
if (error) throw error;

计划中的一个渠道,而非新的集成。

WhatsApp 是 Bird Verify API 上的一个电话系列渠道:接收方是同一个电话号码,创建和验证调用不变,WhatsApp 只是按国家/地区渠道计划中的一个可排序条目。在转化效果好的地方将其排在 SMS 之前,其他地方则保持 SMS 优先。

WhatsApp 验证带来了什么。

按国家/地区计划中的可排序渠道。

  1. 01

    身份验证模板消息送达。

    Codes go as WhatsApp authentication-template messages, the format the platform reserves for one-time passcodes. WhatsApp templates covers how the category works.

  2. 02

    相同的接收方,相同的调用。

    使用相同的电话号码,调用相同的创建和验证端点。WhatsApp 是渠道,而非不同的 API。

  3. 03

    按国家/地区可排序。

    在 WhatsApp 效果最佳的国家/地区,将其排在 SMS 之前;其余地区保持 SMS 优先。

  4. 04

    SMS 作为备选保留。

    电话号码目标携带其完整的电话系列计划,因此 SMS 排在 WhatsApp 之后。随着基于送达的自动推进功能上线,WhatsApp 优先的验证会在同一会话中自动切换到 SMS。

  5. 05

    相同的验证码安全保障。

    验证码通过加密随机源生成,仅以 HMAC 形式存储;长度和有效期可配置;按接收方进行验证。WhatsApp 继承了其他渠道的所有安全保障。

优先使用 WhatsApp,SMS 紧随其后。

Routing is configured for the workspace, and a create call follows whatever it resolved. Putting WhatsApp first happens at that level, so the create call is the same one-liner either way.

whatsapp-otp.ts
200
await bird.verify.verifications.create({
  to: { phone_number: "+15551234567" },
}).safe();

// resolved channels: [{ channel: "whatsapp" }, { channel: "sms" }]

一套验证 API,覆盖用户使用的每个渠道。

WhatsApp 与电子邮件和 SMS 一起作为同一按国家/地区计划中的渠道,按最优转化顺序排列,使用相同的两个端点。

从一个渠道开始。
准备好后,再添加其他渠道。

测试 API 密钥即刻可用。添加支付方式并验证发送者身份后,即可解锁生产环境。

正在使用 Claude Code、Cursor 或 Codex?复制一条设置提示,您的智能代理即可自动安装 Bird CLI 和相关技能。选择您的工具:

Cursor