WooCommerce Transactional Email API (2026): Notify a Customer That Their Refund Was Issued with POST /emails
Send a “your refund was issued — here is the refund / order permalink you already have” notice from a WooCommerce refund hook or queue job with Rovela’s HTTP API: a Bearer key from the process environment, wp_remote_post (or cURL) to POST /emails, and an Idempotency-Key. No official WooCommerce plugin from Rovela. Distinct from the WordPress transactional email primer and from order-canceled, invoice-ready, invoice-overdue, payment-method-updated, and this batch’s subscription-renewed guides.
A refund-issued notice is not an order-canceled, invoice, or generic WordPress mail primer
When a customer refund has already been issued in your WooCommerce store — a returned sweater the warehouse already booked in, a damaged item you already credited, a partial refund the merchant already recorded on that order — that refund hook or queue job still has to tell the customer: “Your refund was issued,” plus the refund / order 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 order canceled, shipment delayed, back in stock, invoice ready, invoice overdue, payment method updated, credit card expiring, Shopware B2B buyer-account-approved, or Shopify order webhook guides. Those tutorials already exist, and they describe cancellations, logistics, invoices, payment methods, or other storefronts. This article is one event in your own WooCommerce store: a refund has already been issued on an order the customer already has. It is also not a generic rewrite of the WordPress transactional email primer — that guide covers sending from WordPress in general; this one is specifically a WooCommerce refund-issued notice. It is distinct from this batch’s subscription renewed guide, which is a billing renewal that succeeded, not a refund that was issued. The recipient is the customer (the address you already store on that order). The call to action is “open this refund and order,” not “your order was canceled,” not “an invoice is ready,” and not “your subscription renewed.”
There is no official WooCommerce plugin from Rovela and no client library to install. Hook a WooCommerce refund action (for example woocommerce_order_refunded) or an Action Scheduler job, then call POST /emails with the WordPress HTTP API (wp_remote_post) or cURL. Do not invent a marketplace plugin. The JSON body and headers are the product. The hook or job that already recorded the refund should send the notice; Rovela does not issue refunds and does not run your store.
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 a WooCommerce refund job belongs on POST /emails, which is also the distinction drawn in Email API vs SMTP relay.
What you need before the first refund-issued notice
The first-email guide and the Quick Start are the same five steps, whether the caller is curl or wp_remote_post inside a WooCommerce job:
- 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, the Domains API, and what domain email is. - Create an API key. A
sending_accesskey can send and nothing else — the right default for a production refund 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 "Orders <orders@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 and the sending domains API overview.
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 customer first sees the refund / order permalink (HTML email API).
A WooCommerce hook or job that sends after the refund is already issued
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 WooCommerce refund hook or Action Scheduler job that already recorded the refund should read ROVELA_API_KEY from the process environment (or from a guarded wp-config constant that is not echoed into the storefront) and call Rovela only on the server (email API authentication). When a merchant issues a refund in wp-admin, or when your own refund workflow writes a WC_Order_Refund, persist that refund against the order first (refund id, permalink already minted), then enqueue the notice. Do not call the Email API from a storefront page, do not replace WooCommerce’s built-in mailer with a browser fetch, and do not invent a Rovela WooCommerce marketplace plugin — none exists.
Store the event first: the refund id and order id you already have, a short order number you already show on the customer account page, the customer’s address, and the refund / order permalink. The send is just the notice. The recipient is consistently the customer on that order — not the store admin, not a marketing segment, and not every previous buyer. If a shared support inbox also needs a copy, add that address deliberately. Key the Idempotency-Key to that issued-refund event so a retried job does not mail the same “your refund was issued” notice twice. A later refund on a different order (or a second refund on the same order) is a different event and should be a different key. If an order is later canceled without a refund, that is the order-canceled guide, not this one.
<?php
// wp-content/plugins/your-store-refunds/includes/class-rovela-client.php
// WooCommerce helper. wp_remote_post. No official Rovela WooCommerce plugin.
defined('ABSPATH') || exit;
final class Rovela_Client {
private const API = 'https://api.rovela.dev';
public static function send_email(
string $to,
string $subject,
string $html,
string $text,
string $idempotency_key,
?string $reply_to = null,
?array $tags = null
): string {
$api_key = self::env('ROVELA_API_KEY');
$body = array(
'from' => self::env('ROVELA_FROM'),
'to' => $to,
'subject' => $subject,
'html' => $html,
'text' => $text,
);
if ($reply_to) {
$body['reply_to'] = $reply_to;
}
if ($tags !== null) {
$body['tags'] = $tags;
}
$response = wp_remote_post(self::API . '/emails', array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json',
'Idempotency-Key' => $idempotency_key,
),
'body' => wp_json_encode($body),
'timeout' => 20,
));
if (is_wp_error($response)) {
throw new RuntimeException($response->get_error_message());
}
$code = wp_remote_retrieve_response_code($response);
$payload = json_decode(wp_remote_retrieve_body($response), true) ?: array();
if ($code < 200 || $code >= 300) {
$message = $payload['message'] ?? ('rovela ' . $code);
throw new RuntimeException($message);
}
return (string) ($payload['id'] ?? '');
}
public static function notify_refund_issued(
string $customer_email,
string $order_number,
string $refund_permalink,
string $refund_id
): string {
$safe_number = esc_html($order_number);
$safe_permalink = esc_url($refund_permalink);
$subject = "Your refund was issued for order {$order_number}";
$text = "A refund was issued for order {$order_number}.\n\nOpen the refund and order: {$refund_permalink}";
$html = "<p>A refund was issued for order {$safe_number}.</p>"
. "<p><a href=\"{$safe_permalink}\">Open the refund and order</a></p>";
$reply_to = getenv('ROVELA_REPLY_TO') ?: null;
return self::send_email(
$customer_email,
$subject,
$html,
$text,
'refund-issued-' . $refund_id,
$reply_to,
array('type' => 'refund_issued')
);
}
private static function env(string $name): string {
$value = getenv($name);
if ($value === false || $value === '') {
throw new RuntimeException("missing {$name}");
}
return $value;
}
}
// Hook the official WooCommerce refund action, then enqueue — do not block wp-admin on the HTTP call.
add_action('woocommerce_order_refunded', function ($order_id, $refund_id) {
as_enqueue_async_action('rovela_notify_refund_issued', array(
'order_id' => (int) $order_id,
'refund_id' => (int) $refund_id,
));
}, 10, 2);
add_action('rovela_notify_refund_issued', function ($order_id, $refund_id) {
$order = wc_get_order($order_id);
$refund = wc_get_order($refund_id);
if (!$order || !$refund) {
return;
}
$permalink = $order->get_view_order_url();
Rovela_Client::notify_refund_issued(
$order->get_billing_email(),
$order->get_order_number(),
$permalink,
(string) $refund_id
);
}, 10, 2);
The snippet uses WooCommerce’s Action Scheduler (as_enqueue_async_action) so the woocommerce_order_refunded hook records the refund and enqueues work, and a later job performs the HTTP call. That is a queue job on top of a refund action, not a marketplace plugin and not a browser request. If you are not running Action Scheduler, any server-side queue you already operate can do the same work.
Call notify_refund_issued only after the refund row and the order permalink already exist. Keep the HTTP call out of the storefront request that merely asks for a return; the customer should be mailed when the refund has actually been issued, not when they first click “request a return.” The email is a status notice, not a place to paste card numbers, a raw gateway response, or a full line-item ledger the customer can already open on the order page. If a later refund adjustment issues a second credit on the same order, that is a different event and should use a different idempotency key — do not reuse the first refund’s key.
The same JSON can be sent with curl, which is useful in a staging shell while you confirm the verified from and the permalink:
curl -X POST https://api.rovela.dev/emails \
-H "Authorization: Bearer $ROVELA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: refund-issued-ref_01H8Q2" \
-d '{
"from": "Orders <orders@yourdomain.com>",
"to": "customer@example.com",
"subject": "Your refund was issued for order 1842",
"html": "<p>A refund was issued for order 1842.</p><p><a href=\"https://shop.example.com/my-account/view-order/1842\">Open the refund and order</a></p>",
"text": "A refund was issued for order 1842.\n\nOpen the refund and order: https://shop.example.com/my-account/view-order/1842",
"reply_to": "support@yourdomain.com",
"tags": {"type": "refund_issued"}
}'
reply_to is documented and optional; use it when replies should reach a support inbox rather than the sending address (reply-to). tags may be an object or an array of arbitrary labels — they are yours to choose, and they help you filter later in the dashboard or in webhooks (email API tags). headers and topic_id are also documented fields; this tutorial does not treat topic_id as a product tour. Attachments, if you ever add a short refund-summary PDF, use { filename, content (base64), content_type }. Do not attach payment-gateway logs, card data, or a full internal credit memo. The permalink is the call to action (email attachments).
If you ever need to notify many independently issued refunds in one go (an operations catch-up, not the usual single-refund 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 customer can open the refund / order permalink even in a text-only client. If you later switch a stable notice to a stored template, drop html and text and follow the Templates API, the templates guide, and the email templates API guide.
Idempotency, recipients, and what a 200 actually means
WooCommerce hooks and Action Scheduler jobs retry, and a “the refund was issued, notify the customer” path can run more than once for the same record. 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 it to the refund id (or to a specific issued-refund event id you already store), not to the clock and not to the customer’s email alone. If the same customer later has a different refund issued, that is a second notice and a second key.
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 refund-issued notice addresses the customer on that order. If a shared support mailbox also has to be told, add that address deliberately and accept that it counts as a second recipient. Do not cc every store admin by default.
HTTP 200 from POST /emails means the message was accepted and queued. It is not a delivery receipt. The JSON is {"object":"email","id":"..."}. Persist that id next to the refund if you want to look the message up later from a dashboard session. Do not block the WooCommerce job until a mailbox provider confirms delivery.
scheduled_at is a documented ISO 8601 future timestamp if you ever need to hold a notice. For a refund that is already issued, send immediately after the refund record is written. If you did schedule a message and the customer should not receive it, POST /emails/:id/cancel cancels an unsent message. Reading, cancelling, and any rescheduling need full_access or a dashboard session. This article does not invent a reschedule request body.
Errors you should handle in the WooCommerce job
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, malformed, or revoked Bearer key. Check the process environment, not the refund row.
- 429 — you are being rate limited. Back off and retry with the same
Idempotency-Keyso a later attempt cannot send a second notice for the same refund (rate limits, retries).
Treat unknown 5xx responses as retryable with the same key. Log name and message next to the refund id; do not log the Bearer key. A practical walk-through is the email API error handling guide.
Delivery is asynchronous — do not poll from the job
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 WooCommerce job. 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 refund-issued notice
- Do not put the Rovela key in a browser client, a public repository, or a container image.
- Do not invent an official WooCommerce plugin or a Rovela payments product. Your job already recorded that the refund was issued; Rovela delivers the mail. There is no official client library. Rovela does not issue the refund.
- Do not send this as an “order canceled,” “invoice ready,” “payment method updated,” or “subscription renewed” template borrowed from another tutorial, and do not treat it as a generic WordPress mail primer. The permalink is a refund and order, and the recipient is the customer.
- Do not include card numbers, gateway logs, or a dump of the credit memo in the email body. The notice carries a short order number and the permalink.
- Do not send from mailbox SMTP for this. SMTP is for mail apps and mailboxes. A WooCommerce refund job 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 refund-issued notice.
- Do not poll
GET /emails/:idwith asending_accesskey, and do not invent a reschedule body if you later cancel an unsent message.
A compact refund-issued checklist
- Verify the sending domain and create a
sending_accesskey (Quick Start). - Put
ROVELA_API_KEYandROVELA_FROMin the WooCommerce job’s process environment, not in the browser. - Record the issued refund first: customer address, order number, and the refund / order permalink.
- Hook
woocommerce_order_refunded(or your own refund workflow), enqueue a job, and callPOST /emailswithwp_remote_post(or cURL), bothhtmlandtext, areply_toif you want replies in a support inbox, and anIdempotency-Keyscoped to that refund id. - Treat HTTP 200 as accepted, not delivered. Persist the returned message id if you need it later.
- Confirm delivery with a signed webhook or from the dashboard.
- 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.