← Back to blog

Rails Transactional Email API (2026): Send Action View Mail through Rovela’s HTTP API

Replace SMTP Action Mailer in Rails with Rovela’s HTTP Email API: a Net::HTTP service object, optional Action View rendering, Active Job plus Idempotency-Key. Not a magic-link tutorial and not a recurring scheduler guide.

Updated November 10, 2026
Rails Transactional Email API (2026): Send Action View Mail through Rovela’s HTTP API

Rails can still render mail; it does not have to deliver over SMTP

A Rails application already renders HTML, queues Active Job, and talks to HTTP APIs. The natural way to send transactional email — an invoice that is ready, a “your export is ready” note, a shipping update, a security alert — is to render the body (Action View is fine) and then POST that string as JSON with a Bearer key. You do not need Action Mailer to open an SMTP session to a mailbox.

Rovela’s Email API is built for that. There is no official SDK and no gem you have to pin. 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).

This is not a redo of a Rails magic-link tutorial, and it is not a recurring Sidekiq, Delayed Job, or Solid Queue scheduler guide. If you need sign-in links, start from the existing Rails magic-link article and the official verification code example. This article is everyday Rails app mail: a Net::HTTP service object, optional Action View rendering, an Active Job that retries with the same Idempotency-Key, and documented error handling around the {statusCode, name, message} envelope.

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 Rails process belongs on POST /emails.

Action Mailer SMTP on the left versus a Rails service object posting JSON to the email API on the right

What you need before the first Rails send

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

  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. 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 production. 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 "Acme <hello@yourdomain.com>". The address must sit on a verified sending domain. 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 (HTML email API).

A Net::HTTP service object (and optional Action View)

Keep the key on the server. Never put a Rovela key in a browser bundle, a mobile app, or a public repository. A leaked sending_access key can send mail as your domain. Credentials or environment variables are the right place; Rails.application.credentials works if you already use it.

# config / ENV (illustrative)
# ROVELA_API_KEY=re_...          # sending_access
# ROVELA_FROM=Acme <hello@mail.acme.com>
# ROVELA_BASE_URL=https://api.rovela.dev
# app/services/rovela_emails.rb
require "json"
require "net/http"
require "uri"

class RovelaEmails
  class Error < StandardError
    attr_reader :status_code, :payload
    def initialize(status_code, payload)
      @status_code = status_code
      @payload = payload
      super(payload["message"] || status_code.to_s)
    end
  end

  def self.send_email(to:, subject:, html:, text:, idempotency_key: nil, reply_to: nil)
    uri = URI.parse("#{ENV.fetch("ROVELA_BASE_URL", "https://api.rovela.dev")}/emails")
    body = {
      "from" => ENV.fetch("ROVELA_FROM"),
      "to" => to,
      "subject" => subject,
      "html" => html,
      "text" => text
    }
    body["reply_to"] = reply_to if reply_to
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.open_timeout = 10
    http.read_timeout = 30
    req = Net::HTTP::Post.new(uri.request_uri)
    req["Authorization"] = "Bearer #{ENV.fetch("ROVELA_API_KEY")}"
    req["Content-Type"] = "application/json"
    req["Idempotency-Key"] = idempotency_key if idempotency_key
    req.body = JSON.generate(body)
    res = http.request(req)
    payload = JSON.parse(res.body) rescue { "statusCode" => res.code.to_i, "name" => "Error", "message" => res.body }
    return payload if res.is_a?(Net::HTTPSuccess)
    raise Error.new(res.code.to_i, payload)
  end
end

You can still use Action View to render the HTML (and a text template) and pass the strings into this service. That keeps familiar mail templates without using Action Mailer’s SMTP delivery:

html = ApplicationController.render(
  template: "invoices_mail/ready",
  assigns: { invoice: invoice },
  layout: false
)
text = ApplicationController.render(
  template: "invoices_mail/ready",
  formats: [:text],
  assigns: { invoice: invoice },
  layout: false
)

There is still no official SDK; this is ordinary Net::HTTP plus templates you already know how to write.

The curl equivalent of the same send, matching the Emails API and the Quick Start, is:

curl -X POST https://api.rovela.dev/emails \
  -H "Authorization: Bearer $ROVELA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: invoice-10043-ready" \
  -d '{
    "from": "Acme <hello@mail.acme.com>",
    "to": "alice@example.com",
    "subject": "Your invoice 10043 is ready",
    "html": "<p>Invoice <b>10043</b> is ready to view.</p>",
    "text": "Invoice 10043 is ready to view."
  }'

Success looks like {"object": "email", "id": "9f1c2e40-..."}. Store that id next to the invoice in your database. You will want it when you debug a single message.

An Active Job that retries safely

Transactional mail is triggered by something the user did. A small job, with an idempotency key derived from the invoice id so a retried job does not send two notices:

# app/jobs/invoice_ready_email_job.rb
class InvoiceReadyEmailJob < ApplicationJob
  queue_as :default

  def perform(invoice_id)
    invoice = Invoice.find(invoice_id)
    html = ApplicationController.render(
      template: "invoices_mail/ready",
      assigns: { invoice: invoice },
      layout: false
    )
    text = "Invoice #{invoice.number} is ready to view."
    result = RovelaEmails.send_email(
      to: invoice.customer_email,
      subject: "Your invoice #{invoice.number} is ready",
      html: html,
      text: text,
      idempotency_key: "invoice-#{invoice.id}-ready",
      reply_to: "Acme Billing <billing@acme.com>"
    )
    invoice.update!(ready_email_id: result["id"])
  end
end

Enqueue it from a controller or a model callback after the invoice is finalized: InvoiceReadyEmailJob.perform_later(invoice.id). Active Job is a one-shot background send, not a recurring scheduler. If you need cron-like mail, that is a different set of guides.

reply_to is optional and is not a substitute for a verified from. It tells the mail client where a human reply should go (Email API Reply-To). cc and bcc are also documented; they count toward the 50-recipient transport cap and toward monthly quota, because quota is charged per recipient, not per message (Email API CC and BCC).

An Idempotency-Key may be up to 256 characters. A retry of the same request within 24 hours returns the original response instead of sending again. That is the right default for anything driven by a queue, a payment webhook, or a user double-clicking “send invoice.” Configure job retries if you want, but keep the key stable; a new key on every retry defeats the point.

A Rails Active Job retries after a timeout but reuses the same Idempotency-Key so the recipient gets one message

Do not invent a sandbox. Free-plan keys send real mail. During development, use a verified staging subdomain and recipients you control (how to test a transactional email API).

Errors you should handle in the service

Every error uses the same shape (Quick Start, Email API error handling):

{
  "statusCode": 400,
  "name": "Bad Request",
  "message": "html or text body is required"
}

Documented cases you will actually hit from a Rails app:

  • 400 — a missing required field, an unverified or foreign from domain, a template that does not exist, a base64 attachment that does not decode, or more than 50 recipients across to, cc, and bcc.
  • 401 — missing or invalid key, or a sending_access key used to read, reschedule, or cancel a message. Reading events is a full_access (or session) operation.
  • 429 — rate limit or monthly allowance exceeded. Official examples mention Retry-After. Each entry in a batch counts individually, so a large batch can trip this partway through. Sending also stops for the rest of the calendar month if you exceed the plan allowance (Pricing).

Surface the message field in your own logs as-is. Do not invent a /logs API; delivery history lives in the dashboard and, with a full_access key, on GET /emails/:id and GET /emails/:id/events. A 403 can appear on management endpoints when the credential is valid but lacks permission. That is a different failure from a 401.

If the job raises RovelaEmails::Error on a 429, honor Retry-After when the response includes it, then retry the job with the same idempotency key.

Delivery is asynchronous — do not poll from the request path

A 200 from POST /emails is not a delivery receipt. Confirm later:

  • The Emails view in the dashboard.
  • GET /emails/:id and GET /emails/:id/events with a full_access key. You are looking for email.sent followed by email.delivered, or email.bounced if the receiving server rejected it (Email delivery status API).
  • A webhook for anything in production. Verify the HMAC-SHA256 signature (webhook security). Event types include sent, delivered, delayed, bounced, complained, opened, and clicked.

Do not turn a Rails controller or a job into a polling loop against /emails/:id/events. The docs are explicit: the events endpoint is useful for debugging a single message; systematic handling belongs on a webhook.

POST /emails/batch accepts up to 100 messages, each with the same schema, processed independently. template and topic_id are rejected on the batch endpoint rather than ignored — send those through POST /emails. If you schedule with scheduled_at, reading, rescheduling, and cancelling need full_access or a dashboard session; a sending_access key can only send. The dedicated scheduled email and batch transactional email guides cover those flows in full; this article will not redo them.

Templates stored in Rovela are available if you would rather send { id, variables } (Templates API, templates guide). template is mutually exclusive with html and text. Rendering with Action View and passing html/text is the other documented path: you supply the body, Rovela queues it.

What not to do in a Rails codebase

Do not configure Action Mailer with smtp_settings pointed at mx.rovela.dev for application volume. That path is for mailboxes and mail apps. A mailbox can send only as its own address, and the documented client limit is 30 messages a minute. You also lose the HTTP API’s tracking, logs, and webhooks (SMTP, Email API vs SMTP relay).

Do not create a “Rovela gem” wrapper that invents endpoints, official clients, numeric HTTP rate (req/s) figures, a sandbox flag, or a dedicated IP. Call the documented HTTP API.

Do not put the key in query parameters, in frontend code, or in a committed credentials file that ships to git unencrypted. Create a sending_access key for the Rails service. If you send for several customers from one organization, a key can be restricted to a single domain (Authentication, Email API for multi-tenant SaaS).

Do not treat Active Job retries as a substitute for the idempotency header. A job that retries after a timeout still needs a stable Idempotency-Key. A job also does not confirm delivery; only the events API or a webhook does.

A compact Rails checklist

  1. Verify the sending domain before any production from.
  2. Store a sending_access key in credentials or the environment; construct Authorization: Bearer … on the server.
  3. Render html and text (Action View is fine) and POST them as JSON.
  4. Set reply_to when a human should be able to answer.
  5. Put an Idempotency-Key on any send a job, webhook, or double submit might repeat.
  6. Handle 400, 401, and 429 from the documented error envelope. Remember that 200 means queued.
  7. Subscribe to webhooks for delivery, bounces, and complaints; use GET /emails/:id/events only to debug a single message.
  8. Leave mailbox SMTP to people and mail apps. Leave recurring schedulers to their own guides.

Once that service object is in place, every other Rails job can call it the same way — receipts, shipping updates, security alerts — without growing a second email stack. That is the point of a transactional email API: one authenticated HTTP call from the application you already run.