POST /api/mail/send
Sends transactional email from your project.
For the complete Mail Platform documentation (BYOK, batch sending, logs, audiences, contacts, broadcasts, webhooks, and dashboard workflows), see Mail Platform guide.
Required headers
Request body
string | string[]
required
Recipient email address, or an array of recipient addresses. Each address must be a valid email. An array must contain at least one entry.
string | string[]
Optional reply-to address, or an array of addresses. Each address must be a valid email. When provided as an array, it must contain at least one entry. Forwarded to Resend as the message’s
Reply-To header.string
Required in direct mode.
string
Optional HTML body. In direct mode, provide at least one of
html or text.string
Optional text body. In direct mode, provide at least one of
html or text.string
Template ObjectId (24 hex chars). Use either
templateId or templateName.string
Template key or name. Use either
templateId or templateName.object
Optional template variables.
Validation rules
- Template mode:
templateIdortemplateName - Direct mode:
subject+ (htmlortext) - Do not pass both
templateIdandtemplateName. toandreplyTomust contain valid email addresses. Array forms cannot be empty (Recipient list cannot be empty,Reply-to list cannot be empty).- Subject is required after any template resolution and variable interpolation (
Subject is required). - The rendered message must include a non-empty
htmlortextbody. Requests where both come out empty after interpolation are rejected withProvide html or text(orProvide at least one of html or text content.when neither field was supplied).
Template resolution order
When usingtemplateName, urBackend resolves in this order:
- Project template override
- Global/system template
- Legacy embedded template fallback (older projects only)
Placeholder syntax
- Escaped:
{{name}} - Raw:
{{{htmlSnippet}}}(use carefully) - Nested:
{{user.name}}
{{appUrl}}. URL-like variables are sanitized to safe http/https values.
How to use
1
Get your Secret Key
Log in to the urBackend Dashboard, create a new project, and copy your Secret Key (
sk_live_...) or you can get it from rotating it from project overview page.2
Copy the Code
Copy your preferred language snippet from below. Use Direct Mode if you just want to send a quick HTML/Text email without setting up templates or use welcome template for fast test.
3
Paste and Run
Paste the code into your app, replace
sk_live_YOUR_SECRET_KEY with your actual key, change the to email address, and run it!The Java examples use the native
java.net.http.HttpClient (requires Java 11+) and Text Blocks for JSON formatting (requires Java 15+).