← Back to blog

Micronaut Transactional Email API (2026): Notify That a Report Is Ready from a Service with POST /emails

Send a “your report finished generating” notice from a Java Micronaut service with Rovela’s HTTP API: HttpClient or a declarative @Client, environment properties for the Bearer key, a download URL in html plus text, and Idempotency-Key. Clearly Micronaut — not a rewrite of the Spring Boot tour or the Quarkus OTP guide.

Updated November 10, 2026
Micronaut Transactional Email API (2026): Notify That a Report Is Ready from a Service with POST /emails

A report-ready notice belongs in a Micronaut service, not in a Spring Boot or Quarkus rewrite

When a long-running job finishes a report — a CSV export, a weekly metrics pack, a compliance PDF — the person who asked for it needs a message that the file is ready: “Your report finished generating,” plus a download URL. That send is transactional email. It is not a marketing blast, not an OTP, and it is not a rewrite of the Spring Boot transactional tour, the Spring Boot OTP guide, the Quarkus OTP guide, the Java language tour, or the Ktor article. Those tutorials already exist. This one is a Java Micronaut service that already produced the file, then uses Micronaut’s HTTP client to call POST /emails.

Rovela’s Email API is a single HTTPS call for that work. There is no client library to install and no official Micronaut SDK in this guide. 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 a message 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 Micronaut worker belongs on POST /emails, which is also the distinction drawn in Email API vs SMTP relay.

A Micronaut service marks a report ready, then an HTTP client posts JSON to the email API and receives a message id

What you need before the first Micronaut send

The first-email guide and the Quick Start are the same five steps, whether your caller is a Micronaut service or curl:

  1. Create an account. You start on the free plan, which sends real mail. There is no separate sandbox or test key.
  2. Add and verify a sending domain (a subdomain such as mail.example.com is a common choice). You cannot send from a domain you have not verified; an unverified or foreign from is 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.
  3. Create an API key. A sending_access key can send and nothing else — the right default for a production worker. A full_access key can also read messages and events, and manage domains, templates, and webhooks. The full key is shown once.
  4. Send with POST /emails.
  5. Confirm delivery in the dashboard, with GET /emails/:id or GET /emails/:id/events (those reads need full_access or a dashboard session), or with a webhook.

from is a string in the documented form "Reports <reports@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 a person first sees the download URL (HTML email API).

A Micronaut HTTP client and environment properties

Keep the key in environment variables or a secret store, then bind it with Micronaut configuration. Never put it in a browser, a mobile app, or a public repository. A leaked sending_access key can send mail as your domain.

# application.yml (override with env in production)
rovela:
  api-key: ${ROVELA_API_KEY}
  from: ${ROVELA_FROM:`Reports <reports@mail.example.com>`}
  reply-to: ${ROVELA_REPLY:}

A declarative client against the documented base URL is enough. This is Micronaut’s HTTP client, not an official Rovela SDK:

// RovelaEmailClient.java
package example.email;

import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Header;
import io.micronaut.http.annotation.Post;
import io.micronaut.http.client.annotation.Client;
import java.util.Map;

@Client("https://api.rovela.dev")
public interface RovelaEmailClient {
    @Post("/emails")
    Map<String, Object> send(
        @Header("Authorization") String authorization,
        @Header("Idempotency-Key") String idempotencyKey,
        @Body Map<String, Object> body
    );
}
// ReportEmailService.java
package example.email;

import io.micronaut.context.annotation.Property;
import jakarta.inject.Singleton;
import java.util.HashMap;
import java.util.Map;

@Singleton
public class ReportEmailService {
    private final RovelaEmailClient client;
    private final String apiKey;
    private final String from;
    private final String replyTo;

    public ReportEmailService(
        RovelaEmailClient client,
        @Property(name = "rovela.api-key") String apiKey,
        @Property(name = "rovela.from") String from,
        @Property(name = "rovela.reply-to") String replyTo
    ) {
        this.client = client;
        this.apiKey = apiKey;
        this.from = from;
        this.replyTo = replyTo;
    }

    public String notifyReportReady(String to, String reportId, String downloadUrl) {
        Map<String, Object> body = new HashMap<>();
        body.put("from", from);
        body.put("to", to);
        body.put("subject", "Your report finished generating");
        body.put("html", "<p>Your report finished generating.</p><p><a href=\"" + downloadUrl + "\">Download the report</a></p>");
        body.put("text", "Your report finished generating. Download it: " + downloadUrl);
        if (replyTo != null && !replyTo.isBlank()) {
            body.put("reply_to", replyTo);
        }
        body.put("tags", Map.of("type", "report_ready", "report_id", reportId));

        Map<String, Object> result = client.send(
            "Bearer " + apiKey,
            "report-ready-" + reportId,
            body
        );
        Object id = result.get("id");
        return id == null ? null : id.toString();
    }
}

Call notifyReportReady from the worker or listener that already stored the file — not from a controller that still has the job in flight. The same JSON is a short curl for a runbook:

curl -X POST https://api.rovela.dev/emails \
  -H "Authorization: Bearer re_your_sending_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: report-ready-rep_01J8K2" \
  -d '{
    "from": "Reports <reports@mail.example.com>",
    "to": "ada@example.com",
    "subject": "Your report finished generating",
    "html": "<p>Your report finished generating.</p><p><a href=\"https://app.example.com/reports/rep_01J8K2/download\">Download the report</a></p>",
    "text": "Your report finished generating. Download it: https://app.example.com/reports/rep_01J8K2/download",
    "reply_to": "data@mail.example.com",
    "tags": {"type": "report_ready", "report_id": "rep_01J8K2"}
  }'

A successful body is {"object": "email", "id": "9f1c2e40-..."}. Store that id next to the report row if you want a support trail; do not treat it as proof of delivery.

tags are documented as arbitrary labels and come back with the message (email API tags). reply_to is optional; use it when questions about the file should reach a data mailbox (email API reply-to). If you prefer an imperative HttpClient instead of a declarative @Client, the URL, headers, and JSON are identical — still POST https://api.rovela.dev/emails, still Authorization: Bearer re_….

Handle HTTP errors from the client the way Micronaut already surfaces them. The API’s error envelope is { statusCode, name, message }; map those fields out of a 4xx/429 body rather than inventing a custom error schema.

Idempotency, recipients, and what a 200 actually means

Report jobs can be retried, and a worker that crashed after the file was written may run again. Send an Idempotency-Key header (up to 256 characters) keyed to the report id. A retry of the same request within 24 hours returns the original response instead of sending again (idempotency).

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. A report-ready notice almost always has one to; if you also notify a watching manager, they count.

If you ever need to notify many independent report owners in one go, 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. You do not need a batch for a single report.

template is documented as { id, variables } and is mutually exclusive with html and text. This tutorial sends both html and text so the download URL is visible in the notification preview. If you later switch to a stored template, use POST /emails (not batch) and follow the Templates API and the templates guide. Attachments are also documented (filename, base64 content, content_type); this guide keeps the file behind a signed download URL rather than attaching a large report in the send itself.

Errors you should handle in the service

Documented send errors use an envelope of { statusCode, name, message }:

  • 400 — a missing required field, a from domain that does not belong to your organization, a template that 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_access key used to read, reschedule, or cancel a message. Check the environment property the service actually bound.
  • 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).

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).

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 block the report worker on a polling loop. 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.

POST /emails/:id/cancel can cancel a message that has not been sent yet, which is relevant if you used scheduled_at (an ISO 8601 timestamp in the future). Reading, rescheduling, and cancelling need full_access or a dashboard session. A request body for rescheduling is not documented here, so this guide does not invent one. Everyday report-ready notices should send immediately.

A Spring Boot tour or a Quarkus OTP handler is a different tutorial; a Micronaut service posts a report-ready notice with POST /emails

What not to do in a Micronaut codebase

  • Do not copy the Spring Boot or Quarkus articles and swap the framework name. The client and configuration shown here are Micronaut’s, and the story is a report that finished generating.
  • Do not invent an official Rovela Micronaut SDK or a starter module this guide has not documented.
  • Do not put the API key in client-side code or in a public repository (email API authentication).
  • Do not send from mailbox SMTP for this. SMTP is for mail apps and mailboxes. A worker should use the HTTP API.
  • Do not skip domain verification. An unverified from is refused. If you send on behalf of several tenants, a key restricted to a single domain limits the blast radius of a leak (Email API for multi-tenant SaaS).

The client interface above posts one JSON object and reads back the message id. That is enough for a report worker. It does not wrap Rovela in an invented Java SDK, and it does not try to list domains or poll events with a sending_access key. If a later job needs to notify a group of report owners, keep using one message per person rather than stuffing many addresses into cc or bcc just to save a request: billing is per recipient, and a bounced address in a shared recipient list is harder to interpret than a single tagged send. Prefer a short-lived download URL in the body over attaching a large file unless you have already decided an attachment is the right shape and you stay inside the documented { filename, content, content_type } fields.

A compact Micronaut checklist

  1. Verify the sending domain and create a sending_access key (Quick Start).
  2. Bind ROVELA_API_KEY and ROVELA_FROM as Micronaut properties, not as hardcoded strings.
  3. After the report file is stored, call POST https://api.rovela.dev/emails with HttpClient or a declarative @Client.
  4. Send both html and text, include the download URL, and set Idempotency-Key to report-ready-<id>.
  5. Optionally set reply_to and tags such as type=report_ready.
  6. Handle 400, 401, and 429 from the error envelope. Confirm delivery with a webhook, not by polling inside the worker.
  7. 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.

That is the whole integration: a Micronaut service you already run, one HTTPS POST, and a download the requester can open.