API reference

Send email

POST /api/emails sends one email from a verified domain, with raw content or a template.
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

Authorization
string required
Bearer sk_live_.... See Authentication.
Content-Type
string required
application/json.
Idempotency-Key
string
Optional. A unique value per email, so a retried request cannot send twice. See Idempotency.

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.

from
string required
The sender, as a bare address (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.
fromName
string
A display name for a bare 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.
to
string | string[] required
One recipient, or an array of up to 50.
cc
string | string[]
Carbon copy recipients.
bcc
string | string[]
Blind carbon copy recipients.
replyTo
string
The address replies go to. Defaults to the workspace's default reply-to from Settings > Workspace, if one is set.
subject
string
The subject line. Required unless you send a templateId.
html
string
The HTML body. Send html, text or both, unless you send a templateId.
text
string
The plain-text body. Clients that do not render HTML show this, and spam filters look for it, so send it alongside html whenever you can.
templateId
string
The id of a template in your workspace. The template supplies the subject and the bodies, so do not send subject, html or text with it.
variables
object
Values for the template's merge tags, as { "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."
  }'

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-receipt or 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 429 and 5xx responses 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

StatusWhen
400The body is not valid JSON, an address is missing or malformed, or the content rules above are broken.
401The API key is missing, malformed, unknown or revoked.
404templateId does not name a template in this workspace.
422The from domain is not verified in this workspace, or a recipient is suppressed.
429You hit the rate limit or your plan's monthly volume.
502Amazon SES rejected the message.

Every error uses the same error format.