Send email
POST https://sendhawk.online/api/emails
Sends one email. The request returns once Amazon SES has accepted the message, with the id you use to retrieve it and to match webhook events.
Headers
Bearer sk_live_.... See Authentication.application/json.Body
Send either templateId (with optional variables), or subject together with html, text or both. A request with both kinds of content, or with neither, answers 400.
hello@yourdomain.com) or with a display name (Acme <hello@yourdomain.com>). The domain after the @ must exactly match a verified domain in your workspace.from address, for example Acme. When neither from nor fromName carries a name, the workspace's default "from" name from Settings > Workspace is used, if one is set.templateId.html, text or both, unless you send a templateId.html whenever you can.subject, html or text with it.{ "name": "value" }. Pass strings: format numbers and dates the way the recipient should read them.Amazon SES delivers at most 50 recipients per message across to, cc and bcc together, so keep the total at 50 or fewer. Every recipient sees the to and cc addresses; to send the same content to people who should not see each other, send one email per recipient.
Response
200 OK with the id of the email:
{
"id": "4f1c2b8e-7a3d-4e5f-9b21-0c6d8e9f1a2b"
}
Examples
curl https://sendhawk.online/api/emails \
-H "Authorization: Bearer $SENDHAWK_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-receipt" \
-d '{
"from": "Acme <billing@yourdomain.com>",
"to": ["ada@example.com"],
"bcc": "archive@yourdomain.com",
"replyTo": "support@yourdomain.com",
"subject": "Your receipt for order 1042",
"html": "<h1>Thanks, Ada</h1><p>We received your payment of EUR 49.00.</p>",
"text": "Thanks, Ada. We received your payment of EUR 49.00."
}'
curl https://sendhawk.online/api/emails \
-H "Authorization: Bearer $SENDHAWK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourdomain.com",
"to": "ada@example.com",
"templateId": "0193a4f2-5c1e-7b8d-9e0f-1a2b3c4d5e6f",
"variables": { "name": "Ada", "code": "428913" }
}'
Idempotency
Networks fail after a request has been sent, and a blind retry can then send the same email twice. Send an Idempotency-Key header to make the retry safe: when the same key arrives again within 24 hours, SendHawk.Online returns the original response instead of sending again.
- Use a value that identifies the email in your own system, such as
order-1042-receiptor a UUID you store with the job. - Use a new key for every distinct email. A key that is reused within 24 hours never sends a second email.
- Retry
429and5xxresponses with the same key. See Errors and limits.
What happens next
The email starts in the sent status, which means Amazon SES accepted it. From there it moves to delivered, bounced or complained as the receiving server reports back, and to opened and clicked when tracking is on for the domain. Retrieve email shows the current status; webhooks push each change to you.
A recipient on your suppression list is never sent to: the request answers 422 instead.
Errors
| Status | When |
|---|---|
400 | The body is not valid JSON, an address is missing or malformed, or the content rules above are broken. |
401 | The API key is missing, malformed, unknown or revoked. |
404 | templateId does not name a template in this workspace. |
422 | The from domain is not verified in this workspace, or a recipient is suppressed. |
429 | You hit the rate limit or your plan's monthly volume. |
502 | Amazon SES rejected the message. |
Every error uses the same error format.