> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.brevo.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.brevo.com/_mcp/server.

# Send a transactional email

POST https://api.brevo.com/v3/smtp/email
Content-Type: application/json

Send a transactional email to one or more recipients, either using inline HTML content or a pre-built template via `templateId`. You can schedule emails for future delivery using `scheduledAt` (UTC, up to 5-minute delay), send multiple personalized versions with `messageVersions` (max 2000 total recipients, 99 per version), and attach files via URL or base64-encoded content. A `sender` and `subject` are required when no `templateId` is provided; when a `templateId` is used, the template''s sender and subject are applied unless overridden.

Reference: https://developers.brevo.com/reference/send-transac-email

## Authentication

- `api-key` header (required) — The API key should be passed in the request headers as `api-key` for authentication.

## Request

### Body (application/json)

This endpoint expects an object.

- `attachment` (list of object, optional) — Array of attachment objects. Each attachment must include either an absolute URL (no local file paths) or base64-encoded content, along with the attachment filename. The `name` field is required when `content` is provided. Supported file extensions: xlsx, xls, ods, docx, docm, doc, csv, pdf, txt, gif, jpg, jpeg, png, tif, tiff, rtf, bmp, cgm, css, shtml, html, htm, zip, xml, ppt, pptx, tar, ez, ics, mobi, msg, pub, eps, odt, mp3, m4a, m4v, wma, ogg, flac, wav, aif, aifc, aiff, mp4, mov, avi, mkv, mpeg, mpg, wmv, pkpass, xlsm. When `templateId` is specified: if the template uses the New Template Language format, both `url` and `content` attachment types are supported; if the template uses the Old Template Language format, the `attachment` parameter is ignored.
  - `content` (string, optional) — Base64-encoded attachment data
  - `name` (string, optional) — Attachment filename. Required when `content` is provided.
  - `url` (string, optional) — Absolute URL of the attachment. Local file paths are not supported.
- `batchId` (string, optional) — UUIDv4 identifier for the scheduled batch of transactional emails. If omitted, a valid UUIDv4 batch identifier is automatically generated.
- `bcc` (list of object, optional) — Array of BCC recipient objects. Each object contains an email address and an optional name.
  - `email` (string, required) — BCC recipient email address
  - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient in bcc for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
  - `name` (string, optional) — Display name of the BCC recipient. Maximum length is 70 characters.
- `cc` (list of object, optional) — Array of CC recipient objects. Each object contains an email address and an optional name.
  - `email` (string, required) — CC recipient email address
  - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient in cc for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
  - `name` (string, optional) — Display name of the CC recipient. Maximum length is 70 characters.
- `headers` (map from string to any, optional) — Custom email headers (non-standard headers) to include in the email. The `sender.ip` header can be set to specify the IP address used for sending transactional emails (dedicated IP users only). Header names must use Title-Case-Format (words separated by hyphens with the first letter of each word capitalized). Headers not in this format are automatically converted. Standard email headers are not supported. Example: `{"sender.ip":"1.2.3.4", "X-Mailin-custom":"some_custom_value", "Idempotency-Key":"abc-123"}`
- `htmlContent` (string, optional) — HTML body content of the email. Required when `templateId` is not provided. Ignored when `templateId` is provided.
- `messageVersions` (list of object, optional) — Array of message version objects for sending customized email variants. The `templateId` can be customized per version only if a global `templateId` is provided. The `htmlContent` and `textContent` can be customized per version only if at least one of these is present in the global parameters. Global parameters such as `to` (required), `bcc`, `cc`, `replyTo`, and `subject` can be customized per version. Maximum total recipients per API request is 2000. Maximum recipients per message version is 99. Individual `params` objects must not exceed 100 KB. Cumulative `params` across all versions must not exceed 1000 KB. See https://developers.brevo.com/docs/batch-send-transactional-emails for detailed usage instructions.
  - `to` (list of object, required) — Array of recipient objects. Each object contains an email address and an optional display name.
    - `email` (string, required) — Email address of the recipient
    - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
    - `name` (string, optional) — Display name of the recipient. Maximum length is 70 characters.
  - `bcc` (list of object, optional) — Array of BCC recipient objects. Each object contains an email address and an optional name.
    - `email` (string, required) — BCC recipient email address
    - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient in bcc for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
    - `name` (string, optional) — Display name of the BCC recipient. Maximum length is 70 characters.
  - `cc` (list of object, optional) — Array of CC recipient objects. Each object contains an email address and an optional name.
    - `email` (string, required) — CC recipient email address
    - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient in cc for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
    - `name` (string, optional) — Display name of the CC recipient. Maximum length is 70 characters.
  - `htmlContent` (string, optional) — HTML body content of the email. Required when `templateId` is not provided. Ignored when `templateId` is provided.
  - `params` (map from string to any, optional) — Key-value pairs for template variable substitution. Only applicable when the template uses the New Template Language format.
  - `replyTo` (object, optional) — Reply-to email address (required) and optional display name. Recipients will use this address when replying to the email.
    - `email` (string, required) — Email address in reply to
    - `name` (string, optional) — Display name for the reply-to address. Maximum length is 70 characters.
  - `subject` (string, optional) — Email subject line for this message version
  - `textContent` (string, optional) — Plain text body content of the email. Ignored when `templateId` is provided.
- `params` (map from string to any, optional) — Key-value pairs for template variable substitution. Only applicable when the template uses the New Template Language format.
- `replyTo` (object, optional) — Reply-to email address (required) and optional display name. Recipients will use this address when replying to the email.
  - `email` (string, required) — Email address in reply to
  - `name` (string, optional) — Display name for the reply-to address. Maximum length is 70 characters.
- `scheduledAt` (datetime, optional) — UTC date-time when the email should be sent (format: YYYY-MM-DDTHH:mm:ss.SSSZ). Include timezone information in the date-time value. Scheduled emails may be delayed by up to 5 minutes.
- `sender` (object, optional) — Sender information. Required when `templateId` is not provided. Specify either an email address (with optional name) or a sender ID. The `name` field is ignored when `id` is provided.
  - `email` (string, optional) — Sender email address. Required when `id` is not provided.
  - `id` (long, optional) — Sender identifier. Required when `email` is not provided. Use this field to select a sender with a specific IP pool (dedicated IP users only).
  - `name` (string, optional) — Display name of the sender. Maximum length is 70 characters. Only applicable when `email` is provided.
- `subject` (string, optional) — Email subject line. Required when `templateId` is not provided.
- `tags` (list of string, optional) — Array of tags for categorizing and filtering emails
- `templateId` (long, optional) — Template identifier
- `textContent` (string, optional) — Plain text body content of the email. Ignored when `templateId` is provided.
- `to` (list of object, optional) — Array of recipient objects. Each object contains an email address and an optional display name. Required when `messageVersions` is not provided. Ignored when `messageVersions` is provided. Example: `[{"name":"Jimmy", "email":"jimmy@example.com"}, {"name":"Joe", "email":"joe@example.com"}]`
  - `email` (string, required) — Email address of the recipient
  - `contactPixelTrackingConsent` (boolean, optional) — Consent of the recipient for open (pixel) and click tracking, resolved by the sender at send time. Considered only if the per-contact pixel tracking consent feature is enabled for your account. Pass `true` if this recipient has consented to open and click tracking, in which case the open pixel and tracked links identify the recipient. Pass `false` to anonymise the open and click events (counted in aggregate statistics only). If it is not passed, the recipient is treated as unknown consent status and the email is still sent (the open and click are anonymised unless your account tracks unknown-consent contacts). A value other than `true`/`false` is rejected. Ignored when the feature is not enabled for your account.
  - `name` (string, optional) — Display name of the recipient. Maximum length is 70 characters.

## Response

### 201

Transactional email sent successfully

- `messageId` (string, optional) — Message ID of the transactional email sent
- `messageIds` (list of string, optional)

### 202

Transactional email scheduled successfully

- `any`

## Errors

### 400 Bad Request Error

bad request

- `code` (enum, required) — Error code displayed in case of a failure
  - Allowed values: `invalid_parameter`, `missing_parameter`, `out_of_range`, `campaign_processing`, `campaign_sent`, `document_not_found`, `not_enough_credits`, `permission_denied`, `duplicate_parameter`, `duplicate_request`, `method_not_allowed`, `unauthorized`, `account_under_validation`, `not_acceptable`, `bad_request`, `unprocessable_entity`, `Domain does not exist`, `Contact email not found`, `Attribute not found`, `Category id not found`, `Invalid parameters passed`, `Record(s) for identifier not found`, `Returned when query params are invalid`, `Returned when invalid data posted`, `Feed not found`, `Campaign ID not found`, `api-key not found`, `DMARC policy requires domain authentication`, `DNS records not properly configured`, `Invalid OTP code provided`, `OTP code has expired`, `Domain already exists in your account`, `The sum of all IP weights must equal 100`, `Authentication failed`, `Insufficient credits`, `Request already processed`
- `message` (string, required) — Readable message associated to the failure

## Examples

### response

**Request**

```json
undefined
```

**Response**

```json
{
  "messageId": "<201798300811.5787683@relay.domain.com>"
}
```

**SDK Code**

```typescript response
import { BrevoClient } from "@getbrevo/brevo";

async function main() {
    const client = new BrevoClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.transactionalEmails.sendTransacEmail({});
}
main();

```

```python response
from brevo import Brevo

client = Brevo(
    api_key="YOUR_API_KEY_HERE",
)

client.transactional_emails.send_transac_email()

```

```php response
<?php

namespace Example;

use Brevo\Brevo;
use Brevo\TransactionalEmails\Requests\SendTransacEmailRequest;

$client = new Brevo(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->transactionalEmails->sendTransacEmail(
    new SendTransacEmailRequest([]),
);

```

```go response
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.brevo.com/v3/smtp/email"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby response
require 'uri'
require 'net/http'

url = URI("https://api.brevo.com/v3/smtp/email")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.brevo.com/v3/smtp/email")
  .header("api-key", "<apiKey>")
  .asString();
```

```csharp response
using RestSharp;

var client = new RestClient("https://api.brevo.com/v3/smtp/email");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift response
import Foundation

let headers = ["api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.brevo.com/v3/smtp/email")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### response

**Request**

```json
undefined
```

**Response**

```json
{
  "messageId": "<201798300811.5787683@relay.domain.com>"
}
```

**SDK Code**

```typescript response
import { BrevoClient } from "@getbrevo/brevo";

async function main() {
    const client = new BrevoClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.transactionalEmails.sendTransacEmail({});
}
main();

```

```python response
from brevo import Brevo

client = Brevo(
    api_key="YOUR_API_KEY_HERE",
)

client.transactional_emails.send_transac_email()

```

```php response
<?php

namespace Example;

use Brevo\Brevo;
use Brevo\TransactionalEmails\Requests\SendTransacEmailRequest;

$client = new Brevo(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->transactionalEmails->sendTransacEmail(
    new SendTransacEmailRequest([]),
);

```

```go response
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.brevo.com/v3/smtp/email"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("api-key", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby response
require 'uri'
require 'net/http'

url = URI("https://api.brevo.com/v3/smtp/email")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.brevo.com/v3/smtp/email")
  .header("api-key", "<apiKey>")
  .asString();
```

```csharp response
using RestSharp;

var client = new RestClient("https://api.brevo.com/v3/smtp/email");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift response
import Foundation

let headers = ["api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.brevo.com/v3/smtp/email")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Static content example

**Request**

```json
{
  "htmlContent": "<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>",
  "sender": {
    "email": "hello@brevo.com",
    "name": "Alex from Brevo"
  },
  "subject": "Hello from Brevo!",
  "to": [
    {
      "email": "johndoe@example.com",
      "name": "John Doe"
    }
  ]
}
```

**Response**

```json
{
  "messageId": "<201798300811.5787683@relay.domain.com>"
}
```

**SDK Code**

```typescript Static content example
import { BrevoClient } from "@getbrevo/brevo";

async function main() {
    const client = new BrevoClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.transactionalEmails.sendTransacEmail({
        htmlContent: "<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>",
        sender: {
            email: "hello@brevo.com",
            name: "Alex from Brevo",
        },
        subject: "Hello from Brevo!",
        to: [
            {
                email: "johndoe@example.com",
                name: "John Doe",
            },
        ],
    });
}
main();

```

```python Static content example
from brevo import Brevo
from brevo.transactional_emails import SendTransacEmailRequestSender, SendTransacEmailRequestToItem

client = Brevo(
    api_key="YOUR_API_KEY_HERE",
)

client.transactional_emails.send_transac_email(
    html_content="<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>",
    sender=SendTransacEmailRequestSender(
        email="hello@brevo.com",
        name="Alex from Brevo",
    ),
    subject="Hello from Brevo!",
    to=[
        SendTransacEmailRequestToItem(
            email="johndoe@example.com",
            name="John Doe",
        )
    ],
)

```

```php Static content example
<?php

namespace Example;

use Brevo\Brevo;
use Brevo\TransactionalEmails\Requests\SendTransacEmailRequest;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestSender;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestToItem;

$client = new Brevo(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->transactionalEmails->sendTransacEmail(
    new SendTransacEmailRequest([
        'htmlContent' => '<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>',
        'sender' => new SendTransacEmailRequestSender([
            'email' => 'hello@brevo.com',
            'name' => 'Alex from Brevo',
        ]),
        'subject' => 'Hello from Brevo!',
        'to' => [
            new SendTransacEmailRequestToItem([
                'email' => 'johndoe@example.com',
                'name' => 'John Doe',
            ]),
        ],
    ]),
);

```

```go Static content example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.brevo.com/v3/smtp/email"

	payload := strings.NewReader("{\n  \"htmlContent\": \"<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>\",\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Static content example
require 'uri'
require 'net/http'

url = URI("https://api.brevo.com/v3/smtp/email")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"htmlContent\": \"<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>\",\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Static content example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.brevo.com/v3/smtp/email")
  .header("api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"htmlContent\": \"<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>\",\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}")
  .asString();
```

```csharp Static content example
using RestSharp;

var client = new RestClient("https://api.brevo.com/v3/smtp/email");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"htmlContent\": \"<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>\",\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Static content example
import Foundation

let headers = [
  "api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "htmlContent": "<html><head></head><body><p>Hello,</p>This is my first transactional email sent from Brevo.</p></body></html>",
  "sender": [
    "email": "hello@brevo.com",
    "name": "Alex from Brevo"
  ],
  "subject": "Hello from Brevo!",
  "to": [
    [
      "email": "johndoe@example.com",
      "name": "John Doe"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.brevo.com/v3/smtp/email")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Dynamic content example

**Request**

```json
{
  "htmlContent": "<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>",
  "params": {
    "estimatedArrival": "Tomorrow",
    "trackingCode": "JD01460000300002350000"
  },
  "sender": {
    "email": "hello@brevo.com",
    "name": "Alex from Brevo"
  },
  "subject": "Hello from Brevo!",
  "to": [
    {
      "email": "johndoe@example.com",
      "name": "John Doe"
    }
  ]
}
```

**Response**

```json
{
  "messageId": "<201798300811.5787683@relay.domain.com>"
}
```

**SDK Code**

```typescript Dynamic content example
import { BrevoClient } from "@getbrevo/brevo";

async function main() {
    const client = new BrevoClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.transactionalEmails.sendTransacEmail({
        htmlContent: "<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>",
        params: {
            estimatedArrival: "Tomorrow",
            trackingCode: "JD01460000300002350000",
        },
        sender: {
            email: "hello@brevo.com",
            name: "Alex from Brevo",
        },
        subject: "Hello from Brevo!",
        to: [
            {
                email: "johndoe@example.com",
                name: "John Doe",
            },
        ],
    });
}
main();

```

```python Dynamic content example
from brevo import Brevo
from brevo.transactional_emails import SendTransacEmailRequestSender, SendTransacEmailRequestToItem

client = Brevo(
    api_key="YOUR_API_KEY_HERE",
)

client.transactional_emails.send_transac_email(
    html_content="<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>",
    params={
        "estimatedArrival": "Tomorrow",
        "trackingCode": "JD01460000300002350000"
    },
    sender=SendTransacEmailRequestSender(
        email="hello@brevo.com",
        name="Alex from Brevo",
    ),
    subject="Hello from Brevo!",
    to=[
        SendTransacEmailRequestToItem(
            email="johndoe@example.com",
            name="John Doe",
        )
    ],
)

```

```php Dynamic content example
<?php

namespace Example;

use Brevo\Brevo;
use Brevo\TransactionalEmails\Requests\SendTransacEmailRequest;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestSender;
use Brevo\TransactionalEmails\Types\SendTransacEmailRequestToItem;

$client = new Brevo(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->transactionalEmails->sendTransacEmail(
    new SendTransacEmailRequest([
        'htmlContent' => '<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>',
        'params' => [
            'estimatedArrival' => "Tomorrow",
            'trackingCode' => "JD01460000300002350000",
        ],
        'sender' => new SendTransacEmailRequestSender([
            'email' => 'hello@brevo.com',
            'name' => 'Alex from Brevo',
        ]),
        'subject' => 'Hello from Brevo!',
        'to' => [
            new SendTransacEmailRequestToItem([
                'email' => 'johndoe@example.com',
                'name' => 'John Doe',
            ]),
        ],
    ]),
);

```

```go Dynamic content example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.brevo.com/v3/smtp/email"

	payload := strings.NewReader("{\n  \"htmlContent\": \"<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>\",\n  \"params\": {\n    \"estimatedArrival\": \"Tomorrow\",\n    \"trackingCode\": \"JD01460000300002350000\"\n  },\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Dynamic content example
require 'uri'
require 'net/http'

url = URI("https://api.brevo.com/v3/smtp/email")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"htmlContent\": \"<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>\",\n  \"params\": {\n    \"estimatedArrival\": \"Tomorrow\",\n    \"trackingCode\": \"JD01460000300002350000\"\n  },\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Dynamic content example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.brevo.com/v3/smtp/email")
  .header("api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"htmlContent\": \"<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>\",\n  \"params\": {\n    \"estimatedArrival\": \"Tomorrow\",\n    \"trackingCode\": \"JD01460000300002350000\"\n  },\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}")
  .asString();
```

```csharp Dynamic content example
using RestSharp;

var client = new RestClient("https://api.brevo.com/v3/smtp/email");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"htmlContent\": \"<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>\",\n  \"params\": {\n    \"estimatedArrival\": \"Tomorrow\",\n    \"trackingCode\": \"JD01460000300002350000\"\n  },\n  \"sender\": {\n    \"email\": \"hello@brevo.com\",\n    \"name\": \"Alex from Brevo\"\n  },\n  \"subject\": \"Hello from Brevo!\",\n  \"to\": [\n    {\n      \"email\": \"johndoe@example.com\",\n      \"name\": \"John Doe\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Dynamic content example
import Foundation

let headers = [
  "api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "htmlContent": "<html><head></head><body>Your delivery is expected {{params.estimatedArrival}}.Your tracking code: {{params.trackingCode}}</p></body></html>",
  "params": [
    "estimatedArrival": "Tomorrow",
    "trackingCode": "JD01460000300002350000"
  ],
  "sender": [
    "email": "hello@brevo.com",
    "name": "Alex from Brevo"
  ],
  "subject": "Hello from Brevo!",
  "to": [
    [
      "email": "johndoe@example.com",
      "name": "John Doe"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.brevo.com/v3/smtp/email")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```