Webhooks
Get a signed request at your own address when an email is delivered, bounces, is opened or clicked, and when a contact subscribes or unsubscribes.
Webhooks tell your server what happened to an email after Wakio accepted it, and when someone subscribes or unsubscribes. Wakio sends each event as a signed POST to an HTTPS address you choose. You manage endpoints in the dashboard under Settings, then Webhooks, next to API keys. There is no API for endpoints yet. Every plan includes webhooks, and deliveries to your endpoint do not count against your sending allowance.
Set up an endpoint
- Open Settings, then Webhooks, and add the address Wakio should call. It must start with
https://, name a host rather than an IP address, use the standard port 443, and carry no username or password. - Pick the events you want, or choose all events. All events includes any type Wakio adds later.
- Pick the streams: transactional email, marketing email, or both. An email event comes only from a stream you picked, the one in its
streamfield. Transactional email is what your app sends through the API, SMTP or a mail library. Marketing email is campaigns, flows and confirmation emails. Contact events come whatever you pick. - Copy the secret, which starts with
whsec_. Wakio shows it once, when you create the endpoint and again each time you rotate it. If you lose it, rotate it. - Press Send test event to check your handler. A test event looks like a real one with
"test": trueat the top level, next toid,typeandoccurred_at, and not insidedata. You can send up to 10 a minute to one endpoint.
Rotating a secret keeps the old one valid for 24 hours. During that time Wakio signs every request with both, so you can deploy the new secret without dropping events.
Wakio refuses to call an address that resolves to a private, loopback, link-local or other internal address, and it never follows a redirect. A redirect counts as a failure, so give Wakio the final address.
What a request looks like
Wakio sends a JSON body with Content-Type: application/json and User-Agent: Wakio-Webhooks/1. Any 2xx answer means you received it. Answer quickly and do the real work afterwards, because Wakio gives up on a request after 10 seconds and reads at most the first 1 KB of your reply.
Every event has the same envelope:
{
"id": "evt_…",
"type": "email.bounced",
"occurred_at": "2026-11-12T08:14:03Z",
"data": {}
}
id: The event's own id. It stays the same on every retry and replay.type: One of the types below.occurred_at: When it happened, in UTC.data: What happened. The shape depends ontype.
Three headers come with every request, following the Standard Webhooks specification: webhook-id, webhook-timestamp and webhook-signature. See Verify the signature.
Rules your handler should follow
- At least once. Wakio can send the same event more than once, for example when your answer was lost on the way back. Treat the
webhook-idheader as a key and ignore one you have already handled. It equals theidin the body. - Unordered. Events can arrive in any order. An
email.deliveredcan arrive before theemail.sentit follows. Useoccurred_atto tell which happened first. - Growth. Within
v1, Wakio only adds fields and event types. It never removes, renames or retypes one. Ignore fields and types you do not know. - Codes. Bounce types and subtypes, complaint feedback types and failure reasons each come from a short list on this page. Anything Wakio does not recognize arrives as
other. Wakio may add a code to a list later, so treat a value you do not know as you wouldother.
Events
email.sent: The sending service accepted the message.email.delivered: The recipient's mail server accepted it.email.bounced: The message bounced.email.complained: The recipient marked it as spam.email.failed: The message was rejected, could not be rendered, or hit a final send error.email.suppressed: The address was suppressed, so the message was not sent.email.opened: The recipient opened a tracked email.email.clicked: The recipient clicked a tracked link.contact.subscribed: A contact became subscribed to a list.contact.unsubscribed: A contact's unsubscribe was recorded.
Fields on every email event
Every email.* event carries these fields in data, plus one block that depends on the type.
email_id(string): Thedlv_id that Send an email returned.to,from(string)subject(string or null): The subject as sent.nullwhen the email was never rendered.stream(string):transactionalormarketing.source(string):transactional,campaign,flow,double_opt_inorsubscription. Asubscriptionemail is one you sent through the API with your ownList-Unsubscribe, and itsstreamismarketing.campaign_id,flow_id,contact_id,brand_id(string or null): Wakio ids.nullwhen the email has none.metadata(object): What the send carried, or{}. Always{}for campaign and flow email.
Emails from the test sends in the dashboard produce no events.
email.sent
{
"id": "evt_…",
"type": "email.sent",
"occurred_at": "2026-11-12T08:14:01Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Your receipt",
"stream": "transactional",
"source": "transactional",
"campaign_id": null,
"flow_id": null,
"contact_id": null,
"brand_id": "brd_…",
"metadata": { "order_id": "1234" }
}
}
email.delivered
Same fields as email.sent, with no extra block.
{
"id": "evt_…",
"type": "email.delivered",
"occurred_at": "2026-11-12T08:14:03Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Your receipt",
"stream": "transactional",
"source": "transactional",
"campaign_id": null,
"flow_id": null,
"contact_id": null,
"brand_id": "brd_…",
"metadata": { "order_id": "1234" }
}
}
email.bounced
Adds bounce with the bounce type, its subtype, and a diagnostic. The type is one of hard, soft or other:
hard: The address does not accept mail. Wakio adds it to your suppressed list and stops sending to it.soft: A temporary problem, such as a full mailbox. Wakio does not suppress the address, so a later email may get through.other: Wakio could not tell what kind of bounce it was. Wakio does not suppress the address.
The subtype is one of general, mailbox_not_found, mailbox_full, message_too_large, content_rejected, attachment_rejected, previously_bounced or other. previously_bounced means the address is on a shared list of addresses that recently bounced for any sender, not necessarily for your mail, so the message was not tried. It is a hard bounce.
The diagnostic is the reply from the recipient's mail server, such as smtp; 550 5.1.1 user unknown. It is untrusted text written by a server you do not control, so escape it before you display it. Wakio sends at most 1,000 characters of it, removes control characters, and replaces any IPv4 address and any host name that points at the sending side with [sending server]. It is null when there was no reply from the recipient's server, as with previously_bounced.
{
"id": "evt_…",
"type": "email.bounced",
"occurred_at": "2026-11-12T08:14:03Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Your receipt",
"stream": "transactional",
"source": "transactional",
"campaign_id": null,
"flow_id": null,
"contact_id": null,
"brand_id": "brd_…",
"metadata": { "order_id": "1234" },
"bounce": {
"type": "hard",
"subtype": "mailbox_not_found",
"diagnostic": "smtp; 550 5.1.1 user unknown"
}
}
}
email.complained
Adds complaint with feedback_type, the kind of report the mailbox provider sent. The feedback type is one of abuse, auth-failure, fraud, not-spam, virus or other. These are the RFC 5965 report types, hyphens included. It is null when the mailbox provider gave none.
Wakio adds the address to your suppressed list. A complaint about marketing email stops further marketing email to it, and a complaint about transactional email stops all email to it.
{
"id": "evt_…",
"type": "email.complained",
"occurred_at": "2026-11-12T09:30:00Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "November news",
"stream": "marketing",
"source": "campaign",
"campaign_id": "cmp_…",
"flow_id": null,
"contact_id": "con_…",
"brand_id": "brd_…",
"metadata": {},
"complaint": { "feedback_type": "abuse" }
}
}
email.failed
Adds failure with a reason. Wakio sends this when the message was rejected, could not be assembled, or hit a send error it will not retry.
The reason is one of these:
account_suspended: Your Wakio account is suspended.account_paused: Sending from your account is paused.no_subscription: Your account has no active subscription.domain_not_ready: The sending domain is not verified and ready to send.rate_limited: Wakio's sending capacity stayed full until Wakio stopped trying this message. That can happen when sending is busy, not only because of your own volume, and sending the email again later may succeed.sending_error: Wakio could not hand the message to the sending service.interrupted: The send was cut off partway, and Wakio could not tell whether the message went out. It does not try again, so the recipient never gets it twice.sending_held: Wakio had put marketing sending on hold to protect delivery, so this email sent with your own unsubscribe link did not go out. Send it again later with a newIdempotency-Key: the same key returns the first response and sends nothing.rejected: The sending service refused the message, for example because it carried a virus.rendering_failed: The message could not be assembled after Wakio handed it over for sending. It does not mean a problem with your template, and you should rarely see it.other: Any other failure.
{
"id": "evt_…",
"type": "email.failed",
"occurred_at": "2026-11-12T08:14:02Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": null,
"stream": "transactional",
"source": "transactional",
"campaign_id": null,
"flow_id": null,
"contact_id": null,
"brand_id": "brd_…",
"metadata": {},
"failure": { "reason": "rejected" }
}
}
email.suppressed
Adds suppressed with a reason. The reason is one of hard_bounce, complaint, unsubscribe, manual or invalid. Handle a reason you do not recognize, because Wakio may add one later. The send was stopped because the address is suppressed. See the suppressed list.
Wakio does not send email.suppressed for an address that was already suppressed when a campaign started. Those addresses were on your suppressed list before the campaign began, and the campaign leaves them out without a delivery record.
{
"id": "evt_…",
"type": "email.suppressed",
"occurred_at": "2026-11-12T08:14:01Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": null,
"stream": "transactional",
"source": "transactional",
"campaign_id": null,
"flow_id": null,
"contact_id": null,
"brand_id": "brd_…",
"metadata": {},
"suppressed": { "reason": "hard_bounce" }
}
}
email.opened
Adds open with machine. It is true when the open looks like a mail provider or security scanner fetching the image, and false for a person. Wakio sends both so your counts match the dashboard. If a later fetch shows a person opened an email first recorded as a machine open, Wakio sends a second email.opened for it, so one email can produce two.
{
"id": "evt_…",
"type": "email.opened",
"occurred_at": "2026-11-12T10:02:44Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "November news",
"stream": "marketing",
"source": "campaign",
"campaign_id": "cmp_…",
"flow_id": null,
"contact_id": "con_…",
"brand_id": "brd_…",
"metadata": {},
"open": { "machine": false }
}
}
email.clicked
Adds click with the url that was clicked and machine, which means the same as for opens. Every click produces an event.
{
"id": "evt_…",
"type": "email.clicked",
"occurred_at": "2026-11-12T10:03:10Z",
"data": {
"email_id": "dlv_…",
"to": "[email protected]",
"from": "[email protected]",
"subject": "November news",
"stream": "marketing",
"source": "campaign",
"campaign_id": "cmp_…",
"flow_id": null,
"contact_id": "con_…",
"brand_id": "brd_…",
"metadata": {},
"click": { "url": "https://example.com/welcome", "machine": false }
}
}
contact.subscribed
Sent when a contact becomes subscribed to a list. The fields are contact_id, email, brand_id, list_id and source. source says how they joined:
doi_click: They confirmed their address from the confirmation email.api: Your app subscribed them with Add a contact.admin: Someone on your team added them to one list from the contact's page in the dashboard.
A confirmation that belongs to no list sends list_id: null. A contact who leaves a list and joins it again sends it again. Some ways of joining a list send nothing; see Changes that send no event.
{
"id": "evt_…",
"type": "contact.subscribed",
"occurred_at": "2026-11-12T11:20:00Z",
"data": {
"contact_id": "con_…",
"email": "[email protected]",
"brand_id": "brd_…",
"list_id": "lst_…",
"source": "doi_click"
}
}
contact.unsubscribed
Sent for every unsubscribe Wakio records. It has the same fields as contact.subscribed, plus:
scope:list,brandoreverything. Witheverything,list_idandbrand_idarenull. Withbrand,list_idisnull.email_id: The email the person unsubscribed from, ornullwhen there is none.
source says why:
one_click: The person used the unsubscribe link or their mail app's unsubscribe button.admin: Someone on your team did it in the dashboard.api: Your app did it through the API.complaint: The person marked an email as spam.flow: A flow's unsubscribe step did it.
An unsubscribe that reaches more than one contact sends one event for each of them. A complaint the sending service reports more than once sends one event. Some ways of leaving a list send nothing; see Changes that send no event.
{
"id": "evt_…",
"type": "contact.unsubscribed",
"occurred_at": "2026-11-12T12:45:09Z",
"data": {
"contact_id": "con_…",
"email": "[email protected]",
"brand_id": "brd_…",
"list_id": "lst_…",
"source": "one_click",
"scope": "list",
"email_id": "dlv_…"
}
}
Changes that send no event
These change who is on a list, or a contact's subscription, without a contact.subscribed or contact.unsubscribed event. If you mirror list membership elsewhere, sync it again after you use them. Bounces, complaints and suppressions are not listed here: they reach you as email.* events about the email involved, or as email.suppressed when a later send is stopped.
- Removing a contact from a list on the contact's page in the dashboard. Wakio treats it as your team tidying the list, not as the person unsubscribing, so you can add them back later.
- Add to list on the Contacts page, which adds everyone who matches the current filter. Only adding a contact to one list from the contact's page sends
contact.subscribed. - Deleting a list. Everyone on it leaves it.
- Imports. Contacts an import adds to a list send no
contact.subscribed, and contacts it marks unsubscribed send nocontact.unsubscribed. A row for a contact who is not active takes them off the import's list. You started the import, and its report tells you what happened. - Erasing a contact. See Erasing a contact.
- Confirming one list after unsubscribing from everything. The contact rejoins that list, which sends
contact.subscribed, and leaves any other list they were still on without an event. - Unsubscribing from an email sent to an address that is not a contact. Wakio records the unsubscribe against the address, but there is no contact to report.
- Unsubscribing through your own
List-UnsubscribeURL. A send withheaderspoints the inbox's unsubscribe button at your URL, so Wakio never sees the press. - Adding a contact through the API with
subscribed: trueandlists: []. The contact can now get your campaigns but joins no list, so there is nothing to report.
Opens and clicks
Wakio records opens and clicks only for campaign and flow email, and only when tracking is on for your account. It is off by default. Wakio never records them for transactional mail, so subscribing to email.opened to watch a password reset will wait forever. Opens and clicks explains what Wakio counts and filters out.
Tag a send with your own ids
To tie an event back to your own record, send metadata with the email. It is an object of text values: up to 10 keys, each key 1 to 40 letters, digits, underscores or hyphens, each value up to 256 characters, and 2 KB in all. Anything else is refused with 422 invalid_request.
curl https://api.wakio.net/v1/emails \
-H "Authorization: Bearer $WAKIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "[email protected]",
"subject": "Your receipt",
"text": "Thanks for your order.",
"metadata": { "order_id": "1234" }
}'
Wakio includes the object as data.metadata in every event about that email. An email from a campaign or a flow carries {}.
The Rails delivery method, the Node client and the WordPress plugin cannot add a JSON field to a message. They read an X-Wakio-Metadata header holding a JSON object, move it into metadata, and do not send it as a mail header:
mail(to: user.email, subject: "Your receipt", "X-Wakio-Metadata" => { order_id: order.id.to_s }.to_json)
await transporter.sendMail({
to: user.email,
subject: "Your receipt",
headers: { "X-Wakio-Metadata": JSON.stringify({ order_id: String(order.id) }) },
})
wp_mail( $user->user_email, 'Your receipt', $message, array( 'X-Wakio-Metadata: ' . wp_json_encode( array( 'order_id' => (string) $order->get_id() ) ) ) );
Verify the signature
Check every request before you trust it. Wakio signs webhook-id, webhook-timestamp and the raw body with your secret, so verify against the exact bytes you received, before any JSON parsing.
webhook-id: The event id.webhook-timestamp: The time Wakio sent the request, in Unix seconds.webhook-signature: One or more signatures separated by spaces, each writtenv1,and then base64. During the 24 hours after a rotation there are two. A request is genuine if any one of them matches.
The signed text is webhook-id, webhook-timestamp and the raw body joined with dots. The signature is the HMAC-SHA256 of that text, with the base64 decoding of your secret after whsec_ as the key. Reject a timestamp more than 5 minutes from your clock, so a captured request cannot be replayed later.
Ruby
Wakio::Webhook.verify comes with the wakio gem. It checks the signature and the timestamp, and returns the parsed event as a hash. It raises Wakio::Webhook::InvalidSignature when the request is not genuine.
class WakioWebhooksController < ActionController::API
def create
event = Wakio::Webhook.verify(payload: request.raw_post, headers: request.headers, secret: ENV.fetch("WAKIO_WEBHOOK_SECRET"))
HandleWakioEvent.perform_later(event)
head :ok
rescue Wakio::Webhook::InvalidSignature
head :bad_request
end
end
Node.js
verifyWebhook comes with the @wakio/sdk package. It checks the signature and the timestamp, returns the parsed event, and throws WakioWebhookError when the request is not genuine. Pass the body as text, not as parsed JSON.
import { verifyWebhook, WakioWebhookError } from "@wakio/sdk"
export async function POST(request: Request) {
const payload = await request.text()
try {
const event = await verifyWebhook({ payload, headers: request.headers, secret: process.env.WAKIO_WEBHOOK_SECRET! })
await handleWakioEvent(event)
return new Response(null, { status: 200 })
} catch (error) {
if (error instanceof WakioWebhookError) return new Response(null, { status: 400 })
throw error
}
}
PHP
Without a library, check it yourself. This works in WordPress and in any other PHP.
<?php
$secret = getenv('WAKIO_WEBHOOK_SECRET');
$payload = file_get_contents('php://input');
$id = $_SERVER['HTTP_WEBHOOK_ID'] ?? '';
$timestamp = $_SERVER['HTTP_WEBHOOK_TIMESTAMP'] ?? '';
$header = $_SERVER['HTTP_WEBHOOK_SIGNATURE'] ?? '';
if (!ctype_digit($timestamp) || abs(time() - (int) $timestamp) > 300) {
http_response_code(400);
exit;
}
$key = base64_decode(substr($secret, strlen('whsec_')));
$expected = base64_encode(hash_hmac('sha256', "$id.$timestamp.$payload", $key, true));
$valid = false;
foreach (explode(' ', $header) as $candidate) {
[$version, $signature] = array_pad(explode(',', $candidate, 2), 2, '');
if ($version === 'v1' && hash_equals($expected, $signature)) {
$valid = true;
}
}
if (!$valid) {
http_response_code(400);
exit;
}
$event = json_decode($payload, true);
http_response_code(200);
Delivery and retries
Wakio tries each event up to 8 times: immediately, 5 seconds, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, and 10 hours after the one before. That is about 28 hours in all. An event that fails every try stops there, and Replay failed in the dashboard resends it.
A request succeeds on any 2xx answer. A redirect, any other status, a timeout or a refused connection counts as a failure. Wakio waits at most 10 seconds for an answer, and the address must be reachable over HTTPS on port 443.
When a request fails, Wakio holds back every other event for that endpoint for a while, so a dead endpoint gets one request at a time and not one for every waiting event. The wait is 5 seconds after the first failure in a row and 5 minutes after each one after that, so Wakio retries a failing endpoint about every 5 minutes, one event at a time. Waiting events stay pending until the endpoint recovers or is turned off, so on a busy endpoint most of them never use up their tries. Send test event and Replay on one attempt skip the wait, and that event goes out first. Changing the URL also skips the wait. Retry now cancels the wait and makes every waiting event due.
Wakio sends one request at a time for your whole account, and your endpoints take turns. A turn lasts up to 20 seconds, plus the request in flight when it ends, and an answer that takes 5 seconds or more ends it early. When a turn ends, an endpoint with events waiting goes next, before the one that just had its turn. How fast events arrive depends on how fast you answer, and is roughly 5 to 20 events a second, shared by every endpoint of yours that has events waiting. A campaign to 270,000 people with deliveries, opens and clicks switched on makes about a million events. When one endpoint subscribed to all of them is the only one with events waiting, it takes roughly 14 to 55 hours to receive that many. Two such endpoints share the rate and take about twice as long each. If that is too slow, subscribe to fewer types, or answer sooner and queue the work on your side.
If your app needs transactional events quickly while campaigns run, give them an endpoint of their own that takes transactional email only. Its events no longer wait behind the campaign's events. They still share your account's turns, so each one can wait for the turn of each of your other endpoints that has events waiting.
Your sending, and other accounts' endpoints, are not slowed by a busy or broken endpoint. Your own endpoints share your turns, so a slow or broken one makes the others wait longer for theirs.
When an endpoint keeps failing
- After 24 hours of failing, Wakio emails your account's owners and admins once, and shows a banner on the endpoint.
- After 5 days of failing, with at least 10 failed requests in a row and no success between, Wakio turns the endpoint off. It marks every event still waiting as failed and stops collecting new ones. Resume in the dashboard starts collecting again, and Replay failed sends the events that were dropped, as long as Wakio still holds them.
Pause is different. A paused endpoint still collects events and sends none. When you resume, Wakio delivers them oldest first. Wakio keeps events for 30 days, so pause for less than that.
What the dashboard shows
For each endpoint, the dashboard lists every attempt with its time, event type, the HTTP status or error, how long it took, the first 1 KB of your answer, and the payload Wakio sent. You can replay one attempt, replay everything that failed since a time you pick, and send a test event.
Erasing a contact
When you erase a contact, Wakio sends no event, and deletes the events it still stores about that address, including ones waiting to be sent. Mail Wakio had already handed to the sending service for that address can still report back after the erasure, so you may get a later email.delivered, email.bounced, email.opened or email.clicked event for it. Events Wakio already delivered to your endpoint are your copy. When someone asks to be erased, delete them from your own records too.