Webhooks
A webhook tells your own system what happened to each message: delivered, bounced, expired, complained or dropped. Teneo sends these events in near real-time to an HTTPS address you choose, signed so you can check that they come from us.
Set up a webhook
Open Configure > Webhooks in the console and add an endpoint. Give it the HTTPS address that should receive the events, choose which event types it wants and whether it covers all your relay accounts or only some of them, and optionally name message headers to copy into each event. The console shows the signing secret once, when you create the endpoint. Keep it where your receiving code can read it.
The address must use https on port 443. Teneo does not follow redirects, so give the final address.
Tags and metadata
A message can carry two headers of your own that come back in every event about that message. X-Tag is a label of your choice, for example invoice. X-Metadata is a JSON object of your own keys and values, for example {"order_id":"4821"}, at most 1000 bytes. Teneo returns both unchanged in data.message.headers of every event, complaints included, and does not read or check the value of X-Metadata. Nothing has to be configured on the endpoint. A message without these headers has no such keys in its events.
The request
Teneo sends a POST with a JSON body. One request carries a batch of events: at most 100 events and at most 256 kB.
The body is the batch envelope:
{
"id": "bat_01JDK8Z7Q4M9A1B2C3D4E5F6G7",
"version": "2026-11-01",
"account": "ACME",
"sent_at": "2026-12-02T16:20:00Z",
"events": [
{ "id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6G8", "type": "message.delivered", "timestamp": "2026-12-02T16:19:41Z", "data": { } }
]
}
| Field | Meaning |
|---|---|
| id | The batch id. Same as the webhook-id header. |
| version | The version of this format, 2026-11-01. A field may be added without a new version. A field is never removed or given another meaning without one, and your endpoint stays on its version until you move it. |
| account | Your Teneo account code. |
| sent_at | When this attempt was made, in UTC. |
| events | The events, 1 to 100 of them, each in the shape below. |
Every event has the same outer shape, whatever its type:
| Field | Meaning |
|---|---|
| id | The event id, evt_ followed by a unique value. Unique for ever. |
| type | What happened, in the form subject.what_happened. See Event types. |
| timestamp | When it happened, in UTC. Not when it was sent. |
| data | The details. Its content depends on the type. |
There is never a subject line or a message body in an event.
Event types
message.delivered
The receiving mail server accepted the message.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6G8",
"type": "message.delivered",
"timestamp": "2026-12-02T16:19:41Z",
"data": {
"message": {
"message_id": "<956486994.5286.1795539476304@app.example.com>",
"from": "billing@example.com",
"to": "anna@example.net",
"relay_account": "acme-app",
"mail_class": "acme-app",
"queued_at": "2026-12-02T16:19:38Z",
"headers": { "X-Order-Id": "4821" }
},
"delivery": {
"sending_ip": "203.0.113.24",
"smtp_response": "250 2.0.0 OK 1795539581 abc123 - gsmtp",
"smtp_code": 250,
"enhanced_code": "2.0.0"
}
}
}
message.bounced
The receiving mail server refused the message for good.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6G9",
"type": "message.bounced",
"timestamp": "2026-12-02T16:19:41Z",
"data": {
"message": {
"message_id": "<956486994.5286.1795539476304@app.example.com>",
"from": "billing@example.com",
"to": "anna@example.net",
"relay_account": "acme-app",
"mail_class": "acme-app",
"queued_at": "2026-12-02T16:19:38Z",
"headers": { "X-Order-Id": "4821" }
},
"delivery": {
"sending_ip": "203.0.113.24",
"smtp_response": "550 5.1.1 <anna@example.net>: Recipient address rejected: User unknown",
"smtp_code": 550,
"enhanced_code": "5.1.1"
},
"bounce": {
"category": "bad-mailbox",
"permanent": true,
"suppress": true
}
}
}
message.expired
Teneo kept trying for the whole retry period and then stopped. The receiving server never accepted the message and never refused it for good. The shape is the same as message.bounced, with bounce.permanent set to false.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6GA",
"type": "message.expired",
"timestamp": "2026-12-02T16:19:41Z",
"data": {
"message": {
"message_id": "<956486994.5287.1795539476305@app.example.com>",
"from": "billing@example.com",
"to": "bob@example.net",
"relay_account": "acme-app",
"mail_class": "acme-app",
"queued_at": "2026-11-30T16:19:38Z",
"headers": { }
},
"delivery": {
"sending_ip": "203.0.113.24",
"smtp_response": "451 4.7.1 Try again later",
"smtp_code": 451,
"enhanced_code": "4.7.1"
},
"bounce": {
"category": "other",
"permanent": false,
"suppress": false
}
}
}
message.complained
A recipient marked the message as spam and the mailbox provider told us through a feedback loop. A complaint carries the message_id, which is how you find the message. It has no recipient address, because the report does not give Teneo one to keep. A complaint also carries X-Tag, X-Metadata and the extra headers you asked for, when the mailbox provider's report includes the headers of the original message. Some providers remove them, so do not rely on them being there. Only headers whose name starts with X- are returned on complaints.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6GB",
"type": "message.complained",
"timestamp": "2026-12-02T15:02:10Z",
"data": {
"message": {
"message_id": "<956486994.5286.1795539476304@app.example.com>",
"headers": { "X-Order-Id": "4821" }
},
"complaint": {
"source": "JMRP",
"feedback_type": "abuse",
"reported_at": "2026-12-02T15:02:10Z",
"recipient_domain": "example.net"
}
}
}
message.dropped
Teneo did not send the message because of a rule you set in Flow Protector, or because the sender domain is not registered for your account. No receiving server was contacted, so it says nothing about the address and it is not a bounce. drop.reason is one of recipient_blocked, recipient_domain_blocked and sender_not_registered.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6GC",
"type": "message.dropped",
"timestamp": "2026-12-02T16:19:41Z",
"data": {
"message": {
"message_id": "<956486994.5288.1795539476306@app.example.com>",
"from": "billing@example.com",
"to": "carol@example.net",
"relay_account": "acme-app",
"mail_class": "acme-app",
"queued_at": "2026-12-02T16:19:38Z",
"headers": { }
},
"drop": {
"reason": "recipient_blocked",
"detail": "Recipient blocked by the ACME Flow Protector list (#5.7.1)"
}
}
}
webhook.test
Sent when you press Send test event on the endpoint. data holds only the endpoint id.
{
"id": "evt_01JDK8Z7Q4M9A1B2C3D4E5F6GD",
"type": "webhook.test",
"timestamp": "2026-12-02T16:20:00Z",
"data": {
"endpoint_id": "we_01JDK8Z7Q4M9A1B2C3D4E5F6GE"
}
}
Field reference
data.message, in every message event:
| Field | Meaning |
|---|---|
| message_id | The Message-ID header of the message, angle brackets included. In a complaint it is the only field of message besides headers. In the other events it can be null when the message had no logged Message-ID. |
| from | The envelope sender (the return path), not the From header. |
| to | The recipient address. |
| relay_account | The name of the relay account the message was sent through. |
| mail_class | The mail class of the message. It has the same value as relay_account. |
| queued_at | When Teneo accepted the message, in UTC. |
| headers | The extra headers you asked this endpoint to copy, plus X-Tag and X-Metadata when the message had them (see Tags and metadata). A header the message did not have is left out. Empty object when there are none. The subject is never included. On a complaint only headers whose name starts with X- can be returned, and only when the provider's report includes them. |
data.delivery, in delivered, bounced and expired events:
| Field | Meaning |
|---|---|
| sending_ip | The dedicated IP address the message left from. |
| smtp_response | The answer of the receiving server, as received (cut at 1000 characters). |
| smtp_code | The three-digit SMTP code in that answer, or null. |
| enhanced_code | The enhanced status code in that answer, for example 5.1.1, or null. |
data.bounce, in bounced and expired events:
| Field | Meaning |
|---|---|
| category | What kind of refusal it was. See the next section. |
| permanent | True for a bounce, false for an expiry. |
| suppress | Teneo's advice: stop sending to this address. See the next section. |
data.drop, in dropped events:
| Field | Meaning |
|---|---|
| reason | recipient_blocked, recipient_domain_blocked or sender_not_registered. |
| detail | The same reason in plain text. |
data.complaint, in complained events:
| Field | Meaning |
|---|---|
| source | The feedback loop the report came from, for example JMRP. |
| feedback_type | The type in the report, for example abuse. |
| reported_at | When the provider reported it, in UTC. |
| recipient_domain | The domain of the recipient, when the report names it. |
Bounce categories and suppress
bounce.category is one of these values. Teneo reads the answer of the receiving server and picks the first category that fits. When none fits the value is other.
| Category | Meaning | suppress |
|---|---|---|
| bad-mailbox | The mailbox does not exist or the address is not valid. | true |
| bad-domain | The recipient domain does not exist or no longer accepts mail. | true |
| inactive-mailbox | The mailbox exists but is disabled, expired or not activated. | true |
| quota-issues | The mailbox is full or over a limit. | false |
| spam-related | The receiver treated the message as spam or the sender as listed or blocked. | false |
| policy-related | The receiver refused the message on a policy. | false |
| content-related | The receiver refused the content of the message. | false |
| virus-related | The receiver refused the message as containing a virus. | false |
| invalid-sender | The receiver could not verify the sender address or domain. | false |
| routing-errors | The receiver or the route to it could not be used. | false |
| relaying-issues | The receiver refused to relay. | false |
| protocol-errors | A mistake in the SMTP conversation. | false |
| bad-configuration | The receiver is set up wrongly. | false |
| no-answer-from-host | The receiving host did not answer. | false |
| bad-connection | The connection to the receiver failed. | false |
| message-expired | The answer says the receiver gave up on the message. | false |
| success | The answer carries a 2.x.x success code. Not expected on a bounce. | false |
| other | No category fits. | false |
suppress is true for bad-mailbox, bad-domain and inactive-mailbox. It is Teneo's advice to stop sending to that address. Every other category says something about the sender, the content or a temporary condition, and not about the address, so it should not put a good address on a suppression list.
Verifying the signature
Using Laravel Rust? The teneo-laravel crate does all of this for you: it verifies each request, turns each event into a typed Laravel event and skips duplicates. It also sends your mail through the relay with MAIL_MAILER=teneo.
Teneo signs every request with the Standard Webhooks scheme, so any Standard Webhooks library can verify it. Give the library the batch headers, the raw body and your secret. If you prefer to write the check yourself, this is all it takes:
- Take the secret shown in the console. It starts with whsec_. The key is the base64-decoded part after that prefix.
- Compute HMAC-SHA256 with that key over <webhook-id>.<webhook-timestamp>.<raw body>, base64 encode it and put v1, in front.
- Use the raw body exactly as received. A body that has been decoded and encoded again may differ by a single character and then the signature does not match.
- The webhook-signature header can hold several signatures separated by spaces. Accept the request when any one of them matches. This happens while a secret is being replaced.
- Compare in constant time.
- Refuse a request whose webhook-timestamp is more than 5 minutes away from your clock.
PHP
<?php
function verify_webhook(string $secret, string $id, string $timestamp, string $body, string $signatureHeader, int $tolerance = 300): bool
{
// Refuse a timestamp more than 5 minutes off.
if (abs(time() - (int) $timestamp) > $tolerance) {
return false;
}
// The key is the base64-decoded part after "whsec_".
$key = base64_decode(substr($secret, strlen('whsec_')), true);
if ($key === false || $key === '') {
return false;
}
$expected = 'v1,' . base64_encode(hash_hmac('sha256', $id . '.' . $timestamp . '.' . $body, $key, true));
// The header can hold several signatures separated by spaces.
foreach (preg_split('/\s+/', trim($signatureHeader)) as $candidate) {
if (hash_equals($expected, $candidate)) {
return true;
}
}
return false;
}
// $ok = verify_webhook(
// $secret,
// $_SERVER['HTTP_WEBHOOK_ID'],
// $_SERVER['HTTP_WEBHOOK_TIMESTAMP'],
// file_get_contents('php://input'), // the raw body, not a decoded copy
// $_SERVER['HTTP_WEBHOOK_SIGNATURE'],
// );
Node.js
const crypto = require('node:crypto');
function verifyWebhook(secret, id, timestamp, rawBody, signatureHeader, tolerance = 300) {
// Refuse a timestamp more than 5 minutes off.
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > tolerance) return false;
// The key is the base64-decoded part after "whsec_".
const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
const expected = Buffer.from(
'v1,' + crypto.createHmac('sha256', key).update(`${id}.${timestamp}.${rawBody}`).digest('base64'),
);
// The header can hold several signatures separated by spaces.
return signatureHeader.trim().split(/\s+/).some((candidate) => {
const given = Buffer.from(candidate);
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
}
module.exports = { verifyWebhook };
// rawBody is the request body exactly as received (a string or Buffer), not re-serialised JSON.
// In Express, use express.raw({ type: 'application/json' }) on this route.
Python
import base64
import hashlib
import hmac
import time
def verify_webhook(secret, webhook_id, timestamp, raw_body, signature_header, tolerance=300):
# Refuse a timestamp more than 5 minutes off.
if abs(time.time() - int(timestamp)) > tolerance:
return False
# The key is the base64-decoded part after "whsec_".
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{webhook_id}.{timestamp}.".encode() + raw_body # raw_body is bytes, as received
expected = "v1," + base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
# The header can hold several signatures separated by spaces.
return any(hmac.compare_digest(expected, candidate) for candidate in signature_header.split())
Rust
// Cargo.toml: hmac = "0.12", sha2 = "0.10", base64 = "0.22"
use base64::{engine::general_purpose::STANDARD, Engine};
use hmac::{Hmac, Mac};
use sha2::Sha256;
pub fn verify_webhook(
secret: &str,
id: &str,
timestamp: &str,
raw_body: &[u8],
signature_header: &str,
now_unix: u64,
tolerance: u64,
) -> bool {
// Refuse a timestamp more than 5 minutes off.
let Ok(ts) = timestamp.parse::<u64>() else { return false };
if now_unix.abs_diff(ts) > tolerance {
return false;
}
// The key is the base64-decoded part after "whsec_".
let Ok(key) = STANDARD.decode(secret.strip_prefix("whsec_").unwrap_or(secret)) else { return false };
let Ok(mut mac) = Hmac::<Sha256>::new_from_slice(&key) else { return false };
mac.update(format!("{id}.{timestamp}.").as_bytes());
mac.update(raw_body);
// The header can hold several signatures separated by spaces.
// verify_slice compares in constant time.
signature_header
.split_whitespace()
.filter_map(|candidate| candidate.strip_prefix("v1,"))
.filter_map(|b64| STANDARD.decode(b64).ok())
.any(|sig| mac.clone().verify_slice(&sig).is_ok())
}
Answering
Answer with any 2xx status within 15 seconds. That means received. Do the heavy work after you have answered, for example by putting the batch on a queue. Anything else counts as a failure and the batch is sent again, with one exception: the answer 410 Gone switches the endpoint off at once.
Retries
A batch that fails is sent again with the same webhook-id and the same body, and a new timestamp and signature. The attempts follow this schedule:
| After failure number | Wait before the next attempt |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 6 hours |
| 6 and further | 12 hours |
A failing endpoint does not hold back the endpoints of other customers. If an endpoint has been failing for 24 hours, Teneo sends you an email. After 5 days of failing, Teneo switches the endpoint off and sends you another email. Events not delivered by then are dropped. A switched-off endpoint collects nothing. After you fix your server, choose Resume in the console.
Duplicates and order
Every event is delivered at least once, so the same event can arrive twice, for example when your answer was lost on the way. Store the event id and ignore an id you have seen. No order is promised between events or between batches. Use timestamp to see which happened first.
Replacing the secret
You can create a new secret for an endpoint in the console. It is shown once. For 24 hours both the old and the new secret are valid: each request carries two signatures, and a receiver that holds either secret accepts it. That gives you time to change your configuration without losing events.
Pausing
You can pause an endpoint in the console, for example during maintenance. While it is paused Teneo keeps collecting its events, up to 5 days, and sends nothing. When you resume, the collected events are sent.
Testing
Press Send test event on the endpoint's page in the console. Teneo sends a signed webhook.test event to your address and shows you the answer it got, so you can check your address, your answer and your signature check before real events arrive.
What Teneo reports and what it does not
Teneo reports what its own servers see: what the receiving mail server answered, what Teneo did not send because of your rules, and the complaints that mailbox providers send back.
- Bounces that arrive later by mail. Sometimes a receiving server accepts a message and sends a bounce back afterwards. That bounce goes to your own return address and not through Teneo, so it is not an event here. Your own mailbox or system sees it.
- Complaints. You get a complaint event from the providers that run a feedback loop and send reports to Teneo. A provider without such a loop, or one that sends its reports to the sender's own address, does not produce an event.
- Opens and clicks. Teneo does not track them, so there are no events for them.
Questions? Open a ticket on the Support page of the console; an engineer answers.