> 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/api-reference/email-and-sms/send-bulk-email.md). Agents can also search and read this documentation through its [MCP server](https://user.netmera.com/netmera-developer-guide/~gitbook/mcp).

# Send Bulk Email

Sends an email template created in the Netmera panel to an audience, referenced by its template ID. Use it when an external system, such as a CRM, manages the content and passes send-time values to Netmera, so the template does not need to be updated in the panel for each campaign.

{% hint style="danger" %}
**Requests sent from Test it are real.** Test it opens a request panel; pressing **Send** in that panel calls the live API with the key you enter. With a production API key the template goes to every user the target matches, and `sendToAll: true` reaches all users of the app. Use a test application's key, or target a tag that only your test users carry. The default example targets the `test-users` tag and returns HTTP 400, code `2009`, if the tag does not exist.
{% endhint %}

#### Capabilities

* **Bulk email delivery** — Send emails to a target audience instead of a single user.
* **Template ID-based sending** — Trigger a template created in the Netmera panel by its ID.
* **Campaign-level custom parameters** — Pass key-value pairs that fill placeholders defined in the template.
* **Attachment support** — Attach files to the email when needed.

#### How it works

1. Create the email template in the Netmera panel. It can contain placeholders such as `{DATE}`, `{TITLE}`, `{CONTENT}` or `{PDF_URL}`.
2. Call this endpoint with the template ID and matching keys in `customParams`.
3. Netmera replaces each placeholder with the matching value at send time.

<details>

<summary>Notes</summary>

* The email template must exist in the Netmera panel before you trigger it through the API.
* A placeholder with no matching key in `customParams` renders as empty in the delivered email.
* `emailIysMessageType` is checked only after the template is found. With an unknown `emailTemplateId`, the template error is returned first, whatever the `emailIysMessageType` value.
* `emailIysMessageType` is case-insensitive and is used only when the template has no email type of its own.
* In that case, an invalid value returns HTTP 400, code `2004`, "emailIysMessageType must be one of: N, NOTIFICATION, C, CAMPAIGN, CAMPAIGN\_ADVERTISEMENT".
* When neither the template nor the request sets a type, the email is sent as `CAMPAIGN_ADVERTISEMENT`.

</details>

```json
{"openapi":"3.1.0","info":{"title":"Netmera REST API","version":"3.0"},"tags":[{"name":"Email and SMS","description":"Send email and SMS messages.\n\n<table data-view=\"cards\"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type=\"content-ref\"></th></tr></thead><tbody><tr><td><strong>Send Email or SMS</strong></td><td><code>POST</code> Send an email or an SMS to one user, with the content in the request or from a template.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/email-and-sms/send-email-or-sms\">Send Email or SMS</a></td></tr><tr><td><strong>Send Email with Attachment</strong></td><td><code>POST</code> Send a panel email to one user with files attached.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/email-and-sms/send-email-with-attachment\">Send Email with Attachment</a></td></tr><tr><td><strong>Send Bulk Email</strong></td><td><code>POST</code> Send a panel email template to an audience, filling its placeholders at send time.</td><td><a href=\"https://user.netmera.com/netmera-developer-guide/api-documentation/api-reference/email-and-sms/send-bulk-email\">Send Bulk Email</a></td></tr></tbody></table>\n"}],"servers":[{"url":"https://restapi.netmera.com","description":"Netmera REST API"}],"security":[{"REST-API-key":[]}],"components":{"securitySchemes":{"REST-API-key":{"type":"apiKey","in":"header","name":"X-netmera-api-key","description":"REST API key. Available in the Netmera Panel under Developers > API.\n"}},"schemas":{"TargetOperatorList":{"description":"A single value, an array of values (OR), or an operator object using `$or`, `$and` or\n`$not`.\n","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"$or":{"type":"array","items":{"type":"string"}},"$and":{"type":"array","items":{"type":"string"}},"$not":{"type":"array","items":{"type":"string"}}},"additionalProperties":true}]},"NetmeraError":{"type":"object","description":"Standard Netmera error body.","required":["code","error"],"properties":{"code":{"type":"integer","description":"Netmera error code. See the error table in the API description."},"error":{"type":"string","description":"Human readable error message."}}},"ProblemDetail":{"type":"object","description":"RFC 7807 error body returned by the framework instead of the Netmera error body when a\nrequired query parameter is missing or a parameter cannot be converted to its type.\n","properties":{"type":{"type":"string"},"title":{"type":"string"},"status":{"type":"integer"},"detail":{"type":"string"},"instance":{"type":"string"}}}},"responses":{"InvalidApiKey":{"description":"The `X-netmera-api-key` header is missing or the key is not valid.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}},"IpNotAllowed":{"description":"The application restricts REST calls to a list of allowed IP addresses and the caller's\nIP is not on it. The check runs after the API key is validated and before the request\nbody and parameters are validated, so a restricted application returns this error even\nfor a malformed request.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}}}},"paths":{"/rest/3.0/sendBulkEmail":{"post":{"operationId":"sendBulkEmail","tags":["Email and SMS"],"summary":"Send Bulk Email","description":"Sends an email template created in the Netmera panel to an audience, referenced by its template ID.\nUse it when an external system, such as a CRM, manages the content and passes send-time values to\nNetmera, so the template does not need to be updated in the panel for each campaign.\n\n{% hint style=\"danger\" %}\n**Requests sent from Test it are real.** Test it opens a request panel; pressing **Send** in\nthat panel calls the live API with the key you enter. With a production API key the template\ngoes to every user the target matches, and `sendToAll: true` reaches all users of the app. Use\na test application's key, or target a tag that only your test users carry. The default\nexample targets the `test-users` tag and returns HTTP 400, code `2009`, if the tag does not\nexist.\n{% endhint %}\n\n### Capabilities\n\n- **Bulk email delivery** — Send emails to a target audience instead of a single user.\n- **Template ID-based sending** — Trigger a template created in the Netmera panel by its ID.\n- **Campaign-level custom parameters** — Pass key-value pairs that fill placeholders defined in the\n  template.\n- **Attachment support** — Attach files to the email when needed.\n\n### How it works\n\n1. Create the email template in the Netmera panel. It can contain placeholders such as `{DATE}`,\n   `{TITLE}`, `{CONTENT}` or `{PDF_URL}`.\n2. Call this endpoint with the template ID and matching keys in `customParams`.\n3. Netmera replaces each placeholder with the matching value at send time.\n\n<details>\n\n<summary>Notes</summary>\n\n- The email template must exist in the Netmera panel before you trigger it through the API.\n- A placeholder with no matching key in `customParams` renders as empty in the delivered email.\n- `emailIysMessageType` is checked only after the template is found. With an unknown\n  `emailTemplateId`, the template error is returned first, whatever the `emailIysMessageType` value.\n- `emailIysMessageType` is case-insensitive and is used only when the template has no email type of\n  its own.\n- In that case, an invalid value returns HTTP 400, code `2004`, \"emailIysMessageType must be one of:\n  N, NOTIFICATION, C, CAMPAIGN, CAMPAIGN_ADVERTISEMENT\".\n- When neither the template nor the request sets a type, the email is sent as\n  `CAMPAIGN_ADVERTISEMENT`.\n\n</details>\n","parameters":[{"name":"X-netmera-api-caller","in":"header","required":false,"description":"Optional free-text name recorded as the creator of the message. When omitted, the\nmessage is recorded as created through the REST API.\n","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["emailTemplateId"],"properties":{"emailTemplateId":{"type":"integer","description":"The ID of the email template to trigger."},"subject":{"type":"string","description":"Email subject for this send; the template subject is used when omitted. Must not contain\nHTML tags or line breaks (HTTP 400, code `2004`).\n"},"customParams":{"type":"object","description":"Key-value pairs that map to placeholders defined in the template.\n","additionalProperties":true},"sendToAll":{"type":"boolean","description":"Set to true to send to all users. A target is required: `sendToAll: true`,\nor `target.tag` / `target.segment`; otherwise the call fails with HTTP 400 and\ncode `2020`.\n"},"target":{"type":"object","description":"Audience of the email. Precedence is `target.tag`, then `target.segment`, then\n`sendToAll`; the top-level `sendToAll` overrides `target.sendToAll`.\n","properties":{"sendToAll":{"type":"boolean","description":"Set to `true` to send to all users.\n"},"tag":{"$ref":"#/components/schemas/TargetOperatorList","description":"Tag name, an array of tag names (OR), or an object with `$and`, `$or` or\n`$not`. An unknown tag returns HTTP 400 with code `2009`.\n"},"segment":{"$ref":"#/components/schemas/TargetOperatorList","description":"Segment name, an array of segment names (OR), or an object with `$and`,\n`$or` or `$not`. Ignored when `target.tag` is sent.\n"}}},"msgSchedule":{"type":"object","description":"Delivery schedule of the email.\n","properties":{"scheduleType":{"type":"string","enum":["NOW","SPECIFIC_TIME","BEST_TIME"],"description":"Scheduling mode. Case-sensitive.\n"},"startDate":{"description":"Send date, as epoch milliseconds or an ISO-8601 date-time string. A date in\nthe past is not rejected.\n","oneOf":[{"type":"integer","format":"int64","description":"epoch milliseconds\n"},{"type":"string","format":"date-time"}]},"basedOnUserTimezone":{"type":"boolean","description":"Whether the schedule is based on the user's time zone.\n"},"timeZoneHourOffset":{"type":"number","description":"Time zone offset, in hours.\n"},"sendImmediatelyIfBestTimePassed":{"type":"boolean","default":false,"description":"With `BEST_TIME`, whether the email is sent immediately when the user's best\ntime has already passed. Defaults to `false`.\n"}}},"attachmentUrls":{"type":"array","description":"URLs of files to attach. Netmera downloads the files at send time; their total\nsize must not exceed 25 MB, and executable or script files are rejected.\n","items":{"type":"string","format":"uri"}},"extRef":{"type":"string","description":"External reference of the email in your own system. Returned in the response; it\nis not stored on the message.\n"},"categories":{"type":"array","description":"Message category IDs, sent as strings (for example `\"12\"`). A non-numeric value\nreturns HTTP 400 with code `2001`; whether the category exists is not checked.\n","items":{"type":"string"}},"labels":{"type":"array","description":"Accepted but currently ignored.\n","items":{"type":"string"}},"emailIysMessageType":{"type":"string","enum":["N","NOTIFICATION","C","CAMPAIGN","CAMPAIGN_ADVERTISEMENT"],"default":"CAMPAIGN_ADVERTISEMENT","description":"IYS message type, case-insensitive: `N` or `NOTIFICATION` for Notification, `C` or\n`CAMPAIGN` for Campaign, or `CAMPAIGN_ADVERTISEMENT`. Used only when the template has no\nemail type of its own.\n"}}}}}},"responses":{"200":{"description":"The bulk email was accepted for delivery.","content":{"application/json":{"schema":{"type":"object","properties":{"notificationKey":{"type":"integer","description":"Identifier of the created email message."},"extRef":{"type":"string","description":"Echo of the request `extRef`, present when one was sent."}}}}}},"400":{"description":"Missing or unknown template.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NetmeraError"}}}},"401":{"$ref":"#/components/responses/InvalidApiKey"},"403":{"$ref":"#/components/responses/IpNotAllowed"},"415":{"description":"Error responses the API can return.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}}}}
```


---

# 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/api-reference/email-and-sms/send-bulk-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.
