跳到正文

API

联系人、分组和主题

营销邮件的收件人:联系人、属性、分组、订阅主题和 CSV 导入。

这些路由需要 full_access 密钥。应用密钥管理其域名下的联系人(如果它覆盖多个域名,请在参数或请求体中指定 domain)。新闻通讯属于域名:个人密钥会收到 401。超出此范围的对象会返回 404。

联系人

联系人可以通过其 ID 或地址来指定。如果创建的联系人地址已经存在,则会更新该联系人(ID 不变,响应为 200 而不是 201)。

Node / Bun

await voaaro.contacts.create({
  email: "ada@example.org",
  firstName: "Ada",
  properties: { plan: "pro" },
  segments: [{ id: segmentId }],
})
await voaaro.contacts.update({ email: "ada@example.org", unsubscribed: true })

Python

voaaro.Contacts.create({
    "email": "ada@example.org",
    "first_name": "Ada",
    "properties": {"plan": "pro"},
    "segments": [{"id": segment_id}],
})
voaaro.Contacts.update("ada@example.org", {"unsubscribed": True})

PHP

$voaaro->contacts->create([
    'email' => 'ada@example.org',
    'firstName' => 'Ada',
    'properties' => ['plan' => 'pro'],
    'segments' => [['id' => $segmentId]],
]);
$voaaro->contacts->update('ada@example.org', ['unsubscribed' => true]);

Go

c, _ := client.Contacts.Create(&voaaro.CreateContactRequest{
	Email:      "ada@example.org",
	FirstName:  "Ada",
	Properties: map[string]any{"plan": "pro"},
	Segments:   []string{segmentId},
})

cURL

curl https://mail.example.com/api/v1/contacts \
  -H "Authorization: Bearer $VOAARO_API_KEY" -H "Content-Type: application/json" \
  -d '{"email": "ada@example.org", "first_name": "Ada", "properties": {"plan": "pro"}}'
字段规则
email必填,创建后无法修改
first_name、last_name最多 100 个字符;null 表示清空
unsubscribed退订所有营销邮件;设为 true 会取消该联系人待发送的营销邮件
properties{键: 值},仅限已声明的属性;最多 500 个字符的文本或数字;null 表示清空
segments创建时使用 [{id}]
topics[{id, subscription: "opt_in" | "opt_out"}]

列出联系人:GET /api/v1/contacts,可使用 segment_id、q(在地址和姓名中搜索)、email(地址包含)、unsubscribed、created_after、created_before(筛选),以及常规的分页。

无论通过哪种途径(API、控制台、导入、表单、偏好设置页面),联系人的每次创建、修改、退订或删除都会触发 contact.* webhook。

参与度评分与验证

每个联系人的简要形式包含 engagement_score(0 到 100,尚未收到开启跟踪的营销邮件时为 null)和 email_status(valid、risky、invalid,地址尚未验证时为 null)。GET /api/v1/contacts/{id} 返回详细信息:

JSON
{ "engagement": { "score": 72, "level": "high", "updated_at": "…", "last_open_at": "…", "last_click_at": "…" },
  "verification": { "status": "risky", "reasons": ["typo"], "suggestion": "jane@gmail.com", "checked_at": "…" } }
  • 评分:过去一年内收到的开启跟踪的营销邮件的加权平均值(点击 1,打开 0.8,Apple Mail 自动打开 0.3,无操作 0),权重每 60 天减半,发送次数较少时向 50 靠拢;发生硬退信或投诉后为 0。等级:low(低于 30)、medium(30 到 69)、high(70 及以上)、unmeasured。
  • 验证原因:syntax、no_mail_server(既无 MX 也无 A 记录)、null_mx、reserved_domain(状态为 invalid);disposable、role、typo(状态为 risky);dns_unknown(解析器无法访问:不作结论)。不会通过 SMTP 连接收件人的服务器。
  • GET /api/v1/contacts 的筛选参数:engagement=low|medium|high|unmeasured、email_status=valid|risky|invalid|unchecked。动态分组的条件:{ "field": "engagement", "op": "lt" | "gte", "value": 30 }(或 "op": "is_not_set")、{ "field": "email_status", "op": "equals" | "not_equals", "value": "invalid" }。
  • POST /api/v1/contacts/verify { "email" } 验证一个地址,但不保存;POST /api/v1/contacts/{id}/verify 重新验证某个联系人并保存结果。
  • GET /api/v1/contacts/export:联系人的 CSV(带 BOM 的 UTF-8),筛选参数与列表相同(segment_id、unsubscribed、engagement、email_status),包含 engagement_score、engagement_level、email_status、email_reasons、email_suggestion、last_open_at、last_click_at 列。

Node / Bun

const { data: v } = await voaaro.contacts.verifyEmail({ email: "jane@gmial.com" })
await voaaro.contacts.reverify({ email: "jane@gmial.com" })
const { data: low } = await voaaro.contacts.list({ engagement: "low", emailStatus: "valid" })
const { data: csv } = await voaaro.contacts.export({ segmentId, engagement: "high" })
await voaaro.contacts.imports.create({ file, skipInvalid: true })

Python

v = voaaro.Contacts.verify_email({"email": "jane@gmial.com"})
voaaro.Contacts.reverify("jane@gmial.com")
low = voaaro.Contacts.list({"engagement": "low", "email_status": "valid"})
csv_text = voaaro.Contacts.export({"segment_id": segment_id, "engagement": "high"})
voaaro.Contacts.imports.create({"file": data, "skip_invalid": True})

PHP

$v = $voaaro->contacts->verifyEmail('jane@gmial.com');
$voaaro->contacts->reverify('jane@gmial.com');
$low = $voaaro->contacts->list(['engagement' => 'low', 'emailStatus' => 'valid']);
$csv = $voaaro->contacts->export(['segmentId' => $segmentId, 'engagement' => 'high']);
$voaaro->contacts->imports->create(['file' => 'contacts.csv', 'skipInvalid' => true]);

Go

v, _ := client.Contacts.VerifyEmail(&voaaro.VerifyEmailRequest{Email: "jane@gmial.com"})
client.Contacts.Reverify("jane@gmial.com", "")
low, _ := client.Contacts.List(&voaaro.ListContactsOptions{Engagement: voaaro.EngagementLow, EmailStatus: voaaro.EmailValid})
csv, _ := client.Contacts.Export(&voaaro.ExportContactsOptions{SegmentId: segmentId, Engagement: voaaro.EngagementHigh})
client.Contacts.Imports.Create(&voaaro.CreateContactImportRequest{File: data, SkipInvalid: voaaro.Bool(true)})

cURL

curl https://mail.example.com/api/v1/contacts/verify \
  -H "Authorization: Bearer $VOAARO_API_KEY" -H "Content-Type: application/json" \
  -d '{"email": "jane@gmial.com"}'

属性

自定义字段只需声明一次,之后即可在营销邮件中使用({{contact.plan}}):POST /api/v1/contact-properties,包含 key(字母、数字、_,最多 50 个字符)、type(string 或 number)和 fallback_value(默认值)。创建后只能修改 fallback_value。删除某个属性会从所有联系人中移除该属性的值。

分组

分组是营销邮件的发送对象:POST /api/v1/segments(name)、GET /api/v1/segments/{id}/contacts,以及用于添加或移除联系人的 POST 和 DELETE /api/v1/contacts/{id}/segments/{segment}。/api/v1/audiences 路由(Resend 以前使用的名称)仍然可用。分组也可以是动态的:用条件代替列表(动态分组)。

主题

主题(“产品动态”、“优惠”)让每位联系人自行选择想要接收的内容。POST /api/v1/topics,包含 name、description、default_subscription(opt_in 或 opt_out,在创建时确定)和 visibility(public:显示在联系人的偏好设置页面上)。联系人的选择:GET 和 PATCH /api/v1/contacts/{id}/topics。与某个主题关联的营销邮件只会发送给该主题的订阅者。

导入 CSV 文件

POST /api/v1/contacts/imports,使用 multipart/form-data:file(UTF-8 编码的 CSV,分隔符为 , 或 ;,最大 10 MB、50,000 行),以及可选的 column_map、on_conflict(默认为 upsert,也可以是 skip)、segments、topics。列按其标题识别。导入在请求过程中完成处理:

JSON
{ "object": "contact_import", "id": "…", "counts": { "total": 1200, "created": 1150, "updated": 40, "skipped": 0, "failed": 10 } }

GET /api/v1/contacts/imports/{id} 还会返回前 20 个错误(行号和原因)。

每个导入的地址都会经过验证(每个域名只查询一次,整个文件最多 20 秒):counts.verification 返回 { "valid", "risky", "invalid" }。使用 skip_invalid=true 时,无效地址不会被导入,而是计入 counts.excluded(并列在错误中)。

导入 1,000 行会为每个已订阅的端点产生 1,000 个 contact.created(或 contact.updated)webhook:请在应用端做好相应准备。

限制

每个域名:200,000 个联系人、100 个分组、50 个主题、50 个属性。

Esc