Skip to main content
relyr / docsDashboard
THE RELYR API

Your first email. In minutes.

Create an account, add and verify your sending domain, then create an API key. All requests use Bearer authentication. The API base path is /api/v1.

Every endpoint is described in the interactive API reference and in the OpenAPI spec, which you can import into Postman or a client generator.

POST

/emails

Queues a transactional email and returns 202 {"id":"uuid"}. Use an Idempotency-Key for safe API retries; reuse with a different payload returns 409.

curl
curl -X POST https://app.getrelyr.io/api/v1/emails \
  -H "Authorization: Bearer $RELYR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: welcome-user-123" \
  -d '{
    "from": "hello@example.com",
    "to": ["ada@example.com"],
    "subject": "Welcome aboard",
    "template": "welcome",
    "variables": { "name": "Ada" }
  }'
Node.js · fetch
const response = await fetch('https://app.getrelyr.io/api/v1/emails', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.RELYR_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': 'welcome-user-123'
  },
  body: JSON.stringify({
    from: 'hello@example.com',
    to: ['ada@example.com'],
    subject: 'Welcome aboard',
    html: '<h1>Hello, Ada.</h1>',
    text: 'Hello, Ada.'
  })
});
const result = await response.json();
if (!response.ok) throw new Error(result.error.message);
console.log(result.id);
Java 17+
import java.net.URI;
import java.net.http.*;

public class SendEmail {
  public static void main(String[] args) throws Exception {
    String body = """
      {"from":"hello@example.com","to":["ada@example.com"],
       "subject":"Welcome aboard","text":"Hello, Ada."}
      """;
    var request = HttpRequest.newBuilder()
      .uri(URI.create("https://app.getrelyr.io/api/v1/emails"))
      .header("Authorization", "Bearer " + System.getenv("RELYR_API_KEY"))
      .header("Content-Type", "application/json")
      .header("Idempotency-Key", "welcome-user-123")
      .POST(HttpRequest.BodyPublishers.ofString(body)).build();
    var response = HttpClient.newHttpClient()
      .send(request, HttpResponse.BodyHandlers.ofString());
    if (response.statusCode() != 202)
      throw new RuntimeException(response.body());
    System.out.println(response.body());
  }
}

Request body

fromRequired. Email address or Name <email>; domain must be verified.
toRequired. Array of email addresses.
cc, bccOptional arrays. Maximum 50 total recipients.
subjectRequired. Subject without line breaks.
html, textProvide one or both, or choose a template.
reply_toOptional reply-to email address.
tagsOptional [{name, value}]; up to 10 tags.
headersOptional object of custom X- headers.
template, variablesBuilt-in template name and string variables.

Templates

Send a ready-made email under your own brand: set template and its variables. The template renders HTML and plain text, replaces html and text, and supplies a default subject. A custom subject may use {{variable}} placeholders. Unknown variables are rejected.

Every template also takes brand variables: app_name (defaults to the sender domain), logo_url, accent_color, support_email, website_url and company_address. Preview any template in the dashboard under Templates, or with POST /api/v1/templates/{id}/preview.

otp_code

One-time code for sign-in, two-factor authentication or step-up checks. Laid out so mail clients can detect the code and offer to copy or autofill it.

Variables: code (required), purpose, expires_in_minutes

"template": "otp_code",
"variables": {
  "code": "482913"
}

pin_code

Short PIN that confirms a sensitive action, such as a payment or a new device. Copyable like the verification code.

Variables: code (required), action (required), expires_in_minutes

"template": "pin_code",
"variables": {
  "code": "7351",
  "action": "approve a payment of €40.00"
}

magic_link

Passwordless sign-in link, with an optional code for signing in on another device.

Variables: login_url (required), code, expires_in_minutes

"template": "magic_link",
"variables": {
  "login_url": "https://acme.example/auth/magic?token=abc123"
}

email_verification

Confirms a new or changed email address with a link, and optionally a code.

Variables: name, verify_url (required), code

"template": "email_verification",
"variables": {
  "verify_url": "https://acme.example/verify?token=abc123"
}

password_reset

Link to choose a new password.

Variables: name, reset_url (required), expires_in_minutes

"template": "password_reset",
"variables": {
  "reset_url": "https://acme.example/reset?token=abc123"
}

password_changed

Confirms a password change and tells the recipient what to do if it wasn't them.

Variables: name, secure_url

"template": "password_changed",
"variables": {}

new_login_alert

Warns about a sign-in from a new device or location.

Variables: name, reason, device (required), location, ip_address, time, secure_url

"template": "new_login_alert",
"variables": {
  "device": "Chrome on macOS"
}

account_created

Welcomes a new user once their account exists.

Variables: name, get_started_url

"template": "account_created",
"variables": {}

account_deleted

Confirms an account deletion, with an optional way to restore it during a grace period.

Variables: name, restore_url, restore_until

"template": "account_deleted",
"variables": {}

subscription_confirm

Asks a new subscriber to confirm before you send them marketing email. Expected under GDPR.

Variables: confirm_url (required), list_name

"template": "subscription_confirm",
"variables": {
  "confirm_url": "https://acme.example/subscribe/confirm?token=abc123"
}

subscribed

Confirms a subscription and shows how to leave. Pair with List-Unsubscribe headers.

Variables: name, list_name, unsubscribe_url (required)

"template": "subscribed",
"variables": {
  "unsubscribe_url": "https://acme.example/unsubscribe?token=abc123"
}

unsubscribed

Confirms that the recipient left a list, with an optional way back.

Variables: list_name, resubscribe_url

"template": "unsubscribed",
"variables": {}

thank_you

Thanks the recipient, e.g. after a contact form, purchase or feedback, with an optional button.

Variables: name, message, cta_label, cta_url

"template": "thank_you",
"variables": {}

Earlier names still work: welcome sends account_created and password-reset sends password_reset.

GET /emails/:id

Returns the message, its current status, and ordered events. Authenticate with an active API key from the same workspace. Statuses are queued, sent, delivered, bounced, complained, or failed.

Listen for events

Register a public HTTPS endpoint and a secret in the dashboard. Events are named email.queued, email.sent, email.delivered, email.bounced, email.complained, and email.failed. Respond with 2xx. Delivery is at least once, with six attempts and exponential backoff starting at five seconds. Each request carries relyr-id, relyr-timestamp, and relyr-signature.

// Verify against the unmodified request body before parsing JSON.
import { createHmac, timingSafeEqual } from 'node:crypto';
const timestamp = request.headers.get('relyr-timestamp');
if (!timestamp || !/^\d+$/.test(timestamp) ||
    Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) {
  throw new Error('Expired signature');
}
const rawBody = await request.text();
const expected = 'v1=' + createHmac('sha256', process.env.WEBHOOK_SECRET)
  .update(timestamp + '.' + rawBody).digest('hex');
const received = request.headers.get('relyr-signature') || '';
const a = Buffer.from(expected), b = Buffer.from(received);
if (a.length !== b.length || !timingSafeEqual(a, b)) {
  throw new Error('Invalid signature');
}
// Deduplicate by relyr-id (the event id) before processing.

Errors & limits

Errors use { "error": { "code": "…", "message": "…" } }. Expect 401 for invalid keys, 404 for unknown messages, 409 for idempotency conflicts, 413 for bodies over 1 MB, 422 for invalid inputs or unverified domains, and 429 for rate limits. The default is 10 sends per second per key. Respect the Retry-After header. A 503 means a dependency is unavailable; retry with the same idempotency key.