Developers

Webhooks

Receive real-time notifications about email events like sends, deliveries, opens, and bounces

Webhooks

Webhooks let you receive real-time notifications when email events occur. Instead of polling for status, Artmail sends HTTP POST requests to your endpoint when an email is sent, delivered, opened, clicked, bounced, or complained about.

How Webhooks Work

  1. You create a webhook in the dashboard and provide a URL.
  2. You subscribe to the event types you care about.
  3. When an event occurs, Artmail signs the payload and POSTs it to your URL.
  4. Your server verifies the signature, processes the event, and returns 2xx to acknowledge receipt.
  5. If your server fails or times out, Artmail retries with exponential backoff (up to 3 retries).

Idempotency

Webhook events include a unique id. Process events idempotently — the same event may be delivered more than once if a retry occurs after a timeout.

Available Event Types

Event TypeDescription
email.sentEmail was queued and accepted for sending
email.deliveredEmail was successfully delivered
email.bouncedEmail bounced (hard or soft)
email.complainedRecipient marked the email as spam
email.openedRecipient opened the email (tracking pixel)
email.clickedRecipient clicked a tracked link
email.unsubscribedRecipient unsubscribed via link

Select which events to receive when creating or editing a webhook. You can subscribe to any combination of these events.

Webhook Payload Format

All webhook events use this structure:

JSON
Loading...
FieldTypeDescription
idstringUnique event ID (for idempotency).
typestringEvent type (e.g. email.delivered).
timestampstringISO 8601 timestamp.
dataobjectEvent-specific data.

Event-specific fields in data vary by event type. Common fields: to, from, subject, messageId, emailId. Bounce events may include bounceType, bounceSubType; click events may include linkUrl, etc.

Setting Up Webhooks

Via Dashboard

  1. Log in to your Artmail dashboard.
  2. Go to Settings → Developer → Webhooks.
  3. Click Create Webhook.
  4. Enter your Endpoint URL (must be HTTPS and publicly reachable).
  5. Select the events you want to receive.
  6. Copy the Signing Secret — you need it to verify signatures.

Save the signing secret

The signing secret is shown once when you create the webhook. Store it securely (e.g. environment variable). If you lose it, regenerate it in the webhook settings.

Signature Verification

Artmail signs each webhook payload with HMAC-SHA256. Always verify the signature before processing to ensure the request came from Artmail and wasn't modified.

Signature Algorithm

  • Input: {timestamp}.{rawRequestBody}
  • Key: Your webhook signing secret
  • Output: Hex-encoded HMAC-SHA256 signature

Headers sent with each request:

HeaderDescription
X-ArtMail-SignatureHMAC-SHA256 hex signature
X-ArtMail-TimestampUnix timestamp used in the signed payload
Content-Typeapplication/json

Node.js Verification Example

Typescript
Loading...

Use raw body

Signature verification requires the raw request body. Do not parse JSON before verifying — use express.raw() or equivalent so the body remains a string/buffer.

Replay Protection (Optional)

Check that the timestamp is within a reasonable window (e.g. 5 minutes) to guard against replay attacks:

Typescript
Loading...

Retry Logic

If your endpoint returns a non-2xx status or times out (10 seconds), Artmail retries:

  • Retries: Up to 3 additional attempts
  • Backoff: Exponential (QStash handles scheduling)
  • Deduplication: Same event ID is not delivered twice concurrently

Return 200 or 204 quickly to acknowledge receipt. Process the event asynchronously if needed.

Example Webhook Handler (Node.js)

Typescript
Loading...

Debugging Webhooks

  • Webhook Logs: View delivery attempts, status codes, and response bodies in Settings → Developer → Webhooks (click a webhook to see logs).
  • Test webhook: Use the "Test" action to send a sample event to your endpoint.
  • Local development: Use a tunnel (ngrok, Cloudflare Tunnel) to expose your local server for testing.

Next Steps

Send Email

Learn how to send transactional emails via the API.

Send Email guide →

Error Handling

Handle API errors and implement retries.

Error handling →