E-mail verzenden
Verstuur individuele transactionele e-mails met het endpoint /v3/smtp/email.
Endpoint
POST /v3/smtp/emailRequest body
Basis-e-mail
{ "sender": { "name": "Your App", }, "to": [ { "name": "John Doe" } ], "subject": "Welcome to our service!", "htmlContent": "<html><body><h1>Welcome!</h1><p>Thank you for signing up.</p></body></html>"}Uitgebreide e-mail
{ "sender": { "name": "Your App", }, "to": [ { "name": "John Doe" } ], "cc": [ { "name": "CC User" } ], "bcc": [ { } ], "subject": "Order Confirmation #{{order_id}}", "htmlContent": "<html><body><h1>Order Confirmed</h1><p>Your order {{order_id}} has been confirmed.</p></body></html>", "textContent": "Your order {{order_id}} has been confirmed.", "params": { "order_id": "12345" }, "tags": ["transactional", "order-confirmation"], "headers": { "X-Custom-Header": "custom-value" }}Codevoorbeelden
JavaScript/Node.js
const brevo = require('@getbrevo/brevo');
const apiInstance = new brevo.TransactionalEmailsApi();apiInstance.setApiKey(brevo.TransactionalEmailsApiApiKeys.apiKey, process.env.BREVO_API_KEY);
const sendEmail = async () => { const sendSmtpEmail = new brevo.SendSmtpEmail();
sendSmtpEmail.subject = "Welcome to our service!"; sendSmtpEmail.htmlContent = "<html><body><h1>Welcome!</h1></body></html>";
try { const result = await apiInstance.sendTransacEmail(sendSmtpEmail); console.log('Email sent:', result); return result; } catch (error) { console.error('Error sending email:', error); throw error; }};Python
import sib_api_v3_sdkfrom sib_api_v3_sdk.rest import ApiException
configuration = sib_api_v3_sdk.Configuration()configuration.api_key['api-key'] = 'YOUR_API_KEY'
api_instance = sib_api_v3_sdk.TransactionalEmailsApi(sib_api_v3_sdk.ApiClient(configuration))
send_smtp_email = sib_api_v3_sdk.SendSmtpEmail( subject="Welcome to our service!", html_content="<html><body><h1>Welcome!</h1></body></html>")
try: api_response = api_instance.send_transac_email(send_smtp_email) print(api_response)except ApiException as e: print("Exception when calling TransactionalEmailsApi->send_transac_email: %s\n" % e)cURL
curl -X POST "https://api.brevo.com/v3/smtp/email" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "api-key: YOUR_API_KEY" \ -d '{ "sender": { "name": "Your App", "email": "[email protected]" }, "to": [ { "email": "[email protected]", "name": "John Doe" } ], "subject": "Welcome to our service!", "htmlContent": "<html><body><h1>Welcome!</h1></body></html>" }'Antwoord
Geslaagd antwoord (201 Created)
{}Foutmeldingen
Ongeldige API-sleutel (401)
{ "code": "unauthorized", "message": "Invalid API key provided"}Ongeldig e-mailformaat (400)
{ "code": "invalid_parameter", "message": "Invalid email format in 'to' field"}Limiet overschreden (429)
{ "code": "too_many_requests", "message": "Rate limit exceeded"}Parameters
Verplichte parameters
| Parameter | Type | Omschrijving |
|---|---|---|
sender | object | Gegevens van de afzender |
to | array | Array met ontvangerobjecten |
subject | string | Onderwerpregel van de e-mail |
Optionele parameters
| Parameter | Type | Omschrijving |
|---|---|---|
htmlContent | string | HTML-inhoud van de e-mail |
textContent | string | Tekstinhoud van de e-mail |
cc | array | Cc-ontvangers |
bcc | array | Bcc-ontvangers |
replyTo | object | Antwoordadres |
attachments | array | Bijlagen |
params | object | Templateparameters |
tags | array | Tags voor tracking |
headers | object | Aangepaste headers |
Templatevariabelen
Gebruik templatevariabelen in je onderwerp en inhoud:
{ "subject": "Welcome {{firstName}}!", "htmlContent": "<h1>Hello {{firstName}} {{lastName}}</h1>", "params": { "firstName": "John", "lastName": "Doe" }}Bijlagen
Voeg bestandsbijlagen toe:
{ "attachments": [ { "content": "base64_encoded_content", "name": "invoice.pdf" }, { "url": "https://example.com/document.pdf", "name": "document.pdf" } ]}Best practices
- Neem altijd zowel HTML- als tekstinhoud op voor een betere afleverbaarheid
- Gebruik templatevariabelen in plaats van inhoud aan elkaar te plakken
- Vul de afzendergegevens volledig in om spamfilters te vermijden
- Voeg tags toe voor tracking en analyse
- Valideer e-mailadressen voordat je verstuurt
- Handel fouten netjes af met herhaallogica
Verzendlimieten
- Gratis accounts: 300 e-mails per dag
- Betaalde accounts: afhankelijk van je abonnement
- Burstlimiet: 100 e-mails per minuut
Tracking
E-mails die via dit endpoint worden verstuurd, worden automatisch gevolgd op:
- Afleverstatus
- Openpercentages
- Kliktracking
- Afhandeling van bounces
Bekijk gedetailleerde analyses in je Brevo-dashboard onder Statistics → Transactional.
Gerelateerde endpoints
- E-mailtemplates
- Bijlagen
- E-mailstatistieken