> ## Documentation Index
> Fetch the complete documentation index at: https://docs.isend.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Email

> Sends a templated email to a recipient using dynamic data.

# Send Email

> Send templated emails through the iSend API using dynamic placeholders with a single API call.

## Endpoint

`POST https://api.isend.ai/emails/send`

## Headers

* **Authorization** (string, required): Bearer token using your API key.\
  Example: `Authorization: Bearer is_xxxxxxx`
* **Content-Type**: `application/json`

## Request Body Parameters

| Field          | Type                | Required | Description                                                     |
| -------------- | ------------------- | -------- | --------------------------------------------------------------- |
| `from`         | `string`            | ✅        | Sender's email. Use `name <email@domain.com>` format if needed. |
| `to`           | `string` or `array` | ✅        | Email or array of emails for recipients.                        |
| `template`     | `string`            | ✅        | Identifier or name of the template to send.                     |
| `data_mapping` | `object`            | ✅        | Dynamic placeholder values to inject into the template.         |

***

## Sample Request

```json theme={null}
{
  "from": "your@email.com",
  "to": "delivered@isend.dev",
  "template": "welcome_emailer",
  "data_mapping": {
    "name": "John Doe",
    "email": "john@example.com"
  }
}
```

***

## Sample Response

```json theme={null}
{
  "id": "abc1234-def5-6789-xyz-00000000",
  "status": "success"
}
```

***

## PHP SDK Example

```php theme={null}
<?php
$client = new isend('YOUR_API_KEY');
$client->emails->send([
  'from' => 'your@email.com',
  'to' => 'delivered@isend.dev',
  'template' => 'welcome_emailer',
  'data_mapping' => [
    'name' => 'John Doe',
    'email' => 'john@example.com'
  ]
]);
```

***

## Notes

* Ensure the `template` exists and is active on your account.
* `data_mapping` must match the placeholders used in your template.
* You may use an array for `to` if you want to send to multiple recipients.


## OpenAPI

````yaml POST /api/send-email
openapi: 3.1.0
info:
  title: Generated API from MDX
  version: 1.0.0
servers:
  - url: https://api.example.com
security: []
paths:
  /api/send-email:
    post:
      summary: Send an email
      description: Sends a templated email to a recipient using dynamic data.
      responses:
        '200':
          description: Successful response
      x-codeSamples:
        - lang: PHP
          label: PHP
          source: |-
            <?php
            $client = new isend('YOUR_API_KEY');
            $client->emails->send([
              'from' => 'your@email.com',
              'to' => 'delivered@isend.dev',
              'template' => 'welcome_emailer',
              'data_mapping' => [
                'name' => 'John Doe',
                'email' => 'john@example.com'
              ]
            ]);
        - lang: Python
          label: Python
          source: >-
            import requests


            headers = {
                "Authorization": "Bearer YOUR_API_KEY",
                "Content-Type": "application/json"
            }


            data = {
                "from": "your@email.com",
                "to": "delivered@isend.dev",
                "template": "welcome_emailer",
                "data_mapping": {
                    "name": "John Doe",
                    "email": "john@example.com"
                }
            }


            response = requests.post("https://api.example.com/api/send-email",
            json=data, headers=headers)

            print(response.json())
        - lang: Node.js
          label: Node.js
          source: >-
            const axios = require('axios');


            const response = await
            axios.post('https://api.example.com/api/send-email', {
              from: 'your@email.com',
              to: 'delivered@isend.dev',
              template: 'welcome_emailer',
              data_mapping: {
                name: 'John Doe',
                email: 'john@example.com'
              }
            }, {
              headers: {
                'Authorization': 'Bearer YOUR_API_KEY',
                'Content-Type': 'application/json'
              }
            });


            console.log(response.data);
        - lang: Java
          label: Java
          source: >-
            OkHttpClient client = new OkHttpClient();


            MediaType mediaType = MediaType.parse("application/json");

            RequestBody body = RequestBody.create(mediaType,
            "{\"from\":\"your@email.com\",\"to\":\"delivered@isend.dev\",\"template\":\"welcome_emailer\",\"data_mapping\":{\"name\":\"John
            Doe\",\"email\":\"john@example.com\"}}");


            Request request = new Request.Builder()
              .url("https://api.example.com/api/send-email")
              .post(body)
              .addHeader("Authorization", "Bearer YOUR_API_KEY")
              .addHeader("Content-Type", "application/json")
              .build();

            Response response = client.newCall(request).execute();
        - lang: Ruby
          label: Ruby
          source: |-
            require 'net/http'
            require 'uri'
            require 'json'

            uri = URI.parse("https://api.example.com/api/send-email")
            header = {
              'Content-Type': 'application/json',
              'Authorization': 'Bearer YOUR_API_KEY'
            }

            body = {
              from: 'your@email.com',
              to: 'delivered@isend.dev',
              template: 'welcome_emailer',
              data_mapping: {
                name: 'John Doe',
                email: 'john@example.com'
              }
            }

            http = Net::HTTP.new(uri.host, uri.port)
            http.use_ssl = true
            request = Net::HTTP::Post.new(uri.request_uri, header)
            request.body = body.to_json

            response = http.request(request)
            puts response.body
        - lang: cURL
          label: cURL
          source: |-
            curl -X POST https://api.example.com/api/send-email \
              -H "Authorization: Bearer YOUR_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "from": "your@email.com",
                "to": "delivered@isend.dev",
                "template": "welcome_emailer",
                "data_mapping": {
                  "name": "John Doe",
                  "email": "john@example.com"
                }
              }'

````