Webhooks
A webhook is a URL on your server that ScrubiMail calls when something happens to your email. Use it to update your own records on delivery, bounce or complaint without polling /send/status/.
Related:Email sending
Checked against the API source on
How it works
- You add an endpoint (an
httpsURL) and choose which events it receives, or all of them. - When an event happens, we send a
POSTwith a JSON body to your URL, signed with your endpoint's secret. - Reply with any
2xxstatus within 10 seconds. Anything else, or no reply, is retried with a growing delay (see Retries). - Each event is sent to every enabled endpoint that subscribes to it, so two endpoints get two separate deliveries.
Create an endpoint
In the dashboard
Open Webhooks in the sidebar, choose Add webhook, enter the URL and pick the events. The signing secret is shown once when you create the endpoint. Copy it then. If you lose it, use Rotate secret.
With the API
POST /send/webhooks/withurland, optionally,events. The response includessecretonce. Managing webhooks with an API key needs thewebhooksscope (a key with no scopes set can do everything).curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/" \ -H "X-API-Key: $SCRUBIMAIL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/webhooks/scrubimail", "description": "Production", "events": [ "email.delivered", "email.bounced" ] }'const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/", { method: "POST", headers: { "X-API-Key": process.env.SCRUBIMAIL_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ "url": "https://example.com/webhooks/scrubimail", "description": "Production", "events": [ "email.delivered", "email.bounced" ] }), }); const data = await res.json(); if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os import requests payload = { "url": "https://example.com/webhooks/scrubimail", "description": "Production", "events": [ "email.delivered", "email.bounced", ], } res = requests.post( "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/", headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]}, json=payload, timeout=30, ) data = res.json() res.raise_for_status()<?php $payload = <<<'JSON' { "url": "https://example.com/webhooks/scrubimail", "description": "Production", "events": [ "email.delivered", "email.bounced" ] } JSON; $ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/'); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => [ 'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'), 'Content-Type: application/json', ], CURLOPT_POSTFIELDS => $payload, ]); $data = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);
| Rule | Detail |
|---|---|
| Protocol | https only. Redirects are not followed, so give the final URL. |
| Address | The host must resolve to a public IP address. URLs that resolve to private, loopback, link-local or reserved addresses are refused when you save the endpoint and again at delivery time. |
| Limit | 10 endpoints per account. |
| Secret | whsec_ followed by 32 characters. Shown in full on create and on rotate only; everywhere else you see the last four characters. |
Event types
| type | Sent when |
|---|---|
| email.sent | A message was accepted by our mail server. Fires for API sends, campaign messages and mail submitted over SMTP. |
| email.delivered | The recipient's mail server accepted the message. |
| email.delivery_delayed | The recipient's server answered with a temporary error. We keep retrying and send this once per message; a final email.delivered or email.bounced follows. |
| email.bounced | The message could not be delivered. data.bounce has the type (hard or soft) and the server's reason. |
| email.complained | The recipient marked the message as spam. The address is added to your suppression list. |
| email.failed | The message could not be handed to the sending service. Nothing was delivered. |
| email.opened | The recipient opened the message (open tracking). |
| email.clicked | The recipient clicked a tracked link. |
| domain.verified | A sending domain became verified (SPF and DKIM both pass). |
| domain.failed | A sending domain's first verification check failed, or a verified domain stopped passing. Repeated failed checks do not send it again. |
Every event has the same envelope: id (also sent as the ScrubiMail-Event-Id header), type, created_at in UTC, and a data object. Email events share the fields below, plus the extras shown in each example. Treat unknown fields as additive and ignore them.
| Field | Description |
|---|---|
| message_id | The id returned when you sent the message. Matches GET /send/status/{message_id}/. |
| to | Recipient address. |
| from | From address. |
| subject | Subject as sent, after personalisation. |
| campaign_id | Campaign id, or null for a single send. |
| status | Message status at the time of the event. |
| tags | Object built from the tags you sent ({"welcome": true}), empty when none. |
Example payloads
{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.sent",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "sending",
"tags": {
"welcome": true
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.delivered",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "delivered",
"tags": {
"welcome": true
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.delivery_delayed",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "sending",
"tags": {
"welcome": true
},
"reason": "451 4.7.1 Greylisted, try again later"
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.bounced",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "bounced",
"tags": {
"welcome": true
},
"bounce": {
"type": "hard",
"reason": "550 5.1.1 The email account that you tried to reach does not exist."
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.failed",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "failed",
"tags": {
"welcome": true
},
"reason": "Failed to hand off to sending service."
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.complained",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "delivered",
"tags": {
"welcome": true
},
"complaint": {
"type": "abuse"
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.opened",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "delivered",
"tags": {
"welcome": true
},
"open": {
"user_agent": "Mozilla/5.0 (Macintosh)",
"ip": "203.0.113.7"
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.clicked",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"from": "[email protected]",
"subject": "Welcome, Ada!",
"campaign_id": null,
"status": "delivered",
"tags": {
"welcome": true
},
"click": {
"url": "https://yourcompany.com/welcome",
"user_agent": "Mozilla/5.0 (Macintosh)",
"ip": "203.0.113.7"
}
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "domain.verified",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"domain_id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"domain": "yourcompany.com",
"status": "active",
"spf": true,
"dkim": true,
"dmarc": true
}
}{
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "domain.failed",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"domain_id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"domain": "yourcompany.com",
"status": "pending",
"spf": true,
"dkim": false,
"dmarc": false
}
}Verify the signature
Anyone can POST to your URL, so check every request. Each delivery carries these headers:
| Header | Value |
|---|---|
| ScrubiMail-Event-Id | evt_ and 32 hex characters. The same value as id in the body. |
| ScrubiMail-Signature | t=<unix seconds>,v1=<hex signature> |
| Content-Type | application/json |
| User-Agent | ScrubiMail-Webhooks/1.0 |
Read the raw body
Sign the exact bytes you received. If your framework parses the JSON first, capture the raw body before it does; re-serialising changes the bytes and the check fails.
Split the header
Take
t(the timestamp) and everyv1value. More than onev1can appear while you rotate a secret.Compute the signature
HMAC-SHA256, hex-encoded, with your full secret string (including
whsec_) as the key and{t}.{raw body}as the message.Compare and check the age
Compare with a constant-time function and accept if any
v1matches. Reject the request whentis more than 300 seconds from your clock, so a captured request cannot be replayed later.
import crypto from "node:crypto";
import express from "express";
const SECRET = process.env.SCRUBIMAIL_WEBHOOK_SECRET; // whsec_...
const app = express();
function verify(rawBody, header, secret, toleranceSeconds = 300) {
const parts = Object.fromEntries(
header.split(",").map((p) => [p.slice(0, p.indexOf("=")), p.slice(p.indexOf("=") + 1)])
);
const t = Number(parts.t);
if (!t || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
const signatures = header
.split(",")
.filter((p) => p.startsWith("v1="))
.map((p) => p.slice(3));
return signatures.some(
(s) => s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected))
);
}
// express.raw keeps the body as a Buffer, exactly as received.
app.post("/webhooks/scrubimail", express.raw({ type: "application/json" }), (req, res) => {
const raw = req.body.toString("utf8");
if (!verify(raw, req.get("ScrubiMail-Signature") ?? "", SECRET)) return res.sendStatus(400);
const event = JSON.parse(raw);
// Handle event.type here. Reply fast; do slow work in a queue.
res.sendStatus(200);
});import hashlib
import hmac
import os
import time
from flask import Flask, request
SECRET = os.environ["SCRUBIMAIL_WEBHOOK_SECRET"] # whsec_...
app = Flask(__name__)
def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
parts = [p.split("=", 1) for p in header.split(",") if "=" in p]
timestamps = [v for k, v in parts if k == "t"]
signatures = [v for k, v in parts if k == "v1"]
if not timestamps or not timestamps[0].isdigit():
return False
t = int(timestamps[0])
if abs(time.time() - t) > tolerance:
return False
expected = hmac.new(
secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256
).hexdigest()
return any(hmac.compare_digest(s, expected) for s in signatures)
@app.post("/webhooks/scrubimail")
def scrubimail_webhook():
raw = request.get_data() # the bytes as received
if not verify(raw, request.headers.get("ScrubiMail-Signature", ""), SECRET):
return "", 400
event = request.get_json()
# Handle event["type"] here. Reply fast; do slow work in a queue.
return "", 200<?php
$secret = getenv('SCRUBIMAIL_WEBHOOK_SECRET'); // whsec_...
$raw = file_get_contents('php://input'); // the bytes as received
$header = $_SERVER['HTTP_SCRUBIMAIL_SIGNATURE'] ?? '';
function verify_scrubimail(string $raw, string $header, string $secret, int $tolerance = 300): bool {
$t = null;
$signatures = [];
foreach (explode(',', $header) as $part) {
[$key, $value] = array_pad(explode('=', $part, 2), 2, '');
if ($key === 't') $t = $value;
if ($key === 'v1') $signatures[] = $value;
}
if ($t === null || !ctype_digit($t) || abs(time() - (int)$t) > $tolerance) return false;
$expected = hash_hmac('sha256', $t . '.' . $raw, $secret);
foreach ($signatures as $s) {
if (hash_equals($expected, $s)) return true;
}
return false;
}
if (!verify_scrubimail($raw, $header, $secret)) {
http_response_code(400);
exit;
}
$event = json_decode($raw, true);
// Handle $event['type'] here. Reply fast; do slow work in a queue.
http_response_code(200);Retries and timeouts
A delivery succeeds on any 2xx response. A timeout, a connection error, a 3xx, 4xx or 5xx counts as a failed attempt. We wait 10 seconds for a response and do not follow redirects. Failed attempts are retried up to 6 attempts in total:
| Attempt | When |
|---|---|
| 1 | Right away |
| 2 | 30 seconds after attempt 1 failed |
| 3 | 5 minutes after attempt 2 |
| 4 | 30 minutes after attempt 3 |
| 5 | 2 hours after attempt 4 |
| 6 | 8 hours after attempt 5. If this fails the delivery is marked failed. |
A failed delivery stays in the endpoint's delivery list for 30 days, with the last HTTP status and error, and you can retry it from the dashboard or with the retry endpoint. Disabling or deleting an endpoint stops pending retries.
Handle events safely
- Deduplicate on the event id. Retries, and manual retries, resend the same event with the same
id. Store the ids you have processed and skip repeats, or make your handler safe to run twice. - Do not rely on order.
email.deliveredcan arrive before a retriedemail.sent. Usecreated_atand the messagestatuswhen order matters. - Reply quickly. Return
200as soon as the event is stored or queued, and do the slow work afterwards. A handler that takes longer than 10 seconds is retried. - Verify before you trust. Check the signature and the timestamp on every request, and return
400when they do not match. - Keep the secret on the server. Never put it in browser code or a repository.
Test locally
Expose your local server
ScrubiMail only calls public
httpsURLs, solocalhostwill not work. Run a tunnel such asngrok http 3000orcloudflared tunnel --url http://localhost:3000and use thehttpsaddress it prints as the endpoint URL.Send a test event
Choose Send test next to the endpoint in the dashboard, or call the test endpoint. You receive a signed
email.deliveredevent with"test": trueindata.curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/" \ -H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/", { method: "POST", headers: { "X-API-Key": process.env.SCRUBIMAIL_API_KEY, }, }); const data = await res.json(); if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os import requests res = requests.post( "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/", headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]}, timeout=30, ) data = res.json() res.raise_for_status()<?php $ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/'); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_HTTPHEADER => [ 'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'), ], ]); $data = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch);Inspect the delivery
The endpoint's deliveries list shows the payload we sent, the HTTP status you returned and any error, so you can see why a verification failed.
API reference
- Base path:
https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/. Authenticate withX-API-Key; the key needs thewebhooksscope unless it has no scopes set. - Webhooks are scoped to your account. You cannot see or change another account's endpoints.
- The list endpoint returns
{count, next, previous, results}, 20 items per page.
List webhooks
/send/webhooks/webhooksYour webhook endpoints, newest change first. The signing secret is never included; secret_hint shows the last four characters.
Request
curl -X GET "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/", {
method: "GET",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.get(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f",
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
],
"enabled": true,
"secret_hint": "whsec_…k3Ds",
"last_delivery": {
"status": "succeeded",
"event_type": "email.delivered",
"status_code": 200,
"created_at": "2026-12-01T09:14:03Z"
},
"updated_at": "2026-12-01T09:00:00Z"
}
]
}Errors
| Status | Code | When |
|---|---|---|
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Create a webhook
/send/webhooks/webhooksAdds an endpoint. The response is the only time besides rotating that the full secret is returned; store it now. You can have up to 10 endpoints.
Body
| Name | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Where to send events. https only, and the host must resolve to a public address. |
| description | string | No | A note for yourself, up to 255 characters. |
| events | string[] | No | Event types to receive. Empty or omitted means all events, including ones added later. |
| enabled | boolean | No | Default true. A disabled endpoint receives nothing. |
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
]
}'const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
]
}),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
payload = {
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced",
],
}
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
json=payload,
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$payload = <<<'JSON'
{
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
]
}
JSON;
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $payload,
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f",
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
],
"enabled": true,
"secret_hint": "whsec_…k3Ds",
"last_delivery": null,
"updated_at": "2026-12-01T09:00:00Z",
"secret": "whsec_Qm3xT9b7LrV2nKp8ZcYd5HwEa1sUf0Jg"
}Errors
| Status | Code | When |
|---|---|---|
| 400 | validation_error | The URL is not https, does not resolve, or points to a private address; an event type is unknown; or you already have 10 endpoints ({"error": "..."}). |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Get a webhook
/send/webhooks/{id}/webhooksOne endpoint, with secret_hint instead of the secret.
Request
curl -X GET "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/", {
method: "GET",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.get(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f",
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
],
"enabled": true,
"secret_hint": "whsec_…k3Ds",
"last_delivery": {
"status": "succeeded",
"event_type": "email.delivered",
"status_code": 200,
"created_at": "2026-12-01T09:14:03Z"
},
"updated_at": "2026-12-01T09:00:00Z"
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Update a webhook
/send/webhooks/{id}/webhooksChanges any of url, description, events and enabled. Send only the fields you want to change.
Body
| Name | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Where to send events. https only, and the host must resolve to a public address. |
| description | string | No | A note for yourself, up to 255 characters. |
| events | string[] | No | Event types to receive. Empty or omitted means all events, including ones added later. |
| enabled | boolean | No | Default true. A disabled endpoint receives nothing. |
Request
curl -X PATCH "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enabled": false
}'const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/", {
method: "PATCH",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"enabled": false
}),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
payload = {
"enabled": False,
}
res = requests.patch(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
json=payload,
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$payload = <<<'JSON'
{
"enabled": false
}
JSON;
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $payload,
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f",
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
],
"enabled": false,
"secret_hint": "whsec_…k3Ds",
"last_delivery": {
"status": "succeeded",
"event_type": "email.delivered",
"status_code": 200,
"created_at": "2026-12-01T09:14:03Z"
},
"updated_at": "2026-12-01T09:00:00Z"
}Errors
| Status | Code | When |
|---|---|---|
| 400 | validation_error | A field is invalid. |
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Delete a webhook
/send/webhooks/{id}/webhooksDeletes the endpoint and its delivery history. Retries still queued for it are dropped.
Request
curl -X DELETE "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/", {
method: "DELETE",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.delete(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
No body.
204 No Content, empty body
Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Rotate the signing secret
/send/webhooks/{id}/rotate-secret/webhooksGenerates a new secret and returns it once. The old secret stops being used for new deliveries at once, so deploy the new one first or accept a short window of failed signature checks.
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/rotate-secret/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/rotate-secret/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/rotate-secret/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/rotate-secret/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f",
"url": "https://example.com/webhooks/scrubimail",
"description": "Production",
"events": [
"email.delivered",
"email.bounced"
],
"enabled": true,
"secret_hint": "whsec_…Hq7B",
"last_delivery": {
"status": "succeeded",
"event_type": "email.delivered",
"status_code": 200,
"created_at": "2026-12-01T09:14:03Z"
},
"updated_at": "2026-12-01T09:00:00Z",
"secret": "whsec_Zr4nB8w2KxP6mTq1YcDv9LsEj3UhF5Ha"
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Send a test event
/send/webhooks/{id}/test/webhooksQueues a sample email.delivered event with "test": true in data. It is signed and delivered like any other event, and works even when the endpoint is disabled. Check the result in the deliveries list.
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/test/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
"event_id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"event_type": "email.delivered",
"status": "pending",
"attempts": 0,
"last_status_code": null,
"last_error": "",
"next_attempt_at": null,
"delivered_at": null,
"created_at": "2026-12-01T09:14:03Z",
"payload": {
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.delivered",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"status": "delivered"
}
}
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
List deliveries
/send/webhooks/{id}/deliveries/webhooksDelivery attempts for one endpoint, newest first, 20 per page (page, page_size up to 100). Each item includes the full payload. Deliveries are kept for 30 days.
Query
| Name | Type | Required | Description |
|---|---|---|---|
| page | integer | No | Page number, starting at 1. |
| page_size | integer | No | Items per page, up to 100. |
Request
curl -X GET "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/", {
method: "GET",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.get(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
"event_id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"event_type": "email.delivered",
"status": "succeeded",
"attempts": 1,
"last_status_code": 200,
"last_error": "",
"next_attempt_at": null,
"delivered_at": "2026-12-01T09:14:04Z",
"created_at": "2026-12-01T09:14:03Z",
"payload": {
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.delivered",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"status": "delivered"
}
}
}
]
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Retry a delivery
/send/webhooks/{id}/deliveries/{delivery_id}/retry/webhooksQueues a failed (or succeeded) delivery again, with the same event id and payload, and a fresh attempt count and signature timestamp.
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d/retry/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d/retry/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d/retry/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/9f0e1d2c-3b4a-4c5d-8e6f-7a8b9c0d1e2f/deliveries/5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d/retry/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
"event_id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"event_type": "email.delivered",
"status": "pending",
"attempts": 0,
"last_status_code": null,
"last_error": "",
"next_attempt_at": null,
"delivered_at": null,
"created_at": "2026-12-01T09:14:03Z",
"payload": {
"id": "evt_3f1c9a2b7d4e4f60a1b2c3d4e5f60718",
"type": "email.delivered",
"created_at": "2026-12-01T09:14:03Z",
"data": {
"message_id": "d4e5f6a7-2b3c-4d5e-9f01-a2b3c4d5e6f7",
"to": "[email protected]",
"status": "delivered"
}
}
}Errors
| Status | Code | When |
|---|---|---|
| 400 | - | {"error": "This delivery is still being retried."}: it is still pending. |
| 404 | not_found | The webhook does not exist or belongs to another account. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
List event types
/send/webhooks/event-types/webhooksEvery event type you can subscribe to, with a one-line description.
Request
curl -X GET "https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/event-types/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/event-types/", {
method: "GET",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.get(
"https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/event-types/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/webhooks/event-types/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
[
{
"type": "email.sent",
"description": "The message was accepted by our mail server for delivery."
},
{
"type": "email.delivered",
"description": "The recipient's mail server accepted the message."
}
]Errors
| Status | Code | When |
|---|---|---|
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. |
| 403 | permission_denied | The key has scopes set and webhooks is not one of them. |
Something missing or wrong? Email [email protected].