> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-transactional-email.md). Agents can also search and read this documentation through its [MCP server](https://user.netmera.com/netmera-developer-guide/~gitbook/mcp).

# Sending a Transactional Email to a Single User

Send an email from a panel template to a single recipient, after adding the address to Netmera.

This recipe shows how to send an email that is defined in the Netmera panel to a single recipient, and how to add the recipient's address to Netmera before the send. Your backend triggers the email right after an event, and Netmera delivers the content of the template.

## When to Use

This recipe fits one-to-one emails that your system sends after an event, such as an account creation notice, an order confirmation, or a password reset notice. To send a different HTML body in every send, see [Sending Bulk Email with Dynamic HTML Content](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-bulk-email-with-dynamic-html.md).

{% hint style="info" %}
The `notificationKey` of an email comes from a transactional email created in the panel. `createNotificationDefinition` creates push notification definitions only and cannot create an email notification key. `sendBulkEmail` creates a new email campaign with every request, so it is not used for one-to-one sends.
{% endhint %}

## Prerequisites

* REST API key of the application
* The Message Key (`notificationKey`) of a transactional email created in the Netmera panel. To create the email and find its key, follow Step 2 of [Sending a Transactional Email with Attachments and Parameters](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-a-transactional-email-with-attachments-and-parameters.md).
* The email address of the recipient

## Step 1: Add the Email Address to Netmera

If the recipient is not a Netmera user yet, upload the address with `addEmail`. The request takes a list, so several addresses can be added at once.

```bash
curl https://restapi.netmera.com/rest/3.0/addEmail \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "emailList": ["john.brown@example.com"]
}'
```

{% hint style="info" %}
If a user with the same email already exists, for example a user with an external ID, a new user is not created. A user created with `addEmail` has no installation ID. If the SDK later creates a user with the same email, the user created with `addEmail` is deleted, because the information from the SDK is considered primary and targeting is done on the SDK user.
{% endhint %}

**Expected result:** The address is available in Netmera as a recipient.

## Step 2: Send the Email

Call `sendNotification` with the `notificationKey` of the email and the address of the recipient in `target.email`.

```bash
curl https://restapi.netmera.com/rest/3.0/sendNotification \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "notificationKey": "12",
  "target": {
    "email": "john.brown@example.com"
  },
  "message": {
    "params": {}
  }
}'
```

**Expected result:** The request is sent with the key of the email created in the panel and the address of the recipient.

### Personalize the Email

To show a different value to each recipient, such as a name or an order number, add a placeholder to the subject or body of the email in the panel, in the `@{NAME}` format. At send time, put the value in `message.params`, with the placeholder name as the key, written without the `@{}` characters.

For example, if the subject of the email is `Welcome to Netmera, @{NAME}`, the following request delivers the subject `Welcome to Netmera, John`:

```bash
curl https://restapi.netmera.com/rest/3.0/sendNotification \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-netmera-api-key: <API_KEY>' \
  --data '{
  "notificationKey": "12",
  "target": {
    "email": "john.brown@example.com"
  },
  "message": {
    "params": {
      "NAME": "John"
    }
  }
}'
```

The values in `message.params` apply only to this request, so every send can carry its own values.

## Step 3: Attach Files When Needed

To send an email with attachments, use `sendEmailWithAttachment`. The request is a multipart form with the fields `mailAttachment`, `to`, and `notificationKey`. More than one attachment can be added.

{% hint style="warning" %}
The email size and the total size of the attachments must not exceed 10 MB. Supported file types include `png`, `jpg`, `jpeg`, `gif`, `pdf`, `csv`, `txt`, `xls`, `xlsx`, `mp4`, `mpeg`, and `avi`.
{% endhint %}

For a full walkthrough with template parameters and example requests, see [Sending a Transactional Email with Attachments and Parameters](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-a-transactional-email-with-attachments-and-parameters.md). For the request reference, see Send Email with Attachment on the [Notifications](https://user.netmera.com/netmera-developer-guide/api-documentation/rest-api/notifications.md) page.

## Step 4: Track the Results

Every send made with the same `notificationKey` is reported under the same transactional email. A separate report is not created for each send.

To read the result of each email, call `getPushResult` with the `notificationKey`. Each entry has `"platform": "EMAIL"` and a `status` of `SUCCESS` or `FAILED`. A failed entry also carries an `errorCode` and an `errorMsg`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getPushResult?notificationKey=12&max=10' \
  --header 'X-netmera-api-key: <API_KEY>'
```

{% hint style="info" %}
`getPushStats` does not return statistics for email notification keys. Read the per-email results with `getPushResult`, and the totals from the report of the transactional email in the panel.
{% endhint %}

In the panel, open the transactional email under **Transactional Messages** to see its report: delivered, opened, clicked, bounced, and unsubscribed counts. The **User Activity** section of the report lists the activity of each recipient by email address.

**Expected result:** One `getPushResult` entry per email, and the totals in the panel report of the transactional email.

## Troubleshooting

| Symptom                                            | Likely cause                                                                         | Solution                                                                                                                                      |
| -------------------------------------------------- | ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| The email does not arrive                          | The address is not a Netmera user yet, or the API key belongs to another application | Add the address with `addEmail` as in Step 1. Check that the API key belongs to the application in which the transactional email was created. |
| A placeholder is not filled in the delivered email | The key in `message.params` does not match the placeholder name                      | Write the key exactly as the placeholder name, without the `@{}` characters.                                                                  |
| `getPushResult` returns an entry with `FAILED`     | The email could not be delivered                                                     | Read the `errorCode` and `errorMsg` of the entry to find the reason.                                                                          |
| `getPushStats` returns no statistics for the key   | `getPushStats` does not support email notification keys                              | Use `getPushResult` and the panel report, as in Step 4.                                                                                       |

## Verification Checklist

* The `notificationKey` belongs to an email created in the Netmera panel and is sent as a string
* `target.email` contains the address of the recipient
* Every placeholder in the email has a key with the same name in `message.params`
* `addEmail` is used only to add addresses, and the SDK user is treated as primary when the same email exists
* The email and its attachments together stay within 10 MB
* Results are read with `getPushResult` and the panel report, not with `getPushStats`

## Related Pages

For the email request formats, see the Email section of the [Notifications](https://user.netmera.com/netmera-developer-guide/api-documentation/rest-api/notifications.md) page. For authentication and request headers, see [Setup](https://user.netmera.com/netmera-developer-guide/api-documentation/rest-api/setup.md). To record the consent of the recipient first, see [Managing Channel Permissions and Category Preferences](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/managing-channel-and-category-preferences.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-transactional-email.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
