Skip to content

Webhooks

Webhooks push mail lifecycle events to your endpoint as they happen — delivery confirmations, bounces, complaints, failures. Create an endpoint in the console under Webhooks: you choose the events (or * for all), and get a signing secret (whsec_…) that is shown once. Endpoint count is plan-gated — 1 on Free, 3 on Pro, 10 on Team, and unlimited on Business and up (Plans & add-ons).

Event names predate the state names and can’t change within v1, so the table maps each event to the state the mail is in after it. Note the one trap: mail.accepted means Mailway received the mail; a provider accepting it is mail.sent.

Event Fires when State after
mail.accepted Mailway received the mail from your app. pending
mail.sent A provider accepted the mail. accepted
mail.delivered The provider’s delivery event arrived: the recipient’s mail server confirmed receipt. delivered
mail.bounced The mail bounced for a recipient, permanently or for now. data.bounce says which. bounced / soft_bounced
mail.delayed The provider reported a delay: it couldn’t deliver yet and is still trying. soft_bounced
mail.complained The recipient marked it as spam. complained
mail.failed The mail was rejected (by a rule, a person in the console, a revoked SMTP credential, a deleted project, its team’s deletion, or a provider’s permanent refusal of its only recipient), or every attempt failed. data.reason says which. failed (Rejected) / exhausted
mail.suppressed The project’s suppression list blocked it. failed (Rejected)

Plus webhook.test, a synthetic event emitted by the console’s Send test button.

mail.delivered, mail.bounced, mail.delayed, and mail.complained come from your provider’s delivery events, and each delivery event is its own webhook event. A mail to three recipients can get three mail.delivered, or two mail.delivered and one mail.bounced. data.recipients says whose outcome each one is, and one event can name several recipients when the provider reports them together. The mail itself has one state, the highest of its outcomes so far in this order: complained, bounced, delivered, soft_bounced. So a mail that bounced permanently for one recipient is bounced, even if its other recipients got mail.delivered.

Events are normalized across providers: a mail.bounced looks the same whether Amazon SES, SendGrid, Mailgun, Postmark, or any other supported provider reported the underlying bounce — one vocabulary for your whole provider set, so your consumer never branches on who happened to carry the message. (data.bounce means the same from every provider. The diagnostic block carries what the provider reported: the receiving server’s reply, and from Amazon SES also the reporting server and each recipient’s action.)

One envelope for every event type:

{
"id": "we.01k8w9…",
"type": "mail.bounced",
"created_at": "2026-06-23T18:20:05.412Z",
"data": {
"event_id": "ev.01k8w9…",
"occurred_at": "2026-06-23T18:20:03.000Z",
"mail": {
"uid": "m.01k8w9…",
"subject": "Invoice #2043",
"from": "billing@yourapp.com",
"to": ["customer@example.com"],
"project": { "uid": "p.01k8w9…", "name": "Billing" },
"tags": ["invoice"],
"metadata": { "invoice_id": "2043" }
},
"provider": "amazon-ses",
"recipients": ["customer@example.com"],
"bounce": "permanent",
"diagnostic": {
"kind": "bounce",
"bounce_type": "Permanent",
"bounce_subtype": "General",
"reporting_mta": "…",
"recipients": [
{ "email": "customer@example.com", "status": "5.1.1", "action": "failed", "diagnostic_code": "smtp; 550 5.1.1 user unknown" }
]
}
}
}

Every event carries these:

Field What it is
id The delivery’s ID (we.…). It stays the same when Mailway retries or you redeliver this delivery.
type The event type.
created_at When Mailway built this delivery.
data.event_id The event’s ID (ev.…). It is the same on every delivery of this event, to every endpoint that receives it, so deduplicate on it.
data.occurred_at When the event happened, in UTC. For delivery events it is the provider’s time, or the time Mailway received the provider’s event if the provider gave none. For the others it is the time Mailway recorded the event, for example when the provider accepted the mail for mail.sent.
data.mail The mail, on every event except webhook.test.

Delivery events (mail.delivered, mail.bounced, mail.delayed, and mail.complained) add provider (the provider account’s family), recipients (the addresses this event is about), and a diagnostic block, which is null on mail.delivered. mail.bounced adds bounce: permanent (the recipient’s server refused it for good, and the address goes on the project’s suppression list) or transient (refused for now, for example a full mailbox). A mail.delayed has no bounce. Its diagnostic has kind: "delay" and retry_until, when the provider stops trying: Amazon SES gives it, and it is null from the other providers. mail.sent adds provider and transport. mail.suppressed adds suppressed, the addresses on the suppression list.

Amazon SES, SendGrid, Mailgun, Mandrill, Brevo, Resend, MailerSend, and Nuntly report delays (Amazon SES only when its event destination publishes DeliveryDelay; see the Amazon SES guide). Mailway reads every temporary failure Mailgun reports as a delay, because Mailgun keeps trying. Postmark, Mailjet, Mailtrap, and SMTP2GO don’t report delays: a temporary failure there arrives as mail.bounced with bounce: "transient".

data.mail.tags lists the mail’s tags: those the send request carried, plus any your rules added, minus any a rule removed. data.mail.metadata is the send request’s metadata, or null when it had none or the mail’s retention window has ended. Mail sent over SMTP or from the console carries neither, so its tags come only from rules and its metadata is always null. To match an event to your own records, use data.mail.uid (the id the send endpoint returned), which never changes, or your metadata while the mail’s content is kept.

This is version 1 of the payload, and every delivery says so in its X-Mailway-Webhook-Version: 1 header. Mailway adds fields and event types within version 1, so ignore any field or event type you don’t know.

mail.failed carries data.reason, which says what ended the mail:

reason What ended it Also in data
rule One of your rules rejected it. rule: its uid, the name it had when it fired, and the reason written on its reject action (null if the action has none)
person A person on your team rejected it in the console while it was paused or captured.
smtp_credential_revoked Mailway received it with an SMTP credential that had been revoked more than 5 minutes earlier. A project’s SMTP credentials are revoked when the project is deleted.
project_deleted Its project was deleted more than 5 minutes before the mail was due to be sent (for example, a mail scheduled with scheduled_at).
team_deletion The deletion of its team started more than 5 minutes before the mail was due to be sent.
provider_refused A provider permanently refused the mail’s only recipient (a hard bounce), so Mailway stopped without trying another provider. provider, and error_type: hard_bounce
exhausted Every attempt failed. error_type and error, about the last attempt

On an exhausted mail, branch on error_type. error is one sentence for people, and its wording can change.

error_type The last attempt
auth The provider refused the provider account’s credentials.
provider_quota The provider account had no sending capacity left: credits or a daily limit used up, or the account paused.
hard_bounce The provider permanently refused one of the mail’s recipients. For a mail with one recipient, the reason is provider_refused instead.
soft_bounce The provider refused the mail for now, for example because a mailbox was full.
rate_limit The provider asked Mailway to send more slowly.
timeout The provider did not answer in time.
connection Mailway could not connect to the provider.
unknown The provider refused the mail with an answer Mailway does not classify.
no_provider No provider was available: none is attached that can send the mail, none matches the provider the mail is pinned to, or every one has used up its free tier and has Stop at the free tier on.
internal An error inside Mailway, not a provider’s answer.

Mailway can add reason and error_type values. Treat one you don’t know as a failure.

A mail rejected when Mailway receives it (by a rule, or because of a revoked SMTP credential or a deleted project) gets mail.accepted first, then mail.failed. Mailway sends the two right after each other, but they can arrive in either order, so don’t rely on the order they arrive in. A scheduled mail whose project was deleted got mail.accepted when Mailway received it, and gets mail.failed at its scheduled time, up to 72 hours later. A mail the suppression list blocks gets mail.suppressed and no mail.failed.

Every delivery is signed with your endpoint’s secret. Verify before trusting anything:

X-Mailway-Signature: t=1782238805,v1=5257a869e7…
X-Mailway-Event: mail.bounced
X-Mailway-Delivery: we.01k8w9…
X-Mailway-Webhook-Version: 1

Recompute HMAC-SHA256("{t}.{raw_body}", secret), compare it in constant time against each v1 in the header, accept the delivery if any one matches, and reject timestamps older than your tolerance (5 minutes is a good default) to defeat replay. Mailway sends one v1 today. Code that checks every v1 keeps working if a later version sends two, for example while a secret rotates.

import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(rawBody, signatureHeader, secret, toleranceSec = 300) {
let t = '';
const signatures = [];
for (const part of signatureHeader.split(',')) {
const [key, value = ''] = part.trim().split('=');
if (key === 't') t = value;
if (key === 'v1' && value) signatures.push(value);
}
if (!/^\d+$/.test(t) || signatures.length === 0) return false;
if (Math.abs(Date.now() / 1000 - Number(t)) > toleranceSec) return false;
const expected = Buffer.from(
createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex'),
);
return signatures.some((signature) => {
const given = Buffer.from(signature);
return given.length === expected.length && timingSafeEqual(given, expected);
});
}
  • Timeout & success: your endpoint has 10 seconds to respond, 5 of them to connect. Any 2xx counts as delivered. Redirects are not followed.
  • Slow endpoints: an endpoint that takes 5 seconds or more, or doesn’t answer, gets its deliveries one at a time, in turns shared with other slow endpoints, until it answers in under 5 seconds again.
  • Retries: failed deliveries retry on a backoff ladder — immediately, then 1 min, 5 min, 30 min, 2 h, and 6 h after each failed attempt (six attempts over about 8.6 hours for an endpoint that answers in under 5 seconds). After three attempts in a row that get no answer, or a non-2xx answer after 5 seconds or more, Mailway pauses the endpoint’s deliveries. It tries one after about 1 minute, then 2, 4, 8, 16, then every 30 minutes, until an attempt gets a 2xx or any answer in under 5 seconds. A paused delivery keeps its remaining attempts, so they can take longer.
  • Giving up: Mailway stops trying a delivery that has had no attempt for 72 hours and marks it failed, with the reason in its delivery log. You can redeliver it.
  • Auto-disable: an endpoint that keeps failing for 24 hours is disabled automatically, and Mailway tells the team by mail (the team email, or its admins) and on the console’s Webhooks page. While it is disabled, Mailway marks each waiting delivery failed when its next attempt comes due. Events that happen while it is disabled are never sent to it, not even after you re-enable it. Re-enable it from the console once it’s healthy.
  • At-least-once: an event can occasionally arrive more than once. Retries and redeliveries of one delivery keep its id, but Mailway can also send the same event again as a new delivery with a new id. data.event_id is the same every time, so deduplicate on it. Don’t deduplicate on type and data.mail.uid: one mail gets several events of one type, for example a bounce for each recipient. A mail retried from the console that fails again gets a new mail.failed with a new data.event_id.
  • No order: events can arrive in a different order than they happened, for example when a delivery is retried. Don’t assume an order between them.
  • Secrets rotate instantly: rotating an endpoint’s secret invalidates the old one immediately, and the new secret is shown once.

Respond fast: acknowledge with a 2xx and process the event async. Anything slow inside the request window risks the 10-second timeout and a needless retry, and an answer that takes 5 seconds or more also slows your later deliveries.

Not receiving events you expect? The troubleshooting guide covers the usual causes — non-2xx responses, an auto-disabled endpoint, and signature mismatches.