Axum Transactional Email API (2026): Notify That a Webhook Delivery Failed with POST /emails
Send a “a customer webhook endpoint failed after retries, here is the delivery-attempt permalink you already have” notice from a Rust Axum worker with Rovela’s HTTP API: a Bearer key from the process environment, plain reqwest to POST /emails, and an Idempotency-Key. Not an OTP tutorial and not a Chi job-failed rewrite.
A webhook-delivery-failed notice is not an Axum OTP mail, a Chi job-failed alert, or a Rocket form receipt
When a customer’s webhook endpoint in your product has already failed after the retries you own — an orders topic that kept returning 502, a billing endpoint that timed out five times, a signature your customer never rotated — your Axum worker still has to tell the integration owner: “This webhook delivery failed after retries,” plus the delivery-attempt permalink you already have. That send is transactional email. It is not a newsletter, not a marketing drip, and it is not a rewrite of the Axum OTP email, Rust transactional email, sending email in Rust, Actix transactional email, Rocket.rs transactional email, or Chi transactional email guides. Those tutorials already exist. The Axum OTP article is a signup or login verification-code walkthrough; this article is not an OTP, password-reset, or welcome-email rewrite. The Rust language tours show a generic HTTP client against POST /emails. Actix announces that a backup finished and points at a backup permalink. Rocket confirms that a form submission was received and points at a request permalink. Chi tells an on-call operator that an internal background job failed and points at the job-run permalink. This guide is a Rust Axum worker — a Tokio task your handler already started, or a route that runs after you already recorded the failed attempt — and the recipient is the integration owner whose endpoint failed. The call to action is “open this delivery attempt and fix your endpoint,” not “enter this code,” not “your backup is ready,” and not “open the failed internal run.”
This guide does not invent an official Axum crate, a marketplace plugin, or a Rovela Rust SDK. There is no client library to install. Use a plain HTTP client such as reqwest, plus curl when you want to prove the JSON. Triggers are described generically: your worker runs after you have already recorded that an outbound webhook delivery failed. This article does not invent field names on the customer’s endpoint or on your delivery log. The JSON body and headers are the product. Rovela does not deliver your product’s webhooks for you and does not retry the customer’s URL.
Rovela’s Email API is a single HTTPS call. The base URL is https://api.rovela.dev. You authenticate with Authorization: Bearer re_… (Authentication) and queue a message with POST /emails. The response is {"object":"email","id":"..."}. HTTP 200 means the message was accepted and queued, not that it has already arrived (Quick Start).
If you are still choosing between HTTP and SMTP, read Email API vs SMTP. Rovela’s SMTP is mailbox SMTP for mail apps (mx.rovela.dev:465, a device credential, send-as-self, 30 messages a minute from one client address). Programmatic volume from an Axum worker belongs on POST /emails, which is also the distinction drawn in Email API vs SMTP relay. Prefer the HTTP API over driving mailbox SMTP through lettre for this notice; the Rust sending tour covers that contrast in more depth.
What you need before the first delivery-failed notice
The first-email guide and the Quick Start are the same five steps, whether the caller is curl or reqwest inside your worker:
- Create an account. You start on the free plan, which sends real mail. There is no separate sandbox, and no test key that behaves differently from production.
- Add and verify a sending domain (a subdomain such as
mail.example.comis a common choice). You cannot send from a domain you have not verified; an unverified or foreignfromis refused with a 400 that names the domain. The dashboard asks for four DNS records — SPF, DKIM, DMARC, and return-path. See the domain setup guide and what domain email is. - Create an API key. A
sending_accesskey can send and nothing else — the right default for a production delivery-failed notifier. Afull_accesskey can also read messages and events, and manage domains, templates, and webhooks. The full key is shown once. - Send with
POST /emails. - Confirm delivery in the dashboard, with
GET /emails/:idorGET /emails/:id/events(those reads needfull_accessor a dashboard session), or with a webhook.
from is a string in the documented form "Integrations <integrations@yourdomain.com>". The address must sit on a verified sending domain. That is the same rule that makes domain email trustworthy: you prove you control the domain before you speak as it. How the display name and the address work is covered in the From name guide.
At least one of html, text, or template is required. Send both html and text where you can — many clients preview the text part, which is often where the integration owner first sees the delivery-attempt permalink (HTML email API).
An Axum worker that sends after the failed attempt is already stored
Keep the Rovela key out of the browser, out of a public repository, and out of a container image. A leaked sending_access key can send mail as your domain. The Tokio worker that already recorded the failed attempt should read ROVELA_API_KEY from its process environment and call Rovela only on the server (email API authentication). Your product already tried the customer’s URL, already applied your retry policy, and already wrote a delivery-attempt row. Only then do you send. This article does not invent the shape of that row.
Store the event first: the delivery-attempt id you already have, the integration owner’s address (the address you already store on the webhook subscription), a short topic or endpoint label you already store if you show one, and the delivery-attempt permalink. The send is just the notice. The recipient is consistently the integration owner who should inspect the failed attempt and fix their endpoint — not your on-call rotation, and not an end user waiting on an OTP. Key the Idempotency-Key to that attempt so a retried worker does not mail the same “this delivery failed” notice twice. A later, separate attempt against the same subscription is a different event and should be a different key.
// rovela.rs — Axum-compatible helper, reqwest, no official SDK
use reqwest::header::{AUTHORIZATION, CONTENT_TYPE, HeaderMap, HeaderValue};
use serde_json::{json, Value};
use std::env;
const API: &str = "https://api.rovela.dev";
fn require_env(name: &str) -> Result<String, String> {
env::var(name).map_err(|_| format!("missing {name}"))
}
pub async fn send_email(
to: &str,
subject: &str,
html: &str,
text: &str,
reply_to: Option<&str>,
tags: Value,
idempotency_key: &str,
) -> Result<String, String> {
let api_key = require_env("ROVELA_API_KEY")?;
let from = require_env("ROVELA_FROM")?;
let mut body = json!({
"from": from,
"to": to,
"subject": subject,
"html": html,
"text": text,
"tags": tags,
});
if let Some(reply) = reply_to {
body["reply_to"] = json!(reply);
}
let mut headers = HeaderMap::new();
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {api_key}")).map_err(|e| e.to_string())?,
);
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
headers.insert(
"Idempotency-Key",
HeaderValue::from_str(idempotency_key).map_err(|e| e.to_string())?,
);
let client = reqwest::Client::new();
let res = client
.post(format!("{API}/emails"))
.headers(headers)
.json(&body)
.send()
.await
.map_err(|e| e.to_string())?;
let status = res.status();
let payload: Value = res.json().await.unwrap_or_else(|_| json!({}));
if !status.is_success() {
let message = payload
.get("message")
.and_then(|v| v.as_str())
.unwrap_or("rovela error");
return Err(format!("{}: {message}", status.as_u16()));
}
payload
.get("id")
.and_then(|v| v.as_str())
.map(|s| s.to_string())
.ok_or_else(|| "missing id".to_string())
}
pub async fn notify_webhook_delivery_failed(
owner_email: &str,
topic_label: &str,
attempt_permalink: &str,
attempt_id: &str,
) -> Result<String, String> {
let subject = format!("Webhook delivery failed: {topic_label}");
let text = format!(
"A webhook delivery for “{topic_label}” failed after retries.\n\nOpen the delivery attempt: {attempt_permalink}"
);
let html = format!(
"<p>A webhook delivery for “{topic_label}” failed after retries.</p>\
<p><a href=\"{attempt_permalink}\">Open the delivery attempt and inspect the failure</a></p>"
);
let reply = env::var("ROVELA_REPLY_TO").ok();
send_email(
owner_email,
&subject,
&html,
&text,
reply.as_deref(),
json!({"type": "webhook_delivery_failed"}),
&format!("axum-webhook-delivery-failed-{attempt_id}"),
)
.await
}
reply_to is optional and documented (email API reply-to). A delivery-failed notice can point replies at an integrations mailbox you already staff, so questions about the attempt do not land on a no-reply address. tags can be an object or an array of labels; they are yours to attach and later filter (email API tags). The helper above uses { type: "webhook_delivery_failed" }.
The same JSON works from curl, which is useful when you are wiring the worker and want to prove the payload before Tokio is in the loop:
curl -X POST https://api.rovela.dev/emails \
-H "Authorization: Bearer $ROVELA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: axum-webhook-delivery-failed-att_01JK9P" \
-d '{
"from": "Integrations <integrations@yourdomain.com>",
"to": "owner@example.com",
"subject": "Webhook delivery failed: orders.updated",
"html": "<p>A webhook delivery for “orders.updated” failed after retries.</p><p><a href=\"https://app.example.com/webhooks/attempts/att_01JK9P\">Open the delivery attempt and inspect the failure</a></p>",
"text": "A webhook delivery for “orders.updated” failed after retries.\n\nOpen the delivery attempt: https://app.example.com/webhooks/attempts/att_01JK9P",
"reply_to": "integrations@yourdomain.com",
"tags": {"type": "webhook_delivery_failed"}
}'
The from address must already be on the verified domain. The permalink in the body is yours — a URL you already mint for that delivery attempt in your own app. Rovela does not invent, store, or retry the customer’s webhook. Your product owns the delivery log; this mail only carries the permalink.
Call the helper from a background task after the attempt row is committed, not from a request extractor that still holds the customer’s outbound HTTP connection. An Axum route can enqueue the work; the send itself should be a plain reqwest call with the documented JSON.
Idempotency, recipients, and what a 200 actually means
Workers retry, and a “give up and notify the owner” path can run more than once for the same attempt. Send an Idempotency-Key header (up to 256 characters). A retry of the same request within 24 hours returns the original response instead of sending again (idempotency). Key the header to the delivery-attempt id (axum-webhook-delivery-failed-<attemptId>), not to the subscription id or the owner’s email alone — the same subscription can fail again later, and that is a different notice.
A message may address at most 50 recipients across to, cc, and bcc combined. That is the transport’s limit, not a plan limit, and it is checked before the request is accepted. Quota is charged per recipient, not per message — cc and bcc count the same as to. A delivery-failed notice almost always has one to (the integration owner who should open the attempt). Do not cc your on-call mailbox by default unless you intend that mailbox to count against quota and to receive a copy of every customer-endpoint failure. Staff-wide pages belong in your incident tool; this mail is for the owner of the endpoint.
If you ever need to notify many independent failed attempts in one go (a rare catch-up, not the usual path), POST /emails/batch accepts up to 100 messages, each with the same schema. Two fields are rejected rather than ignored: template and topic_id. Send those through POST /emails. See the batch example and the batch transactional email guide. Each item should still carry its own business key if you send them as individual POST /emails calls; if you use the batch endpoint, keep the rest of the payload identical to a single send, without template or topic_id.
template is documented as { id, variables } and is mutually exclusive with html and text. This tutorial sends both html and text so the delivery-attempt permalink is visible in the notification preview. If you later switch to a stored template, use POST /emails (not batch), follow the Templates API and the templates guide, and still pass only the attempt id and the permalink as variables.
You can also set scheduled_at to an ISO 8601 future timestamp, but a delivery-failed notice is usually sent immediately after you record that retries are exhausted — the owner is waiting to repair the endpoint. If you do schedule one and then a later retry (in your product) succeeds before the mail goes out, POST /emails/:id/cancel can cancel a message that has not been sent yet. Reading, rescheduling, and cancelling need full_access or a dashboard session. This guide does not invent a reschedule request body.
Errors you should handle in the Axum worker
Documented send errors use an envelope of { statusCode, name, message }:
- 400 — a missing required field, a
fromdomain that does not belong to your organization, atemplatethat does not exist, or more than 50 recipients on one message. Fix the payload; retrying the same body will fail the same way. - 401 — a missing or invalid credential, or a
sending_accesskey used to read, reschedule, or cancel a message. Check the secret the process is actually reading. - 429 — rate limit exceeded. Each message in a batch counts individually. Back off and retry with the same
Idempotency-Key(email API retries, rate limits).
Map 400 and 401 to a non-retryable failure, and 429 to a retry with the same key, so a typo in from does not spin the queue. Broader patterns are in Email API error handling. Domain management endpoints such as GET /domains return 403 for a sending_access key — that is expected; leave domain work to the dashboard or a full_access key (Domains API, sending domains API).
Do not conflate this send with an Axum OTP mail, a Chi job-failed alert, an Actix backup-finished notice, or a Rocket form-received receipt. Those articles cover a verification code, an internal run, a finished backup, or an inbound form. This article covers an Axum worker after a customer webhook endpoint failed, and the call to action is “open this delivery attempt.”
Rovela’s own webhook overview and webhook security pages describe inbound delivery events for mail you sent through Rovela. That is a different webhook from the customer endpoint in your product. Do not mix the two. Use Rovela webhooks to learn whether this notice was accepted, delivered, bounced, or failed; use your own delivery log for the customer’s URL.
Delivery is asynchronous — do not poll from the worker
A 200 from POST /emails means accepted for delivery, not delivered. Reading GET /emails/:id or GET /emails/:id/events needs a full_access key or a dashboard session; a sending_access key cannot do it, and you should not add a polling loop inside the Axum worker. Subscribe to a webhook instead, and verify the signature header x-resend-signature as documented in webhook security and signature verification. Event names include accepted, delivered, opened, clicked, bounced, or failed. For a single message you can also use the email delivery status API or the dashboard from a support session.
What not to do in this delivery-failed notice
- Do not put the Rovela key in a browser client, a public repository, or a container image.
- Do not invent an official Axum crate or a Rovela Rust SDK. Your worker already recorded the failed attempt; Rovela delivers the mail. There is no official client library.
- Do not turn this into an Axum OTP, password-reset, or welcome-email tutorial. Those are different messages and a different security design.
- Do not reuse a Chi job-failed story. Chi tells an operator to open an internal run. This article tells an integration owner to open a delivery attempt against their endpoint.
- Do not turn this into an Actix backup-finished or Rocket form-received walkthrough, and do not collapse it into the language-level Rust transactional email or send email in Rust tours.
- Do not send from mailbox SMTP for this. SMTP is for mail apps and mailboxes. An Axum worker should use the HTTP API. Inbound mail into a hosted mailbox is a different path, described in the webmail manual; this guide is an outbound integration notice.
- Do not skip domain verification. An unverified
fromis refused. If you send on behalf of several brands or tenants, a key restricted to a single domain limits the blast radius of a leak (Email API for multi-tenant SaaS). - Do not ask Rovela to retry the customer’s webhook URL. Your product owns that delivery. This mail only carries the permalink you already minted.
A compact delivery-failed checklist
- Verify the sending domain and create a
sending_accesskey (Quick Start). - Put
ROVELA_API_KEYandROVELA_FROMin the Axum worker’s process environment, not in the browser. - After your worker has already recorded that a webhook delivery failed and stored the attempt permalink,
POST https://api.rovela.dev/emailswithreqwest(or the same JSON from curl). - Send both
htmlandtext, include the delivery-attempt permalink, and setIdempotency-Keytoaxum-webhook-delivery-failed-<attemptId>. - Optionally set
reply_toandtagssuch astype=webhook_delivery_failed. - Handle 400, 401, and 429 from the error envelope. Confirm delivery with a webhook, not by polling inside the worker.
- If you are comparing providers, the existing pages are Rovela vs Mailgun, vs Amazon SES, vs Postmark, vs SendGrid, vs Resend, and vs Brevo. For the HTTP shape itself, see the transactional email API, the curl sending guide, and the HTTP email API overview. For other notification patterns, see the email notification API guide.