Sendinblue is now Brevo. This repo uses Brevo's current Node.js SDK, @getbrevo/brevo, with a small Express app.
The examples cover:
- send a transactional email with inline HTML/text
- send with a Brevo template
- send batch transactional messages with
messageVersions - create or update a contact
- create a transactional webhook
- receive webhook events locally
- Express quickstart routes - the runnable root app with transactional sends, template sends, batch sends, contacts, webhook creation, and local webhook receiving.
- Node.js 20+
- A Brevo API key
- A verified Brevo sender or sending domain
npm install
cp env.template .env
npm run devFill in .env:
BREVO_API_KEY=xkeysib-xxxxxxxxx
BREVO_FROM_EMAIL=sender@example.com
BREVO_FROM_NAME=Tutorial App
BREVO_TO_EMAIL=recipient@example.com
BREVO_WEBHOOK_TOKEN=
PORT=3000BREVO_WEBHOOK_TOKEN is optional. If you set it, configure the same value as a custom webhook header and the local receiver will reject requests without it.
curl http://127.0.0.1:3000/healthcurl -X POST http://127.0.0.1:3000/send-email \
-H "Content-Type: application/json" \
-d '{
"subject": "Hello from Brevo",
"htmlContent": "<p>Your order {{params.orderNumber}} is confirmed.</p>",
"params": { "orderNumber": "A-1043" },
"tags": ["tutorial"]
}'curl -X POST http://127.0.0.1:3000/send-template \
-H "Content-Type: application/json" \
-d '{
"templateId": 8,
"params": { "name": "Ada", "plan": "Pro" }
}'Brevo batch transactional sends use messageVersions. Put every recipient inside a version.
curl -X POST http://127.0.0.1:3000/send-batch \
-H "Content-Type: application/json" \
-d '{
"subject": "Order confirmation",
"htmlContent": "<p>Hello {{params.name}}, order {{params.orderNumber}} is ready.</p>",
"messageVersions": [
{
"to": [{ "email": "one@example.com", "name": "One" }],
"params": { "name": "One", "orderNumber": "A-100" }
},
{
"to": [{ "email": "two@example.com", "name": "Two" }],
"params": { "name": "Two", "orderNumber": "A-101" }
}
]
}'curl -X POST http://127.0.0.1:3000/contacts \
-H "Content-Type: application/json" \
-d '{
"email": "ada@example.com",
"attributes": { "FIRSTNAME": "Ada" },
"listIds": [2],
"updateEnabled": true
}'The URL must be public HTTPS for production. During local development, use a tunnel.
curl -X POST http://127.0.0.1:3000/webhooks \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhooks/brevo",
"events": ["delivered", "hardBounce", "spam"],
"description": "Tutorial transactional events"
}'POST /webhooks/brevo
Incoming events are saved under webhooks/.