Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Build reliable downstream automation from StackShift Mail events without trusting unsigned payloads.

Prerequisites

  • A public HTTPS webhook endpoint
  • Storage for webhook endpoint secret values
  • An idempotent event handler

Workflow

1
List events or inspect a message timeline when debugging.
2
Create a webhook endpoint with a URL and explicit eventTypes.
3
Store the returned secret immediately. It is returned on create. To see the current secret again or rotate it, open the webhook in the dashboard.
4
Verify StackShift webhook signatures with timestamp tolerance before processing.
5
Use delivery detail and retry APIs for failed webhook deliveries.

Event types

  • Message events: mail.message.accepted, mail.message.queued, mail.message.sending, mail.message.mta_accepted, mail.delivery.delayed, mail.delivery.delivered, mail.message.bounced, mail.message.failed, mail.message.suppressed, and mail.message.complained.
  • Suppression events: mail.suppression.created and mail.suppression.deleted.
  • OTP events: mail.otp.created, mail.otp.sent, mail.otp.verified, mail.otp.failed_attempt, mail.otp.failed, mail.otp.expired, and mail.otp.canceled.
  • Template events: mail.template.created, mail.template.updated, mail.template.deleted, mail.template.version.created, and mail.template.test_queued.
  • Domain events: mail.domain.created, mail.domain.verified, mail.domain.failed, and mail.domain.deleted. Partner accounts also receive mail.domain.owner_approval.requested, approved, declined and expired.
  • Webhook events: mail.webhook.created, mail.webhook.updated, mail.webhook.disabled, mail.webhook.delivery.succeeded, and mail.webhook.delivery.failed.
  • Operations events: mail.scheduled.created, mail.scheduled.canceled, mail.scheduled.dispatched, mail.scheduled.failed, mail.batch.created, mail.batch.completed, and mail.batch.failed.
  • Audience and campaign events: mail.audience.created, mail.audience.members.imported, mail.campaign.created, mail.campaign.queued, and mail.campaign.stopped. mail.campaign.stopped is sent when a running campaign is stopped because its sender stayed paused for 7 days; its payload has campaignId, brandId, reason (sender_paused), pauseReason, pausedSince, and message.
  • Partner platform events (partner accounts only): partner.domain.registered, partner.domain.failed, partner.domain.dns_verified, partner.brand.ready, partner.warmup.progress, partner.brand.warning, partner.brand.paused, partner.brand.resumed, partner.brand.bounced, partner.brand.complained, partner.domain.renewal_due, partner.domain.renewed, and partner.domain.renewal_failed. See Partner platforms.
  • Inbound events: mail.inbound.domain.created, mail.inbound.domain.verified, mail.inbound.domain.routing_paused, mail.inbound.received, mail.inbound.quarantined, mail.inbound.failed, mail.message.replied, and mail.message.reply_to_fallback (a message asked for its own reply address while none was receiving).
  • Reputation events include workspace/domain watch, throttled, and disabled states; limit changes; recipient-domain throttling; and manual-review outcomes.

See what is waiting and why an endpoint fails

  • GET /mail/webhooks/{webhookId} returns the endpoint with waitingSummary: how many deliveries are still waiting (pending, delivering or failed; count stops at 1000 and capped is true when more are waiting), when the oldest was created (oldestAt), how many are partner merchant updates (merchantUpdates) and up to three highlights with the event type and the shop, pause events first, taken from the 200 newest waiting deliveries. It is null when nothing is waiting. The list GET /mail/webhooks does not carry it, so read the detail of each endpoint you show.
  • GET /mail/webhooks/{webhookId}/deliveries returns each delivery with durationMs, how long the latest attempt took (or null), and merchant, with partnerDomainId, merchantRef and shop when the event belongs to a partner merchant (or null).
  • GET /mail/webhooks/{webhookId}/diagnosis returns {diagnosis}: the stored checkedAt, repliesRead and plain-language summary from Stackie of why a failing endpoint is failing, or null when Stackie has not looked yet. It never uses AI credits.
  • POST /mail/webhooks/{webhookId}/diagnosis asks Stackie to read the replies the endpoint gave to recent deliveries and returns the new {diagnosis}. It uses AI credits, needs the mail:manage scope, runs at most once every 10 minutes per endpoint (a repeat returns the stored one) and is not available to agent connections.
  • POST /mail/webhooks/{webhookId}/reveal-secret returns the current signing secret as {secret}. Every reveal is audited and rate limited. It needs a signed-in browser session: CLI tokens get 403 browser_session_required and agent connections cannot reveal secrets.

Create a webhook

Verify a signature

Operational APIs

  • GET /mail/events filters by type, resourceType, resourceId, messageId, from, to, limit, and cursor.
  • GET /mail/messages/{id}/timeline returns timeline items with type, label, createdAt, and optional metadata.
  • GET /mail/webhooks/{webhookId}/deliveries filters webhook deliveries by status, limit, and cursor.
  • GET /mail/webhook-deliveries/{deliveryId} includes delivery attempts.
  • POST /mail/webhook-deliveries/{deliveryId}/retry requests a retry for a delivery.

Expected result

Your application processes mail lifecycle events once, verifies signatures, and can recover failed webhook deliveries.

Common failures

  • Webhook handler does not preserve the raw request body before JSON parsing.
  • Signature verification uses the wrong secret after rotation.
  • Handler is not idempotent and double-processes retried events.
  • Endpoint repeatedly returns non-2xx responses and deliveries move from failed toward abandoned. Ask for a diagnosis to see why.
  • Reveal or rotate secret answers 403 browser_session_required: CLI and agent tokens cannot see or change signing secrets. Reveal or rotate it from the webhook in the dashboard.
  • Diagnosis answers 404 webhook_not_failing for an endpoint that is not failing. Asking for a new one (POST) answers 402 ai_credits_exhausted when your AI credits are used up (deliveries keep running), 503 ai_unavailable when Stackie cannot read the endpoint right now, 429 webhook_diagnosis_throttled when one was asked for in the last 10 minutes and none is stored yet, and 403 agent_diagnosis_forbidden from an agent connection.

Send email

Send a single outbound email with the official SDK or REST API, then inspect the message, attempts, logs, and timeline.

Bounces, suppressions, and reputation

Handle hard and soft bounces, workspace-scoped suppressions, sending limits, warmup stage, domain reputation, and reputation events.

Templates and OTP

Create versioned templates, preview and test them, send from a template, and use the built-in one-time-code challenge flow.