地址
每个实例都提供自己的 API:
https://mail.example.com/api/v1所有请求均通过 HTTPS 以 JSON(UTF-8)格式发送,并在 Authorization 请求头中携带密钥。日期采用 ISO 8601 格式,时区为 UTC。
API 的功能
| 资源 | 用途 | 页面 |
|---|---|---|
/emails、/emails/batch | 发送、定时、跟踪、取消、分享 | 发送 |
/emails/receiving | 读取邮箱收到的邮件 | 接收 |
/domains | 发信域名及其 DNS 记录 | 域名 |
/api-keys | 创建和撤销密钥 | 身份验证 |
/contacts、/segments、/topics、/contact-properties | 营销邮件的联系人 | 联系人 |
/broadcasts | 营销邮件 | 营销邮件 |
/newsletter、/forms、/newsletter-templates、/automations、/events | 设置、订阅表单、模板、自动化 | 新闻通讯 |
/suppressions、/emails/events | 禁止发送列表、发送事件日志 | 禁止发送列表与事件日志 |
/webhooks | webhook 端点、投递记录、重放 | 管理 webhook |
/emails/metrics | 统计信息 | 发送 |
/organizations | 客户组织,使用单独的运营方密钥(mko_…),这些路由默认停用 | 组织 |
参考文档描述了每一个路由;它由 API 的 OpenAPI 3.1 文件生成,该文件会自动与服务的实际路由进行比对。
第一次调用
cURL
curl https://mail.example.com/api/v1/emails \
-H "Authorization: Bearer $VOAARO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "Acme <notifications@example.com>", "to": "client@example.org", "subject": "Hello", "text": "First email."}'Node / Bun
const { data, error } = await voaaro.emails.send({
from: "Acme <notifications@example.com>",
to: "client@example.org",
subject: "Hello",
text: "First email.",
})Python
email = voaaro.Emails.send({
"from": "Acme <notifications@example.com>",
"to": "client@example.org",
"subject": "Hello",
"text": "First email.",
})PHP
$email = $voaaro->emails->send([
'from' => 'Acme <notifications@example.com>',
'to' => 'client@example.org',
'subject' => 'Hello',
'text' => 'First email.',
]);Go
sent, err := client.Emails.Send(&voaaro.SendEmailRequest{
From: "Acme <notifications@example.com>",
To: []string{"client@example.org"},
Subject: "Hello",
Text: "First email.",
})通用约定
所有路由都遵循相同的规则:
| 主题 | 规则 | 页面 |
|---|---|---|
| 列表 | 使用 limit、after、before 游标,从新到旧排列;可按状态、地址或日期筛选 | 分页 |
| 重试 | 任何 POST 请求都可携带 Idempotency-Key 请求头,保留 24 小时 | 幂等性 |
| 速率 | 每个密钥每分钟 600 个请求,返回 RateLimit-* 请求头 | 限制 |
| 错误 | 始终返回 JSON {statusCode, name, message, error},即使是未知路由也是如此 | 错误 |
| 字段 | 请求中的未知字段会被拒绝(422);响应可能会随版本增加字段:请忽略您不认识的字段 | 错误 |
延伸阅读
- 身份验证:应用密钥和个人密钥。
- 错误和限制。
- 从 Resend 迁移:有哪些变化。