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

# Send Email with Template

> Send an email using a pre-configured template with dynamic merge fields.

<ParamField body="template_key" type="string" required>
  The unique key of the template to use.
</ParamField>

<ParamField body="from" type="object" required>
  Sender details.

  <Expandable title="from properties">
    <ParamField body="from.address" type="string" required>
      Sender email address. Must be from a verified domain.
    </ParamField>

    <ParamField body="from.name" type="string">
      Sender display name.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="to" type="array" required>
  Array of recipient objects.

  <Expandable title="recipient properties">
    <ParamField body="email_address.address" type="string" required>
      Recipient email address.
    </ParamField>

    <ParamField body="email_address.name" type="string">
      Recipient display name.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="merge_info" type="object">
  Key-value pairs for template variable substitution. Example: `{"first_name": "John", "order_id": "12345"}`.
</ParamField>

<ParamField body="reply_to" type="object">
  Reply-to address with `address` and optional `name`.
</ParamField>

<ParamField body="cc" type="array">
  CC recipients. Same structure as `to`.
</ParamField>

<ParamField body="bcc" type="array">
  BCC recipients. Same structure as `to`.
</ParamField>

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.unosend.co/v1/email/template \
    -H "Authorization: Bearer un_xxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "template_key": "welcome-email",
      "from": {
        "address": "hello@yourdomain.com",
        "name": "Your App"
      },
      "to": [
        {
          "email_address": {
            "address": "user@example.com",
            "name": "John Doe"
          }
        }
      ],
      "merge_info": {
        "first_name": "John",
        "activation_link": "https://yourapp.com/activate/abc123"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch('https://api.unosend.co/v1/email/template', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer un_xxxxxxxxxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      template_key: 'welcome-email',
      from: { address: 'hello@yourdomain.com', name: 'Your App' },
      to: [{ email_address: { address: 'user@example.com', name: 'John Doe' } }],
      merge_info: { first_name: 'John', activation_link: 'https://yourapp.com/activate/abc123' }
    })
  });
  ```

  ```python Python theme={null}
  import requests

  requests.post('https://api.unosend.co/v1/email/template',
    headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
    json={
      'template_key': 'welcome-email',
      'from': {'address': 'hello@yourdomain.com', 'name': 'Your App'},
      'to': [{'email_address': {'address': 'user@example.com', 'name': 'John Doe'}}],
      'merge_info': {'first_name': 'John', 'activation_link': 'https://yourapp.com/activate/abc123'}
    }
  )
  ```
</CodeGroup>

### Response

```json 200 theme={null}
{
  "message": "OK",
  "request_id": "req_abc123def456",
  "data": {
    "message_id": "msg_550e8400e29b41d4"
  }
}
```

<Note>
  Template variables use the `{{variable_name}}` syntax. Make sure all required variables in the template are provided in `merge_info`.
</Note>
