API 参考

草稿与附件

借助私有附件存储构建邮件撰写流程。

POST/drafts
API 密钥

创建撰写草稿

创建撰写草稿

请求
curl https://sendhq.cc/api/v1/drafts \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"hello@example.com","to":["customer@example.net"],"subject":"Hello"}'
201 响应
{
  "id": "dr_…",
  "attachments": []
}
GET/drafts
API 密钥

列出撰写草稿

列出撰写草稿

请求
curl https://sendhq.cc/api/v1/drafts \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "data": [],
  "count": 0
}
GET/drafts/:id
API 密钥

获取草稿及其附件

获取草稿及其附件

请求
curl https://sendhq.cc/api/v1/drafts/id_value \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "id": "dr_…",
  "attachments": []
}
PUT/drafts/:id
API 密钥

替换草稿内容

替换草稿内容

请求
curl https://sendhq.cc/api/v1/drafts/id_value \
  -X PUT \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"hello@example.com","to":["customer@example.net"],"subject":"Updated subject","text":"Updated body"}'
200 响应
{
  "id": "dr_…"
}
DELETE/drafts/:id
API 密钥

丢弃草稿

丢弃草稿

请求
curl https://sendhq.cc/api/v1/drafts/id_value \
  -X DELETE \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "ok": true
}
POST/drafts/:id/attachments
API 密钥

向草稿上传附件

上传原始文件字节。需设置 Content-Type 和 X-Filename。一封邮件最多包含 10 个文件,总大小不超过 10 MB。

可选请求头X-Filename
请求
curl https://sendhq.cc/api/v1/drafts/id_value/attachments \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/pdf" \
  -H "X-Filename: invoice.pdf" \
  --data-binary @invoice.pdf
201 响应
{
  "id": "att_…",
  "filename": "invoice.pdf",
  "sizeBytes": 48231,
  "available": true
}
GET/attachments/:id
API 密钥

下载私有附件

下载私有附件

请求
curl https://sendhq.cc/api/v1/attachments/id_value \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
DELETE/attachments/:id
API 密钥

删除私有附件

删除私有附件

请求
curl https://sendhq.cc/api/v1/attachments/id_value \
  -X DELETE \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "ok": true
}
GET/sending-identities
API 密钥

列出已验证的发信身份

列出已验证的发信身份

请求
curl https://sendhq.cc/api/v1/sending-identities \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "domains": [],
  "addresses": [],
  "localParts": []
}