字母数字发送者 ID 会在发件人字段中放置你的品牌名称而非号码。许多国家/地区要求你在该名称能够投递之前对其进行预注册。Bird 会提交注册并通过 API 报告其状态,让你知道发送者何时生效。
import { BirdClient } from "@messagebird/sdk";
const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });
const { data, error } = await bird.sms.send({
from: "Bird",
to: "+31612345678",
text: "Your order #4821 has shipped. Track it: bird.ly/t/4821x",
category: "transactional",
}).safe();
if (error) throw error;
console.log(data.id);
// → "sms_01m11jw130e7svjzv70kgqr38w"
为什么某些发送者需要先注册。
发送者 ID 注册是 Bird SMS API 上 SMS 合规 的一部分。为了遏制伪造,一些国家/地区只投递已向当地运营商或监管机构预注册的字母数字发送者 ID。在适用此规则的地方,未注册的品牌发送者会被拒绝或被改写。Bird 会替你提交注册并暴露其状态,于是你不会向一个尚不能投递的发送者发送。
注册如何运作。
哪里需要它、由谁提交,以及它何时生效。
- 01
了解哪里需要它。
字母数字发送者 ID 是否需要注册取决于目的地国家/地区。有些要求预注册,有些允许动态发送者,还有些则完全不允许字母数字。
- 02
Bird 替你提交。
从控制台提交发送者 ID 和目的地。Bird 会代表你将注册提交给当地运营商或监管机构。
- 03
通过 API 跟踪状态。
审批会经由外部注册机构进行,需要数天到数周。轮询注册的状态,让你的代码在从该发送者 ID 发送之前等待它。
- 04
它适用于字母数字发送者。
注册管辖的是字母数字发送者 ID 本身。从号码发送——长码、短码、免费电话号码——则遵循这些号码类型的规则。
从 API 查看注册状态。
您可以从控制面板提交发送方 ID 申请;需求概览会显示每个目标国家/地区对应一行的当前状态。在使用该发送方 ID 发送消息之前,请根据该行的状态以及目标国家/地区是否已启用来判断是否可以发送。
// The sender surface is not on the SDK yet, so read it over HTTP with a key
// carrying the sms_management:read scope.
const res = await fetch(
`https://eu1.platform.bird.com/v1/sms/senders/${senderId}/requirements`,
{ headers: { Authorization: `Bearer ${process.env.BIRD_API_KEY!}` } },
);
const { data: countries } = await res.json();
// Registration is decided per destination, so there is one row per country
// this sender can reach — never a single status for the sender itself.
const india = countries.find((c) => c.country_code === "IN");
// approved and not_required are the two statuses that satisfy a country.
// destination_enabled is a separate axis: a fully registered country still
// refuses the send while the workspace has it switched off.
if (india.status === "approved" && india.destination_enabled) {
// safe to send from this sender ID to India
}
注册跟随字母数字发送者。
这是 字母数字发送者 ID 背后的合规步骤。该发送者类型让你能在国家/地区允许的地方以品牌名称发送;而注册正是在国家/地区要求先注册的地方让该名称可投递的关键。