v0 Transactional Email API (2026): Send a Magic-Link Sign-In from a v0-Generated Next.js App with POST /emails
After a v0-generated Next.js app already mints a one-time sign-in URL, send that magic link with Rovela POST /emails. No official v0 plugin. Rovela does not authenticate v0 users.
A v0 magic-link sign-in is not a generic magic-login guide, a signup confirmation, or an agent-tool primer
When v0 has already generated a Next.js app — a sign-in form, a session strategy, and a one-time sign-in URL you minted after the user typed their address — that Server Action or Route Handler still has to tell the person who asked to sign in: “Use this link to sign in,” plus the magic URL you already have. That send is transactional email. It is not a newsletter, and it is not a rewrite of the generic magic login email links guide, the Next.js magic-link tutorial, the signup confirmation flow, or the AI coding agent HTTP send primer. Those tutorials already exist. This article is one event in a v0-generated product: the user asked to sign in (they may already have an account), a single-use login URL already exists, and you need that link to leave your verified domain. Rovela does not run v0, mint Next.js sessions, or talk to Vercel — this is your app’s own magic-link sign-in, sent through POST /emails. The recipient is the address that was just submitted. The call to action is “sign in,” not “confirm your email to finish signing up,” and not “welcome to the product.”
This guide does not invent an official v0 or Vercel plugin, or a Rovela Next.js SDK. There is no client library to install. If you already use a hosted auth provider’s built-in mail, treat that as a separate path. The HTTP email API is how the generated Server Action sends from a domain you verified, with DKIM, an Idempotency-Key, and webhooks you control. Keep the key in the Server Action’s environment, never in a Client Component that v0 may have also generated.
A magic-link sign-in is a returning (or returning-to-complete) session, not the first proof of address after insert. If you also confirm new signups, that is a second event, with its own token and idempotency key — see email verification links and the code vs link comparison. The token in the sign-in URL is yours. Rovela only delivers the message.
What you need before the first magic-link sign-in
The first-email guide and the Quick Start are the same five steps, whether you call curl or a server-side fetch from a Next.js Server Action or Route Handler in the v0-generated app:
- Create an account. The free plan sends real mail. There is no separate sandbox, and no test key that behaves differently from production.
- Add and verify a sending domain (often a subdomain such as
mail.example.com). 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 an email domain is. - Create an API key. A
sending_accesskey can send and nothing else — the right default for a production magic-link sign-in sender. Afull_accesskey can also read messages and events, and manage domains, templates, and webhooks. The full key is shown once. Keys look likere_…and go out as a bearer token (authentication, email API authentication). - 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 "Acme <login@mail.example.com>". The address must sit on a verified sending domain. You prove you control the domain — that is what makes domain email trustworthy — before you speak as it. See the From name guide, the sending domains API, how email authentication works, how to set up domain email, and sending subdomain setup.
At least one of html, text, or template is required. template is a documented { id, variables } object and is mutually exclusive with html and text. Send both html and text where you can (HTML email API). Reusable copy can move to a template later; follow the templates guide. Examples here keep the copy inline.
Programmatic volume belongs on the HTTP email API, not on mailbox SMTP. Rovela SMTP is mailbox mail for Outlook, Apple Mail, or a phone: host mx.rovela.dev, port 465 with SSL/TLS, the mailbox’s full address, and a device credential (the same one that device uses for IMAP). A mailbox can send only as itself. For this magic-link sign-in, start with email API vs SMTP.
A v0 Server Action that sends only after the one-time sign-in URL already exists
v0 typically emits a Next.js App Router project. Sign-in forms may look like Client Components, but the mail send belongs in a Server Action or a Route Handler. That is the only place a ROVELA_API_KEY should live. If v0 also generated a "use client" form, have it POST the email address to your server function and stop there.
Do the auth work first, then the send. Look up or create the user according to your own rules, mint a random one-time token, store only its hash and an expiry (15 minutes is a common choice you enforce yourself), and build a sign-in URL on your domain, for example https://app.example.com/auth/magic?token=…. Only after that write succeeds should the Server Action call the Send Email API. If the write fails, do not send. If the HTTP call times out, retry it with the same Idempotency-Key; do not mint a second token unless you also bump the key version.
There is no official v0 SDK for Rovela. A server-side fetch is enough:
// app/auth/magic/action.ts — Server Action, never a Client Component
"use server";
const signInUrl = `https://app.example.com/auth/magic?token=${plainToken}`;
const res = await fetch("https://api.rovela.dev/emails", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ROVELA_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": `v0-magic-login-${userId}-v${tokenVersion}`,
},
body: JSON.stringify({
from: "Acme <login@mail.example.com>",
to: email,
subject: "Sign in to Acme",
html:
`<p>Use this link to sign in to Acme. It expires in 15 minutes.</p>` +
`<p><a href="${signInUrl}">Sign in</a></p>` +
`<p>If you did not request this, you can ignore this message.</p>`,
text:
`Use this link to sign in to Acme. It expires in 15 minutes.\n${signInUrl}\n` +
`If you did not request this, you can ignore this message.`,
tags: { type: "magic-login", source: "v0-app" },
}),
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(`rovela ${res.status}: ${err.message || res.statusText}`);
}
const { id } = await res.json();
Use a sending_access key. When the user opens /auth/magic, compare the token to your hash, start the session, and invalidate the token. Rovela does not start Next.js sessions. If you later want a welcome message after the first successful sign-in, send it as a second, separately idempotent event.
Idempotency, recipients, and what a 200 actually means
Retries are normal. A server action, edge function, workflow, or queued job can time out after Rovela has already accepted the message. Send the documented Idempotency-Key header so a retry does not create a second magic-link sign-in. A stable key such as v0-magic-login-user_01-v2 is unique to this event, this recipient, and this token or invite version, and it stays the same when the HTTP call is repeated.
to accepts a string or an array. cc and bcc count toward billing and toward the documented cap of 50 recipients on one message. For a magic-link sign-in, use a single to: the person who just asked to sign in. If you need an owner copy, send a second, separately idempotent message instead of BCC-ing a shared inbox.
A 200 from POST /emails means accepted for delivery, not arrived. The body looks like {"object": "email", "id": "9f1c2e40-..."}. Delivery is asynchronous. Read state with GET /emails/:id or GET /emails/:id/events (those need full_access or a dashboard session). In production, subscribe to a webhook for email.sent, email.delivered, email.bounced, and related events instead of polling from the request that minted the magic-link sign-in.
If the address is on the suppression list, the send can still return an id, but the message is not delivered and its status becomes suppressed. Check Suppressions in the dashboard before assuming the API failed. Rate limits are per key; a 429 means retry with backoff. Each message in a POST /emails/batch request counts individually.
Optional documented fields include reply_to, scheduled_at (an ISO 8601 timestamp in the future), tags, headers, and attachments as { filename, content (base64), content_type }. This magic-link sign-in does not need an attachment. To queue a later follow-up, use scheduled_at — not a sleep in the request path. A batch is appropriate only when you truly have many different messages, up to 100 per request.
Errors you should handle in the v0-generated Server Action
Documented errors share one shape: statusCode, name, and message. Handle them once in the v0-generated Server Action.
- 400 — a missing required field, a
fromdomain that is not in your organization or is still unverified, a template that does not exist, a base64 attachment that does not decode, or more than 50 recipients on one message. Readmessage; it often names the domain or the missing field. Do not retry a 400 in a tight loop. - 401 — missing or invalid credential, or a missing
Bearerprefix. A revoked key looks the same from the client’s point of view. - 403 — a valid
sending_accesskey used on a management or read endpoint such asGET /emails/:idorGET /domains. The message says which permission is required. Keep the send path onsending_access; usefull_accessor the dashboard for status reads. - 429 — the per-key rate limit. Retry with backoff. Do not fan out a burst of magic-link sign-in sends from an unqueued loop.
A leaked sending_access key can send mail as your domain. Keep ROVELA_API_KEY in the server or edge-function environment, never in the browser, a mobile client, a public page, or a chat transcript (email API authentication). There is no official client SDK to install; a standard HTTPS call is enough.
Delivery is asynchronous — do not poll from the v0-generated Server Action
After magic-link sign-in is accepted, delivery continues in the background. The v0-generated Server Action should store the returned message id next to your own event record and return to the user. Watching the message from that same request with a tight GET /emails/:id loop will slow the sign-up, invite, or form path and still needs full_access.
For production, configure a webhook and follow the webhook overview. Typical events include email.sent, email.delivered, email.opened, email.clicked, and email.bounced (event reference). Use bounces to keep your own list clean; do not invent a /logs API — the documented reads are GET /emails/:id, GET /emails/:id/events, the dashboard Emails view, and webhooks.
If a magic-link sign-in landed in spam, start with DNS rather than the HTTP call: confirm the DKIM record is published at the selector the dashboard gave you, that you have exactly one SPF record, and that DMARC is not p=reject on a brand-new domain with no sending history. Reputation takes weeks, not minutes (how email authentication works).
What not to do in this v0 magic-link sign-in
Do not paste a Rovela key into the v0 chat, into a Client Component, or into a NEXT_PUBLIC_ variable. Do not configure Nodemailer against mx.rovela.dev for app sign-ins — mailbox SMTP is send-as-self for a person or a small client. This magic-link belongs on the HTTP API.
Do not turn the message into a signup confirmation or a marketing blast (transactional vs marketing). Do not invent a sandbox key or a dedicated IP. Do not poll GET /emails/:id inside the Server Action. Do not reuse an Idempotency-Key after you rotate the login token; bump the version in the key.
Rovela will not consume the token or set a cookie. Your /auth/magic route does that after a successful click.
A compact v0 magic-link checklist
- Verify a sending domain and create a
sending_accesskey (Quick Start). - Mint and store the one-time sign-in URL first; send only after that write succeeds.
- Call
POST /emailsfrom a Server Action or Route Handler withIdempotency-Key,html, andtext. - Keep the key out of Client Components and out of the v0 prompt.
- Use webhooks for bounces; a 200 only means accepted.
- Invalidate the token after a successful sign-in.