はじめに
クイックスタート
APIキーを作成し、ドメインを検証して、再試行しても安全なリクエストで制御されたメールを送信します。
始める前に
Create a SendHQ workspace and keep the dashboard open. You can verify a domain and create an API key before paying. Sending requires an active subscription: there is no free allowance, including to your own address. Choose a plan at pricing.
1. APIキーを作成する
ダッシュボードでAPIキーを開き、Productionなどのわかりやすい名前を付けて、表示されたキーをコピーします。キーはサーバー側のシークレットマネージャーに保存してください。SendHQが完全な値を再び表示することはありません。
SENDHQ_API_KEY=re_your_key_here2. 送信ドメインを追加する
Open Domains, add a domain you control, and publish the returned DKIM, SPF, DMARC, and domain verification records. Copy the records into your DNS host and click Verify. On Cloudflare, add them as DNS only (grey cloud). Add the records, then click Verify.
include:amazonses.com) into the existing v=spf1 value.3. 検証を待つ
Use the dashboard or POST /domains/:id/verify. DNS can move through pending, checking, and propagating before the sending identity is verified.
4. 制御されたメッセージを送信する
curl https://sendhq.cc/api/v1/emails \
-H "Authorization: Bearer $SENDHQ_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: onboarding-user-42" \
-d '{"from":"Acme <hello@example.com>","to":["owner@example.com"],"subject":"SendHQ is connected","html":"<h1>It works</h1><p>Your first controlled message was accepted.</p>","text":"It works. Your first controlled message was accepted."}'リクエストが成功すると、SendHQのメールID、プロバイダーのメッセージID、会話のスレッドIDが返されます。SendHQのIDは、メール送信のきっかけとなったアプリケーションイベントと一緒に保存してください。
5. 結果を処理する
APIリクエストが受け付けられたことは、受信者への配信とは同じではありません。/emails/:id/eventsを取得するかダッシュボードを使って、配信、バウンス、苦情、拒否、開封、クリックのイベントを確認してください。