Sending & Testing

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

TransactionalCampaign
EndpointPOST /emailsPOST /campaigns/:id/send
ShapeOne-to-one (or a few to/cc/bcc)One-to-many to a domain’s contacts
RecipientsAddresses you pass in the request (to, 1–50)Every subscribed contact on the linked domain
Typical useReceipts, password resets, magic links, alerts, OTPsNewsletters, product announcements, marketing campaigns
Triggered byYour app, per event, in real timeYou, once, when the campaign is ready
UnsubscribeNot applicable (1:1 app mail)Per-contact one-click unsubscribe, added automatically
Permission neededsending_access or full_accessfull_access to create/edit; send needs sending_access
Schedulingscheduled_at on the sendscheduled_at on /send
IdempotencyIdempotency-Key headerDrafts 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.

MessageRecipientSend as
Order / signup confirmationSingleTransactional
Password resetSingleTransactional
Abandoned-cart reminderSingleCampaign / marketing (unsubscribable)
NewsletterManyCampaign
Promotional offerManyCampaign
The deciding factor is the *nature* of the message, not the recipient count. A one-to-one promotional message (e.g. an abandoned-cart nudge) is still marketing and must be unsubscribable — don’t send it as a no-unsubscribe transactional email.
Rule of thumb: if you would send the same content to one person because of something they did, it is transactional. If you would send it to a list because you decided to, it is a campaign.
Do not loop 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.