Install with one command
API base URL: https://api.relayloft.com
Run this in your app's folder and follow the prompts. It connects your sending domain, creates a key and puts it where your app reads its secrets, then sends a test email. Node 18 or newer; nothing to install first.
npx relayloft initWhat it does, step by step
- Signs in through your browser. It shows a code like
ABCD-EFGHand opens/devicein the portal. An Owner or Admin types that code there and approves it (see below). No password or key is ever typed into the terminal for this. - Looks at your project: a Cloudflare Worker or Pages project, a Vercel project, or a plain
.envfile; whether you use the Resend SDK or call the API with fetch; and the From address you send with. - Connects your sending domain to the app you picked, with the same rules and limits as the portal's Domains page, and shows the DNS records to publish. If the domain is on Cloudflare, it can add them for you with a Cloudflare API token you type into a hidden prompt (Zone → DNS → Edit on that zone); the token is used once and never stored. Existing records are never changed: any that clash are listed for you to fix.
- Waits for the domain to verify, or tells you how to finish later if DNS is slow.
- Creates a sending-only key limited to that one domain and pipes it straight into your host's secret store (
wrangler secret put,vercel env add, or.env.localwhen that file is git-ignored). The key is never printed. - Points your app at Relayloft. Usually nothing changes in your code: the Resend Node SDK reads
RESEND_API_KEYandRESEND_BASE_URLfrom the environment. Where your code passes the key itself, or calls the API with fetch, it shows the one-line change as a diff and asks before saving it. - Sends a test email to
delivered@simulator.relayloft.comwith the new key and prints the result. The test addresses work during the trial too. - Signs out: the CLI session ends as soon as setup finishes.
Options: --dry-run (shows what it would do, changes nothing), --yes (accepts the defaults), --domain and --host (skip the questions).
What the person approving sees
The portal's /device page shows the address the request came from as Relayloft saw it, when it started, the program that sent it, and the device's name (labelled as reported by the device, since the device chooses it). It warns when the request came from a different network or country than theirs. It doesn't display the code (the link the CLI opens carries it, so the page can find the request): they type it from your terminal, pick the app, enter their authenticator code and press Approve, or Deny. Only an Owner or Admin can approve; a Member is asked to have their Owner or an Admin run it. The Owner is emailed every approval and every key the CLI creates, and each one is in the audit log.
Only approve a code you just started on your own computer. Nobody from Relayloft will ever ask you for one.
Security
- Approval happens in the browser, by an Owner or Admin with their authenticator code. Codes last 10 minutes.
- The CLI session can only do this setup for the one app approved: connect one domain and create one sending-only key for it. It can't send email, read your email log or use the rest of the API. It ends when setup finishes, and after an hour at most.
- The key it creates is sending-only and limited to one domain, so a leaked key can't manage anything or send as your other domains.
- The key goes straight into the host's secret store and is never printed or logged.
- The CLI has no dependencies and talks to https://api.relayloft.com over HTTPS only.
Supported hosts
- Cloudflare Workers and Pages (secrets with wrangler)
- Vercel (environment variables with the Vercel CLI)
- Anything else: a
.env.localfile, only when git ignores it (otherwise the CLI stops and explains, so the key can't end up in git)
If your app already sends with Resend
A Resend key can't be read back once it's overwritten, so the CLI checks first. With no Resend key yet, it sets RESEND_API_KEY and RESEND_BASE_URL. If one exists, by default it sets new variables beside it and has the client use them, the base URL picking the key:
RELAYLOFT_API_KEY=mr_... # sending-only, one domain
RELAYLOFT_BASE_URL=https://api.relayloft.com
new Resend(env.RELAYLOFT_BASE_URL ? env.RELAYLOFT_API_KEY : env.RESEND_API_KEY, { baseUrl: env.RELAYLOFT_BASE_URL })You can choose to replace the Resend key instead; the CLI warns you first, because rolling back then needs a new Resend key.
Roll back
Side by side: delete RELAYLOFT_API_KEY and RELAYLOFT_BASE_URL and redeploy; your app uses the Resend key again. You can also revoke the CLI's key on the portal's API keys page. The domain and its DNS records can stay; see Switch from Resend for the rest of a move.