联系人只存一份,按 email 去重,再将其分组为可在 broadcast 中定向的受众。带类型的属性注册表让数据保持干净,一次性批量 upsert 1,000 行可快速导入一份列表。
import { BirdClient } from "@messagebird/sdk";
import { render } from "@react-email/render";
import { WelcomeEmail } from "./emails/welcome";
const bird = new BirdClient({ apiKey: process.env.BIRD_API_KEY! });
const { data, error } = await bird.email.send({
from: "Bird <hello@bird.com>",
to: ["ada@example.com"],
subject: "Your invite is ready",
html: await render(<WelcomeEmail name="Ada" />),
}).safe();
if (error) throw error;
console.log(data.id);
// → "em_2bX91Yk8h..."
You can sign in any time at bird.com/login.
Your test API key is on your dashboard, ready to send.
一条联系人记录。属性不会漂移。
受众是 Bird Email API 的一部分:联系人按 email 唯一并在各受众间共享,受众只是这些联系人的集合,属性始终保存在联系人上,而不会复制到每份列表里。属性注册表意味着写入时就会拒绝拼错的字段,而不是等到投放营销活动时才发现。
让你的数据保持干净的五件事。
数据模型替你处理记账工作,因此你的列表不会腐烂。
- 01
每人一条记录。
每个 email 对应一个联系人,包含名、姓、external ID 以及你自己的自定义数据。
- 02
受众即成员关系。
受众是一组你可以自由添加和移除的联系人。属性始终保存在联系人上,绝不复制到列表里。
- 03
带类型的属性注册表。
预先定义你的自定义字段:string、number 或 boolean,并可选填默认回退值。未知的 key 和类型错误的值会在写入时被拒绝。
- 04
批量更新或插入多达 1,000 个。
单次调用即可 upsert 至多 1,000 个联系人,并在同一请求中将它们加入某个受众。
- 05
精确匹配查找。
按精确 email 匹配查找联系人,让你自己的系统无需扫描每一条记录即可同步。
一次调用即可导入整份名单。
Upsert 基于每条记录携带的标识符实现幂等性,因此重新运行导入只会更新而不会产生重复数据。单次请求最多可添加 1,000 个联系人并将其加入受众,无需额外的成员关联步骤,也无需事后去重。更大的列表可按每批 1,000 条分批上传。每次调用相互独立,因此中断的导入可以安全地从断点处恢复。
// Upsert up to 1,000 contacts and add them to an audience at once.
const result = await bird.contacts.batch({
audience_ids: ["adn_01krdgeqcxet5s7t44vh8rt9mg"],
contacts: [
{ email: "ada@example.com", first_name: "Ada", data: { plan: "growth" } },
{ email: "grace@example.com", first_name: "Grace", data: { plan: "free" } },
],
});
// Per-contact results come back in submission order.
for (const item of result.data) {
console.log(item.email, item.status);
}
不会漂移的字段。
自定义联系人数据要经过一个带类型的注册表。每个字段声明一次,类型为 string、number 或 boolean,并可选填回退值;拼错的 key 或类型错误的值会在你写入的那一刻被拒绝,而不是在营销活动进行到一半时才发现。由于属性保存在联系人而非列表上,在受众之间移动某人绝不会留下过期的副本。
Email 平台的其余功能
一套 API,一组密钥。探索其他能力。
全球约 40% 的商业邮件已经在 Bird 上运行。
在我们运营了十年的基础设施上提供事务性和营销邮件。受众是 Bird Email API 的一项能力:发送、broadcast、送达率、抑制和分析都随之提供。