Which sending feature should I use?
Transactional emails (POST /emails) are for one-to-one app email; campaigns are for one-to-many marketing to a sending domain’s contacts. How to choose.
MailBlastr has two ways to send mail, built for two different jobs. Use transactional sends (POST /emails) for messages you trigger for a single person from your application — and campaigns for one campaign sent to many contacts at once. Both send from a verified domain; they differ in how you address recipients and how unsubscribes are handled.
At a glance
| Transactional | Campaign | |
|---|---|---|
| Endpoint | POST /emails | POST /campaigns/:id/send |
| Shape | One-to-one (or a few to/cc/bcc) | One-to-many to a domain’s contacts |
| Recipients | Addresses you pass in the request (to, 1–50) | Every subscribed contact on the linked domain |
| Typical use | Receipts, password resets, magic links, alerts, OTPs | Newsletters, product announcements, marketing campaigns |
| Triggered by | Your app, per event, in real time | You, once, when the campaign is ready |
| Unsubscribe | Not applicable (1:1 app mail) | Per-contact one-click unsubscribe, added automatically |
| Permission needed | sending_access or full_access | full_access to create/edit; send needs sending_access |
| Scheduling | scheduled_at on the send | scheduled_at on /send |
| Idempotency | Idempotency-Key header | Drafts are sent once (already-sent is rejected) |
Use transactional (POST /emails) when…
- The email is for one person and triggered by something they did — a signup, a purchase, a password reset request.
- You already know the recipient address at send time and want to pass it directly.
- You need a programmatic, low-latency send straight from your backend.
- Examples: order receipts, password resets, email verification, magic links, security alerts, one-off notifications.
A transactional send takes the recipients inline and returns an email id immediately:
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.emails.send({
"from": "Acme <receipts@yourdomain.com>",
"to": ["customer@example.com"],
"subject": "Your receipt",
"html": "<p>Thanks for your order!</p>"
});
console.log({ data, error });Use a campaign when…
- The email goes to many people at once — everyone on a list, not one triggered recipient.
- It is marketing or newsletter content where recipients must be able to unsubscribe.
- You want MailBlastr to fan the message out across a sending domain’s contacts and track per-campaign performance.
- Examples: monthly newsletters, launch announcements, promotions, re-engagement campaigns.
A campaign targets a sending domain — its contact pool — instead of inline recipients. You create the draft, then send it — MailBlastr delivers to every subscribed contact and appends a one-click unsubscribe footer.
1. Create the campaign (draft):
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.campaigns.create({
"domain": "yourdomain.com",
"from": "Acme <news@yourdomain.com>",
"subject": "March newsletter",
"html": "<p>What we shipped this month…</p>"
});
console.log({ data, error });2. Send it (optionally pass scheduled_at), using the id returned from the create call:
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.campaigns.send('CAMPAIGN_ID');
console.log({ data, error });Transactional vs. marketing: the compliance line
The endpoint split mirrors a legal one. A transactional email is triggered by a user action or required for compliance — order confirmations, password resets, account notices — and recipients cannot unsubscribe from it; it’s an essential, expected message. That’s why POST /emails carries no unsubscribe footer.
A marketing email is anything that isn’t transactional: promotions, newsletters, product updates. These are regulated by laws such as CAN-SPAM (US) and CASL (Canada), and recipients must be able to unsubscribe. That’s why campaigns append a one-click unsubscribe automatically.
| Message | Recipient | Send as |
|---|---|---|
| Order / signup confirmation | Single | Transactional |
| Password reset | Single | Transactional |
| Abandoned-cart reminder | Single | Campaign / marketing (unsubscribable) |
| Newsletter | Many | Campaign |
| Promotional offer | Many | Campaign |
POST /emails over a contact list to send marketing — that bypasses audience unsubscribe handling and risks complaints. Use a campaign for one-to-many mail.See the full emails API, campaigns, and audiences references.