Email campaigns overview
Author campaigns in the console, send to an audience, and track delivery through the REST API.
Campaigns are authored in the BuildBase console: pick a template, pick an audience, send or schedule. The API is for driving and observing that pipeline from your backend, not for composing mail in code.
Note
There is no bb.email.send(). The BuildBase() server factory has no
email namespace. To send one transactional message to one user, use
bb.notification.send() - it renders the event's
email template and respects the user's preferences. To send one email to any
address from your backend, use the email
API. Campaigns are for audience-scale
sends.
// Send a campaign that was prepared in the console
const response = await fetch(
`https://api.console.buildbase.app/api/emails/campaigns/${campaignId}/send`,
{
method: 'POST',
headers: { Authorization: process.env.BUILDBASE_API_TOKEN! },
}
);Before you start
Before a campaign can send, you need a working sender (SMTP, Google, Mailgun
or Amazon SES, under Messaging > Sender accounts; a Mailgun sender
also needs a verified sending domain, while SMTP,
Google and Amazon SES authenticate the domain at that provider), and a
template with an unsubscribe link and your postal address (the unsubscribe
and companyAddress merge tags, with the
address set under merge tags). Anti-spam law in the US, Canada and the EU
requires both in marketing email, and the send is refused (422
EMAIL_PRESEND_FAILED) until they are there.
The pipeline
- Template - the reusable body, with merge tags. See templates and merge tags.
- Sender - who it comes from, through a sender with an active account; a Mailgun sender also on a verified domain.
- Campaign - a template plus an audience plus a schedule.
- Drafts - one queued message per recipient, materialized from the campaign.
- Send - the queue delivers, and history records the outcome per recipient.
Drafts are the step that surprises people. A campaign does not send directly to an audience: it first expands into per-recipient drafts, and the send walks those. That is what makes partial retry possible.
Campaign endpoints
All require an Authorization header - see the admin API
for the token format and list-query parameters.
| Method | Path | Purpose |
|---|---|---|
GET | /api/emails/campaigns | List campaigns, paginated |
GET | /api/emails/campaigns/:id | One campaign |
POST | /api/emails/campaigns | Create |
PATCH | /api/emails/campaigns/:id | Update |
POST | /api/emails/campaigns/:id/create-drafts | Expand the audience into per-recipient drafts |
POST | /api/emails/campaigns/:id/send | Send the campaign |
POST | /api/emails/campaigns/:id/retry-failed | Re-queue only the recipients that failed |
DELETE | /api/emails/campaigns/:id | Delete |
GET | /api/emails/campaigns/:id/presend-check | What blocks the send, and what is only advice |
POST | /api/emails/campaigns/:id/schedule | Send at scheduledAt, checked now |
POST | /api/emails/campaigns/:id/unschedule | Back to draft |
POST | /api/emails/campaigns/:id/pause | Hold what has not gone out |
POST | /api/emails/campaigns/:id/resume | Re-queue what was held |
POST | /api/emails/campaigns/:id/cancel | Drop what has not gone out, for good |
POST | /api/emails/campaigns/:id/release-sample | Send to the rest now, after the health check |
POST | /api/emails/campaigns/:id/archive | Publish or withdraw the web version |
GET | /api/emails/campaigns/:id/postmaster | Gmail's data for the days it went out |
Scheduling, pausing, the first-send sample and the A/B subject test are described in Sending campaigns.
retry-failed re-queues failures without touching recipients who already
received the message, so it is safe to call more than once after a partial
delivery failure. It returns the counts it acted on:
{
"message": "Retried 12 failed emails, 3 skipped",
"retried": 12,
"skipped": 3
}Campaign status
A campaign is always in one of eight states, and the action endpoints are guarded by it:
| Status | Meaning |
|---|---|
draft | Editable, not yet dispatched |
scheduled | Waiting for its scheduledAt; starts sending on its own |
sending | Dispatch in progress |
paused | Stopped mid-send by a person or the sending health check; resumable |
cancelled | Stopped for good; recipients not reached yet are never sent |
sent | Dispatch finished |
failed | Dispatch failed |
archived | Retired |
| Endpoint | Allowed from | Rejected with |
|---|---|---|
/create-drafts | draft only | 400 - Cannot create drafts for campaign in "X" state |
/send | draft or failed | 400 - Cannot send campaign in "X" state |
/schedule | draft, failed or scheduled (a new time replaces the old) | 409 - Only a draft, failed or scheduled campaign can be scheduled. |
/unschedule | scheduled only; it goes back to draft | 409 - Only a scheduled campaign can be unscheduled. |
/pause | sending, or sent while some of its messages still wait in the send queue | 409 - Only a campaign that is sending can be paused. |
/resume | paused only; it goes back to sending | 409 - Only a paused campaign can be resumed. |
/cancel | sending or paused, or sent while some messages still wait | 409 - Only a campaign that is sending or paused can be cancelled. |
/release-sample | A campaign holding the rest back after its first-send sample | 409 - The rest was not sent: <reason>. |
/archive | Any state: it sets the web version (archive), not the status | - |
/send accepting failed is what makes a whole-campaign retry possible after
a dispatch collapses. Use /retry-failed instead when the campaign partly
succeeded - re-sending from failed state is coarser.
The two 400 rejections use the { error: true, message, path: "status" } shape; the 409 ones answer { success: false, message }.
Delivery history
Every send writes a history row per recipient with a status, and tracking records opens and clicks when the template includes the tracking pixel. Both are exposed as chart endpoints the console renders, and as ordinary list endpoints you can page through.
Delivery is asynchronous. /send returns { "message": "Campaign dispatch started" } as soon as the work is queued - that is not a delivery
confirmation. Poll the history rows for per-recipient outcomes.
Recipients are resolved from the campaign's audience list and expanded in batches of 500, so a large list produces drafts progressively rather than in one pass.
In the console
Open Email history in the console (opens the console in a new tab)In the left rail choose Messaging, then Email history: every message your organization sent, from campaigns, workflows, your app and sign-in, with totals and a chart. Filter by template narrows it to one template.

Press Details on a row for one message: its status, subject, sender,
recipient, when it was sent, each open and click, and its body. The subject is
shown as its reader got it, merge tags filled in, except that a sign-in code or
a link reads [hidden]; a message sent before this was kept shows the
template's subject. The body is shown as the template wrote it; each merge tag
is filled in for its reader when the message goes out. Retry on a failed row sends it again, and Send
now sends a scheduled one at once.

Drafts lists mail made but not sent yet, such as a campaign's messages while it sends, with Send and archive on each row.

Inside a non-production environment, Inbox keeps every message the platform sender sent, links and codes included (the inbox).
Open the Inbox in the console (opens the console in a new tab)Switch to the environment, then choose Inbox, the first item under Email: it shows only there.

Unsubscribes
Two merge tags render opt-out links. Both resolve at send time to a page on your application URL - not the API - carrying a per-recipient token, so the link identifies the recipient without a login:
| Merge tag | Resolves to |
|---|---|
{{unsubscribe}} | <your-app>/unsubscribe-email-group?token=… |
{{manage-preference}} | <your-app>/manage-email-preference?token=… |
The preference center is backed by its own token-validated API under
/api/manage-email-preference, which is what the page calls to read and update
preferences. You do not call it directly.
Every audience campaign should carry at least one of these tags. The
pre-send check refuses a
campaign whose template has neither. Marketing mail, and any message sent
under an unsubscribe group, also carries a List-Unsubscribe header. That is a
hidden line at the top of the message that Gmail and Yahoo use to show their
own Unsubscribe button. See
Unsubscribes and opt-in.
Providers
BuildBase sends through a provider account you connect yourself: Google, Mailgun, Amazon SES, and custom SMTP. BuildBase has no mail account of its own to send your production mail for you. Domain verification runs through your own Mailgun account, so a verified sending domain requires connecting it, whichever provider delivers a given sender.
A development or staging environment with no sender of its own is the exception. Its mail goes through a platform sender, and only to your team's addresses and to pending invitees. Every subject carries the environment's name. Every message it sends is kept in the console's Inbox, links and codes included. Production never uses it.
Send one email from your backend
To send one email from your server, such as a receipt or a shipping notice,
call the email API with an org API key. It runs the checks the console does:
a working sender and the suppression list (addresses BuildBase will not send
to). It does not count against your plan's monthly email quota, which counts
marketing mail, but it has limits of its own: a daily number of API sends set
by your plan, and 30 emails to one address per hour. Past either, it answers
429 with SEND_LIMIT_REACHED.
It also takes an Idempotency-Key header: a name you give this one send. If
your server retries the request with the same key, the email still goes out
only once.
curl -X POST https://api.console.buildbase.app/api/v1/server/emails/send \
-H "Authorization: $BUILDBASE_API_TOKEN" \
-H "Idempotency-Key: order-1234-shipped" \
-H "Content-Type: application/json" \
-d '{"to":{"email":"[email protected]"},"templateId":"TEMPLATE_ID","data":{"orderId":"1234"}}'A new send answers 202 (accepted, not yet sent) with
{ id, status: "queued", replayed: false }. A retry with the same key answers
200 with the same id and replayed: true. The SDK wraps it as emails.send() on createServerClient from
@buildbase/sdk/server, together with subscribers.upsert() and the rest of
the subscriber calls. Requires @buildbase/sdk 1.0.0 or later.
See Send transactional email for the parameters,
the refusal codes and idempotency.
Next Steps
- Templates and merge tags - compose the body.
- Sending domains - verify a domain before the first send.
- Sending campaigns - schedule, test, sample first, A/B the subject, pause and resume.
- Deliverability - the bounce and complaint limits, the never-email lists and what keeps sign-in mail flowing.
- Unsubscribes and opt-in - groups, the preference center, one-click unsubscribe and double opt-in.
- Newsletter archive - publish past issues as a public page with an RSS feed.
- Gmail Postmaster - Gmail's own spam rate and reputation for your domain.
- Notifications - one-off transactional mail.