A newsletter API lets your application keep a subscriber list and send one email to everyone on it, personalized per person, without a separate marketing tool. You add contacts to a list, create a broadcast with a subject and body, and send it now or later. The provider sends one message per subscribed contact, adds unsubscribe headers and skips addresses that bounced or complained.
Why send newsletters through an API?
A drag-and-drop marketing tool suits a marketing team. An API suits a product team that wants:
- One source of truth. Subscribers live in your database and sync to the list as they sign up or change settings.
- Automation. A release note can go out when a deploy finishes, or a digest every Monday from a cron job.
- One provider. The same domain, DNS records and webhooks as your transactional mail.
What a good newsletter setup needs
| Need | Why |
|---|---|
| Recorded consent | You must be able to show each person asked to receive it |
| One-click unsubscribe | Required by Gmail and Yahoo for bulk marketing mail (RFC 8058) |
| Topics | People can leave one kind of email instead of all of them |
| Suppression | Hard bounces and complaints must never be mailed again |
| A text part | Readable everywhere and easier for spam filters to trust |
| A sending subdomain | Keeps newsletter reputation away from receipts and logins |
The List-Unsubscribe header guide explains the two headers and what your unsubscribe endpoint must do.
Best practices for newsletters
- Double opt-in. Send a confirmation email on sign-up and add the contact only after they click. It keeps typos and bots off your list.
- Say who you are. Use a recognizable From name, the same every time.
- One message, one main link. Readers act on one thing. A digest can list several, but keep a clear first one.
- Keep a steady rhythm. Weekly or monthly, but predictable. Long gaps followed by a big send look suspicious to filters and surprising to readers.
- Prune. Remove contacts who have not opened in a long time. Note that open tracking is unreliable since Apple Mail Privacy Protection loads images for its users, so use clicks or site activity as well.
- Include a postal address. CAN-SPAM requires a valid physical postal address in commercial email. See the FTC’s compliance guide.
Example newsletter
From: Acme Product <news@news.acme.com>
Subject: Acme in November: three things worth knowing
Hi Sam,
1. Scheduled reports. Pick a day and Acme emails the PDF.
2. Two new API filters on /reports.
3. Office hours on 4 December. Reply to this email to save a seat.
Thanks for reading,
The Acme team
Acme Inc, 1 Example Street, Springfield
Not interested in product news? Unsubscribe: {link}
Sending a newsletter with Mailcandor
Mailcandor Broadcasts gives you audiences, contacts, topics and one-click unsubscribe through the same API key and domain as your other email. A broadcast sends one email per contact who has not unsubscribed (and, with a topic, is in it), skips your suppression list and carries RFC 8058 List-Unsubscribe headers.
Merge tags work in the subject, HTML and text: {{{FIRST_NAME|fallback}}}, {{{LAST_NAME}}}, {{{EMAIL}}} and {{{UNSUBSCRIBE_URL}}}.
This script creates an audience, adds a contact, creates a broadcast and schedules it:
const API = 'https://api.mailcandor.com/v1';
const headers = {
Authorization: `Bearer ${process.env.MAILCANDOR_KEY}`,
'Content-Type': 'application/json',
};
async function call(method, path, body) {
const res = await fetch(API + path, { method, headers, body: JSON.stringify(body) });
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.type}: ${data.error.message}`);
return data;
}
const audience = await call('POST', '/audiences', { name: 'Product news' });
await call('POST', `/audiences/${audience.id}/contacts`, {
email: 'sam@example.com',
first_name: 'Sam',
});
const broadcast = await call('POST', '/broadcasts', {
audience_id: audience.id,
name: 'November update',
from: 'Acme Product <news@news.acme.com>',
subject: 'Acme in November: three things worth knowing',
html: `<p>Hi {{{FIRST_NAME|there}}},</p>
<p>Scheduled reports are here: pick a day and Acme emails the PDF.</p>
<p>Acme Inc, 1 Example Street, Springfield<br>
<a href="{{{UNSUBSCRIBE_URL}}}">Unsubscribe</a></p>`,
text: 'Hi {{{FIRST_NAME|there}}},\n\nScheduled reports are here.\n\nUnsubscribe: {{{UNSUBSCRIBE_URL}}}',
});
const sent = await call('POST', `/broadcasts/${broadcast.id}/send`, {
scheduled_at: 'in 2 hours',
});
console.log(sent.status); // "scheduled"
For double opt-in, send the confirmation itself with POST /v1/emails (it is a transactional email to one person), and only call the contacts endpoint once the link is clicked. Store when and how each person confirmed, in case you ever need to show consent.
In a real app you would create the audience once and keep its id, adding contacts as people confirm their subscription. scheduled_at accepts an ISO time or plain English up to 30 days ahead, and a scheduled broadcast can be canceled until it goes out. Broadcast emails count toward your plan like any other email; see pricing.
Common pitfalls
- Importing an old list. Addresses collected years ago bounce and complain. Send a re-permission email first or leave them out.
- Hiding the unsubscribe link. People who cannot find it press “Report spam” instead, which hurts you far more.
- Newsletters from your login domain. One bad send can delay password resets. Use a subdomain such as
news.acme.com. - HTML only. Some clients and readers prefer text. Always send both.
- No preview send. Send a draft to yourself and check it on a phone before every broadcast.
- Image-only emails. A single large image with no text is a classic spam sign and unreadable with images off.