The Emails API
Create a key and send email from your server.
Create a key
- 1Open Emails → API Keys and choose Create key.
- 2Name it after the app that uses it, like Checkout service.
- 3Pick the access: Send only for apps that just send, Full access for tools that also read the log, Read only for dashboards.
- 4Pick Live to deliver, or Test to log emails without delivering them while you build.
- 5Copy the key. It is shown once.
Send an email
POST https://api.rimbra.app/api/marketing/emails/send with your key as a Bearer token.
javascript
const res = await fetch("https://api.rimbra.app/api/marketing/emails/send", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RIMBRA_EMAILS_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
from: "Yourcompany <receipts@yourcompany.com>",
to: ["ada@example.com"],
subject: "Your receipt",
html: "<p>Thanks for your order.</p>",
text: "Thanks for your order.",
}),
})
const message = await res.json() // { id, status: "queued", ... }Fields
| Field | Required | Notes |
|---|---|---|
| from | Yes | An address at a verified domain. "Name <address>" works too |
| to | Yes | One address, or an array of addresses |
| subject | Yes, unless template_id | Up to 998 characters |
| html or text | One of them, unless template_id | Send both for the best inbox placement |
| template_id | No | Send a saved template instead of subject and body |
| variables | With template_id | Values for the template’s {{variables}} |
Responses
| Code | Meaning |
|---|---|
| 202 | Accepted and queued. Follow it in the email log |
| 400 | A field is missing or invalid |
| 401 | The key is missing, wrong or revoked |
| 403 | The key is read only |
| 422 | Test key, unverified from address, unknown template or missing variable |
| 429 | Over 60 sends per minute for this key |
