SDKs
Use the official Resend SDKs with Ritto Mail — the API is wire-compatible.
Ritto Mail has no SDKs of its own. Its REST API is wire-compatible with
Resend's, so the official Resend SDKs work as they are: point them at
Ritto Mail's base URL and authenticate with a Ritto Mail API key (rm_...).
Nothing else changes — same methods, same request and response shapes.
Base URL
https://api.ritto.email — what every example on this page uses. Create
the rm_ key under API keys in the dashboard at
app.ritto.email.
Most SDKs read the base URL from the RESEND_BASE_URL environment variable
and the key from RESEND_API_KEY, so in most apps the switch is two
environment lines:
RESEND_API_KEY=rm_...
RESEND_BASE_URL=https://api.ritto.emailThe exceptions are noted per language below: Python reads RESEND_API_URL
instead, Ruby needs a trailing slash, and Java, .NET and Elixir take the base
URL as a client option.
If the base URL is not applied, the SDK still talks to api.resend.com and
Resend answers 401 with API key is invalid — your rm_ key is fine, the
request just went to the wrong server. Several SDKs read the variable only
once, when the package is loaded, so it must be in the process environment
(shell, container, .env loaded first) before the SDK is imported.
Node.js / TypeScript
resend on npm. Use
RESEND_BASE_URL — it works in every version of the SDK.
npm install resend// RESEND_BASE_URL=https://api.ritto.email
import { Resend } from "resend";
const resend = new Resend("rm_123");
const { data, error } = await resend.emails.send({
from: "Acme <onboarding@acme.dev>",
to: "success@simulator.amazonses.com",
subject: "Hello from Ritto Mail",
html: "<strong>It works!</strong>",
});Up to resend@6.12.3 (including every 4.x and 5.x release) the constructor
takes only the key, and RESEND_BASE_URL is read once, when the module
loads. Assigning process.env.RESEND_BASE_URL after the import has no
effect, and in ES modules the imports run before the rest of the file, so set
it in the environment — node --env-file=.env app.js, your host's
environment settings, or import "dotenv/config" as the very first import.
From resend@6.12.4 the constructor also accepts a baseUrl option, and the
variable is read when the client is created:
const resend = new Resend("rm_123", { baseUrl: "https://api.ritto.email" });On older versions that option is silently ignored and the request goes to
Resend. Check with npm ls resend.
Python
resend on PyPI. Reads
RESEND_API_URL (not RESEND_BASE_URL) when the package is imported, or set
resend.api_url in code, which is read on every request.
pip install resendimport resend
resend.api_key = "rm_123"
resend.api_url = "https://api.ritto.email"
email = resend.Emails.send({
"from": "Acme <onboarding@acme.dev>",
"to": "success@simulator.amazonses.com",
"subject": "Hello from Ritto Mail",
"html": "<strong>It works!</strong>",
})Go
resend-go. Set the client's
BaseURL field, which works in every version. Since v2.5.0 the package also
reads RESEND_BASE_URL, once, when the program starts.
go get github.com/resend/resend-go/v4client := resend.NewClient("rm_123")
client.BaseURL, _ = url.Parse("https://api.ritto.email/") // import "net/url"
sent, err := client.Emails.Send(&resend.SendEmailRequest{
From: "Acme <onboarding@acme.dev>",
To: []string{"success@simulator.amazonses.com"},
Subject: "Hello from Ritto Mail",
Html: "<strong>It works!</strong>",
})Ruby
resend on RubyGems. Reads
RESEND_BASE_URL (since v0.10.0) once, when the gem is loaded, so set it in
the process environment before require "resend". The gem appends paths
without a separator, so keep the trailing slash:
https://api.ritto.email/.
gem install resend# RESEND_BASE_URL=https://api.ritto.email/
require "resend"
Resend.api_key = "rm_123"
email = Resend::Emails.send({
from: "Acme <onboarding@acme.dev>",
to: "success@simulator.amazonses.com",
subject: "Hello from Ritto Mail",
html: "<strong>It works!</strong>"
})PHP
resend/resend-php on Packagist.
Reads RESEND_BASE_URL (since v0.11.0) each time Resend::client() is
called, so the variable only has to be set before that call. There is no
base URL argument.
composer require resend/resend-php// RESEND_BASE_URL=https://api.ritto.email
$resend = Resend::client('rm_123');
$email = $resend->emails->send([
'from' => 'Acme <onboarding@acme.dev>',
'to' => 'success@simulator.amazonses.com',
'subject' => 'Hello from Ritto Mail',
'html' => '<strong>It works!</strong>',
]);Rust
resend-rs on crates.io. Reads
RESEND_BASE_URL; ConfigBuilder::base_url sets it in code.
cargo add resend-rs tokio -F tokio/macros,tokio/rt-multi-thread// RESEND_BASE_URL=https://api.ritto.email
use resend_rs::types::CreateEmailBaseOptions;
use resend_rs::Resend;
let resend = Resend::new("rm_123");
let email = CreateEmailBaseOptions::new(
"Acme <onboarding@acme.dev>",
["success@simulator.amazonses.com"],
"Hello from Ritto Mail",
)
.with_html("<strong>It works!</strong>");
let sent = resend.emails.send(email).await?;Java
com.resend:resend-java on Maven Central.
Takes the base URL through the builder.
<dependency>
<groupId>com.resend</groupId>
<artifactId>resend-java</artifactId>
<version><!-- latest --></version>
</dependency>Resend resend = Resend.builder()
.apiKey("rm_123")
.baseUrl("https://api.ritto.email")
.build();
CreateEmailResponse sent = resend.emails().send(
CreateEmailOptions.builder()
.from("Acme <onboarding@acme.dev>")
.to("success@simulator.amazonses.com")
.subject("Hello from Ritto Mail")
.html("<strong>It works!</strong>")
.build());.NET
Resend on NuGet. Takes the base
URL through ResendClientOptions.ApiUrl (also with AddResend in
dependency injection).
dotnet add package Resendusing Resend;
IResend resend = ResendClient.Create(new ResendClientOptions
{
ApiToken = "rm_123",
ApiUrl = "https://api.ritto.email",
});
var res = await resend.EmailSendAsync(new EmailMessage
{
From = "Acme <onboarding@acme.dev>",
To = "success@simulator.amazonses.com",
Subject = "Hello from Ritto Mail",
HtmlBody = "<strong>It works!</strong>",
});Elixir
resend on Hex. Takes the base URL
through the client config.
# mix.exs
def deps do
[{:resend, "~> 0.4"}]
endconfig :resend, Resend.Client,
api_key: System.get_env("RESEND_API_KEY"),
base_url: "https://api.ritto.email"
{:ok, email} =
Resend.Emails.send(%{
from: "Acme <onboarding@acme.dev>",
to: "success@simulator.amazonses.com",
subject: "Hello from Ritto Mail",
html: "<strong>It works!</strong>"
})Receiving and inboxes
The Resend SDKs cover sending, and their received-mail methods call the same
receiving endpoints. What Ritto Mail adds on top —
inboxes, long polling with wait, the inbox_id filter,
verification codes, quarantine, threads and drafts — is not in the Resend
SDKs: call it over HTTP with your rm_ key, from any language.
const headers = { Authorization: `Bearer ${process.env.RESEND_API_KEY}` };
const inbox = "7eeb9517-aed7-40d7-ad65-500be42ed147";
// Wait up to 30 seconds for the next email delivered to an inbox.
const page = await fetch(
`https://api.ritto.email/emails/receiving?inbox_id=${inbox}&wait=30`,
{ headers },
).then((r) => r.json());
// The newest verification code or sign-in link it received.
const code = await fetch(
`https://api.ritto.email/inboxes/${inbox}/codes/latest?wait=30`,
{ headers },
).then((r) => r.json());- Reply, forward and draft sends accept an
Idempotency-Keyheader. Send one to make a retry safe. - A reply or forward that the inbox's rules hold answers a draft instead of the sent email; the response says which.
- Domains gain
receiving_catch_all, API keysinbox_id, webhooksinbox_ids, and the webhook event typesemail.receivedand the inbox events. Resend SDKs ignore fields they don't know, so they keep working. - Every endpoint is in the API reference.
Resend is a registered trademark of Plus Five Five, Inc. Ritto Mail is not affiliated with or endorsed by Resend.