Quickstart
Send your first email with the MailBlastr API in a few minutes.
Prerequisites
- A verified domain — add one under Domains and publish its DNS records. (guide)
- An API key — create one under API Keys. It starts with
mb_and is shown once. (guide)
Install the SDK
Using Node.js? Install the official `mailblastr` SDK — the Node.js examples throughout these docs use it. From any other language, call the REST API directly (see the cURL / Python / other tabs in each example).
npm install mailblastrSend an email
Replace mb_xxxxxxxxx with your API key and use a from address on your verified domain.
import { MailBlastr } from 'mailblastr';
const mb = new MailBlastr('mb_xxxxxxxxx');
const { data, error } = await mb.emails.send({
"from": "Acme <hello@yourdomain.com>",
"to": ["delivered@example.com"],
"subject": "Hello from MailBlastr",
"html": "<p>Your first email 🎉</p>"
});
console.log({ data, error });Response
A successful send returns the email id you can use to retrieve the email or correlate webhook events.
{
"id": "49a3999c-0ce1-4ea6-ab68-afcd6dc2e794"
}validation_error about the domain not being verified, finish the DNS verification first — emails can only be sent from a verified domain you own (or a subdomain of one).Test addresses
To simulate delivery events without sending to a real inbox (and without damaging your domain reputation), send to one of these reserved test recipients:
| Address | Simulates |
|---|---|
delivered@example.com | A successful delivery. |
bounced@example.com | A hard bounce. |
complained@example.com | A spam complaint. |
suppressed@example.com | A recipient on the suppression list. |
Avoid duplicates with an idempotency key
To safely retry a send without delivering the same email twice, pass an Idempotency-Key header. A repeated request with the same key within the window returns the original result instead of sending again.
- Must be unique per logical request.
- Keys expire after 24 hours.
- Maximum length 256 characters.
- Recommended pattern:
<event-type>/<entity-id>— for examplewelcome-user/123456789.
curl -X POST 'https://api.mailblastr.com/emails' \
-H 'Authorization: Bearer mb_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: welcome-user/123456789' \
-d '{
"from": "Acme <hello@yourdomain.com>",
"to": ["delivered@example.com"],
"subject": "Hello from MailBlastr",
"html": "<p>Your first email 🎉</p>"
}'Next steps
- Schedule an email for later delivery.
- Add attachments or custom headers.
- Send a batch of up to 100 emails in one request.
- Receive webhooks for delivery and engagement events.