API 参考

账户与计费

使用 API 密钥读取账户用量、分析数据和密钥元数据;计费变更以及密钥的创建或吊销需要控制台会话。

GET/account
API 密钥

使用 API 密钥获取账户、用量、计费状态和工作区数量

相当于控制台个人资料页的 API 密钥版本:账户所有者、当前周期内收件人和附件的用量及套餐上限、访问级别、发件人信誉摘要、订阅状态、已发布的套餐以及工作区数量。只读;计费变更仍只能通过会话进行。

请求
curl https://sendhq.cc/api/v1/account \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "user": {},
  "usage": {},
  "access": {},
  "reputation": {},
  "infrastructure": {},
  "billing": {},
  "plans": [],
  "workspace": {
    "mailer": "ses",
    "stats": {}
  }
}
GET/account/diagnostics
API 密钥

Diagnose sending and receiving problems in the workspace

Read-only troubleshooting snapshot from stored state: an `issues` list in plain language, plan and usage against limits, each domain's DKIM and inbound state, sending identities, 30-day deliverability and sender reputation, suppressions and unsubscribes, the last 30 days of messages that were not sent with their reasons, bounce, complaint and reject events, and webhook delivery health. Never returns message bodies, API keys or webhook secrets.

请求
curl https://sendhq.cc/api/v1/account/diagnostics \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "generatedAt": "2026-10-30T12:00:00.000Z",
  "windowDays": 30,
  "issues": [
    {
      "severity": "action",
      "code": "domain_unverified",
      "message": "example.com is not verified (pending); 2 of 3 DKIM records are not visible in DNS yet."
    }
  ],
  "plan": {},
  "domains": [],
  "sendingIdentities": {
    "domains": [],
    "addresses": []
  },
  "inbound": {},
  "deliverability": {},
  "suppressions": {},
  "failures": {
    "notSent": [],
    "recentNotSent": [],
    "recentProviderEvents": []
  },
  "webhooks": []
}
GET/analytics
API 密钥

获取 7 天、30 天或 90 天的控制台发信分析数据

时间窗口内的已发送、已接收、已送达、退信、被拦截、打开、点击和投诉总数,按天统计的发送/接收时间线,发信量最高的域名,以及表现最好的邮件主题。

查询参数days
请求
curl https://sendhq.cc/api/v1/analytics \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "window": "30d",
  "days": 30,
  "metrics": {
    "sent": 0,
    "received": 0,
    "bounced": 0,
    "blocked": 0,
    "delivered": 0,
    "opened": 0,
    "clicks": 0,
    "complaints": 0
  },
  "timeline": [],
  "domains": [],
  "topContent": []
}
GET/profile
浏览器会话

获取账户、用量和叠加的订阅状态

获取账户、用量和叠加的订阅状态

请求
curl https://sendhq.cc/api/v1/profile \
  -X GET \
  -H "Cookie: sendhq_session_v2=…"
200 响应
{
  "user": {},
  "usage": {},
  "access": {},
  "reputation": {},
  "billing": {},
  "plans": []
}
POST/billing/checkout
浏览器会话

为尚未持有的套餐(级别、邮件类别和计费周期)发起托管结账

为尚未持有的套餐(级别、邮件类别和计费周期)发起托管结账

请求
curl https://sendhq.cc/api/v1/billing/checkout \
  -X POST \
  -H "Cookie: sendhq_session_v2=…" \
  -H "Content-Type: application/json" \
  -d '{"plan_key":"scaleup_marketing_annual"}'
200 响应
{
  "url": "https://checkout.example/…",
  "session_id": "…"
}
POST/billing/cancel
浏览器会话

在应用内取消当前订阅,不触及支付服务商

在应用内取消当前订阅,不触及支付服务商

请求
curl https://sendhq.cc/api/v1/billing/cancel \
  -X POST \
  -H "Cookie: sendhq_session_v2=…"
200 响应
{
  "ok": true
}
POST/keys
浏览器会话

创建 API 密钥

创建 API 密钥

请求
curl https://sendhq.cc/api/v1/keys \
  -X POST \
  -H "Cookie: sendhq_session_v2=…" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production"}'
201 响应
{
  "id": "key_…",
  "name": "Production",
  "key": "re_…",
  "prefix": "re_…"
}
GET/keys
API 密钥

列出 API 密钥元数据

列出密钥名称、非机密的前缀和最近使用时间。完整的密钥值永远不会返回。创建和吊销密钥需要控制台会话。

请求
curl https://sendhq.cc/api/v1/keys \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 响应
{
  "data": [],
  "count": 0
}
DELETE/keys/:id
浏览器会话

吊销 API 密钥

吊销 API 密钥

请求
curl https://sendhq.cc/api/v1/keys/id_value \
  -X DELETE \
  -H "Cookie: sendhq_session_v2=…"
200 响应
{
  "ok": true
}