# Send a transactional email: from, to, subject, body curl -sS -X POST 'https://app.sendarix.com/v1/email/send' \ -H 'Content-Type: application/json' \ -H 'X-API-Key: YOUR_API_KEY' \ -H 'Idempotency-Key: otp_8842' \ -d '{"from":"no-reply@yourdomain.com","to":"user@example.com","subject":"Your sign-in code","text":"Your code is 482913"}'
// Node 18+ (built-in fetch) const res = await fetch("https://app.sendarix.com/v1/email/send", { method: "POST", headers: { "Content-Type": "application/json", "X-API-Key": process.env.SENDARIX_API_KEY, "Idempotency-Key": "otp_8842" }, body: JSON.stringify({ from: "no-reply@yourdomain.com", to: "user@example.com", subject: "Your sign-in code", text: "Your code is 482913" }) }); console.log(await res.json()); // message_id, status, request_id, sx_trace_id
# Drop-in SMTP — 保留集成并获得 control plane host: smtp.sendarix.net port: 587 (STARTTLS) username: "YOUR_SMTP_USERNAME" # dashboard › SMTP password: "YOUR_SMTP_PASSWORD"
能力审计(本平台)
下列数量反映应用当前向集成方暴露的能力。任何能发送 HTTPS + JSON 的语言均可调用这些端点;页面包含 六 套可复制示例栈。
4
集成面
6
示例语言
6
使用模式
Surfaces: (1) Transactional send REST, (2) Deliverability Intel REST, (3) SMTP relay (protocol, not JSON), (4) Outbound engagement webhooks (you receive signed HTTPS POSTs from Sendarix). Older /v1 endpoints for alerts, message lookup, domains, events, suppressions and usage are retired and return 410.
集成面
| 集成面 | 机制 | 基础 / 入口 |
|---|---|---|
| 事务发送 | POST JSON,账户 API 密钥 | POST /v1/email/send |
| Retired v1 endpoints | Return 410 with code API_KEYS_RETIRED | /v1/send, /v1/alerts/ingest, /v1/email/{id}, /v1/domains, /v1/events, /v1/suppressions, /v1/reports/usage |
| 送达率 Intel | GET/POST JSON,工作区送达率 API 密钥 | /api/deliverability/v1/*(7 条路由) |
| SMTP 中继 | SMTP AUTH(主机、端口、用户名、密码来自控制台) | 见 SMTP 中继 |
| 互动 Webhooks | 您的 HTTPS 端点接收签名 POST | 在应用中配置 → Webhooks |
认证
- Send API key: header
X-API-Key: …orAuthorization: Bearer …. Keys in the query string are not accepted. Each key belongs to one sending domain and service, andfrommust use that domain. - 送达率 API 密钥: 请求头
X-API-Key(工作区范围;用于 Intel / 送达率监控)。 - 幂等(发送): 可选请求头
Idempotency-Key用于安全重试。
Create and revoke keys in the dashboard under Developers › API keys. How many keys you can create depends on your plan (see Pricing).
发送 API
POST https://app.sendarix.com/v1/email/send
JSON 体字段(除非注明否则必填):
from— required; an address on the domain the API key belongs toto— 字符串或地址数组subjecttextand/orhtml— optional strings; send at least one so the message has a body- Optional:
reply_to(one address),headers(up to 20; onlyList-Unsubscribe,List-Unsubscribe-Post,List-Id,In-Reply-To,References,Auto-Submitted,Precedence),metadata(up to 20 keys) - Not supported:
cc,bccandattachmentsare rejected with422 UNSUPPORTED_FIELD. There are no template or routing-policy fields; build the subject and body in your application.
to takes one address or a list of up to 50. Duplicates are removed, and each address is checked against suppressions, routed and sent as its own message. The response then adds results, recipient_count and accepted_count.A single-recipient send returns 200 with message_id, status, request_id and sx_trace_id. A suppressed address returns status: "suppressed" and is not sent. If the outcome cannot be confirmed, the API returns 202 with status: "unknown". With Idempotency-Key (up to 64 characters) a retry returns the stored result; the same key with a different body returns 409.
Retired endpoints
POST /v1/send, POST /v1/alerts/ingest and the older /v1 lookup endpoints return 410 API_KEYS_RETIRED.
Send with POST /v1/email/send or SMTP. Use the dashboard for logs and suppressions, and signed webhooks for delivery events. Remove calls to retired endpoints from existing integrations.
送达率 Intel API
基础路径:/api/deliverability/v1/。端点含工作区、客户端、域名、黑名单状态与报告生成。均需要送达率工作区 API 密钥。
GET | /workspaces |
GET | /clients |
POST | /clients |
GET | /domains |
POST | /domains |
GET | /blacklists/status |
POST | /reports/generate |
SMTP 中继与入站式 Webhooks
SMTP 使用控制台凭据的标准邮件提交——适合遗留应用与 MTA。互动 Webhooks 由 Sendarix 向您的 URL 出站,用于投递与互动事件(负载与安全见产品页)。
面向服务商的入站 Webhooks(如 Postal)为基础设施端点,非客户集成目标。
发送 API — 示例(6 种语言)
替换 YOUR_API_KEY 与地址。各栈使用相同 JSON。
# Bash — 事务发送
curl -sS -X POST 'https://app.sendarix.com/v1/email/send' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
-H 'Idempotency-Key: order-10042-reset' \
-d '{
"from": "noreply@example.com",
"to": "user@example.com",
"subject": "\u5bc6\u7801\u91cd\u7f6e",
"text": "\u4f7f\u7528\u6b64\u94fe\u63a5\u91cd\u7f6e\u5bc6\u7801\u3002",
"html": "<p>\u4f7f\u7528\u6b64\u94fe\u63a5\u91cd\u7f6e\u5bc6\u7801\u3002</p>"
}'// Node 18+(全局 fetch)
const res = await fetch('https://app.sendarix.com/v1/email/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'Idempotency-Key': 'order-10042-reset',
},
body: JSON.stringify({
from: 'noreply@example.com',
to: 'user@example.com',
subject: "密码重置",
text: "使用此链接重置密码。",
html: "<p>使用此链接重置密码。<\/p>",
}),
});
console.log(await res.json());# Python 3
import json, urllib.request
req = urllib.request.Request(
'https://app.sendarix.com/v1/email/send',
data=json.dumps({
'from': 'noreply@example.com',
'to': 'user@example.com',
'subject': "密码重置",
'text': "使用此链接重置密码。",
'html': "<p>使用此链接重置密码。<\/p>",
}).encode(),
headers={
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'Idempotency-Key': 'order-10042-reset',
},
method='POST',
)
with urllib.request.urlopen(req) as r:
print(r.read().decode())<?php
$ch = curl_init('https://app.sendarix.com/v1/email/send');
$payload = json_encode([
'from' => 'noreply@example.com',
'to' => 'user@example.com',
'subject' => '密码重置',
'text' => '使用此链接重置密码。',
'html' => '<p>使用此链接重置密码。</p>',
]);\ncurl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: YOUR_API_KEY',
'Idempotency-Key: order-10042-reset',
],
CURLOPT_POSTFIELDS => $payload,
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);// Go
package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
body, _ := json.Marshal(map[string]any{
"from": "noreply@example.com",
"to": "user@example.com",
"subject": "密码重置",
"text": "使用此链接重置密码。",
"html": "<p>使用此链接重置密码。<\/p>",
})
req, _ := http.NewRequest("POST", "https://app.sendarix.com/v1/email/send", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Idempotency-Key", "order-10042-reset")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
}# Ruby — net/http
require 'json'
require 'net/http'
uri = URI('https://app.sendarix.com/v1/email/send')
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['X-API-Key'] = 'YOUR_API_KEY'
req['Idempotency-Key'] = 'order-10042-reset'
req.body = {
from: 'noreply@example.com',
to: 'user@example.com',
subject: "密码重置",
text: "使用此链接重置密码。",
html: "<p>使用此链接重置密码。<\/p>",
}.to_json
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body 使用模式(6 种)
- 单次发送 — 每条消息一次 POST,无幂等头。
- 幂等重试 — 网络失败时相同
Idempotency-Key+ 相同正文。 - Bearer 认证 — 将
X-API-Key换为Authorization: Bearer YOUR_API_KEY。 - HTML + 文本 — 在支持处同时提供两者以实现 multipart/alternative 风格渲染。
- Several recipients — put up to 50 addresses in
toand compareaccepted_countwithrecipient_count. - 送达率自动化 — 使用工作区密钥在
/api/deliverability/v1/*下轮询或变更 Intel 资源。
相关