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
Install the official SDK for your language — Node.js, Python, Ruby, PHP, Go, Rust, Java, .NET, or the CLI. Every install command is listed on SDKs. The Node.js examples throughout these docs use the mailblastr npm package; each example also has tabs for the other packages and a dependency-free cURL tab if you prefer no SDK at all.
npm install mailblastr # Node.js
pip install mailblastr # Python
composer require mailblastr/mailblastr # PHPSend 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@mailblastr.dev"],
"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@mailblastr.dev | A successful delivery. |
bounced@mailblastr.dev | A hard bounce. |
complained@mailblastr.dev | A spam complaint. |
suppressed@mailblastr.dev | 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 255 characters.
- Recommended pattern:
<event-type>/<entity-id>— for examplewelcome-user/123456789.
curl -X POST 'https://www.mailblastr.com/api/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@mailblastr.dev"],
"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.