SendHQ

Email API security

Verify who can send from your domain, limit which operations a key can perform and check the signature on every delivery callback.

Verify your sending domain with three DNS records

When you enroll a domain, SendHQ generates a 2048-bit RSA keypair and returns three TXT records. Use the exact names and values from your enrollment. The private DKIM key is stored encrypted with AES-256-GCM.

RecordWhat to publish
DKIMThe issued public key at your domain-specific selector. The matching private key lets SES sign mail on behalf of that domain.
SPFInclude amazonses.com in the domain’s existing SPF policy. Keep one SPF policy at that name and place the include before the terminal all rule.
DMARCPublish a policy at _dmarc on the sending domain. Keep an existing valid policy. The suggested p=none value requests monitoring.

The verifier checks DNS through two public resolvers and confirms SES identity and DKIM readiness. While verification is pending, a new submission from the domain gets 403 domain_not_verified. Read the SES guide to DKIM and SPF alignment with DMARC.

Limit the reach of an API key

The account and environment come from the bearer credential. SendHQ stores key digests and shows a newly issued secret once. Use separate keys for each workload and keep raw secrets on the server.

ScopeUse it for
sendSubmit a message and enroll a sending domain.
readRead account email logs, metrics, domain status and sending usage.
webhooks:manageRegister and remove webhook endpoints.
keys:manageIssue or revoke keys within the caller’s grantable scopes and request a subscription checkout.

To rotate a key, issue its replacement in the same environment, update the consuming service, verify authentication, then revoke the old key by ID.

Verify signed webhooks before reading the event

Each endpoint has its own signing secret. Capture the raw body as bytes. SendHQ signs the Unix timestamp in seconds, a literal period, then the unmodified body with HMAC-SHA256. In Node.js, the header names arrive in lowercase.

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyDelivery(rawBody, headers, secret, now = Math.floor(Date.now() / 1000)) {
  const timestamp = headers["x-mailforge-timestamp"];
  const received = headers["x-mailforge-signature"];
  if (!Buffer.isBuffer(rawBody) || typeof secret !== "string" || !secret.length) return false;
  if (typeof timestamp !== "string" || !/^(0|[1-9][0-9]{0,14})$/.test(timestamp)) return false;
  if (typeof received !== "string" || !/^[0-9a-f]{64}$/.test(received)) return false;
  if (Math.abs(now - Number(timestamp)) > 300) return false;

  const expected = createHmac("sha256", secret)
    .update(timestamp + ".")
    .update(rawBody)
    .digest();
  return timingSafeEqual(expected, Buffer.from(received, "hex"));
}

Call this function with the original Buffer, the incoming headers and your endpoint secret. The example rejects timestamps more than five minutes from the receiver’s clock and compares digests in constant time. After verification, parse JSON and persist the event’s string ID together with its business change before responding with 2xx.

A failed callback has up to five retries after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. Each retry keeps the event ID and body and gets a new signature. After the final failure, the endpoint is disabled. Use the email event history to reconcile missed events.

Suppress permanent bounces and complaints

SendHQ verifies incoming provider notifications against its configured SNS topic and signature version 2. A confirmed permanent bounce or complaint records the event and suppresses the affected recipient for the sending account. A transient bounce alone leaves the suppression list unchanged.

A new submission to a suppressed address returns 422 recipient_suppressed. Stop retrying that recipient and use the message history to investigate. Review bounce and complaint metrics or read the acceptable use policy.