> ## 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

> Send an email to one or more recipients.

<ParamField body="from" type="string" required>
  Sender email address. Must be from a verified domain. Can include a name: `"John Doe <john@yourdomain.com>"`.
</ParamField>

<ParamField body="to" type="string | string[]" required>
  Recipient email address(es).
</ParamField>

<ParamField body="subject" type="string" required>
  Email subject line.
</ParamField>

<ParamField body="html" type="string">
  HTML content of the email. Required unless `text` or `template_id` is provided.
</ParamField>

<ParamField body="text" type="string">
  Plain text content of the email.
</ParamField>

<ParamField body="template_id" type="string">
  UUID of a saved template to use. If provided, the template's content will be used.
</ParamField>

<ParamField body="template_data" type="object">
  Variables to replace in the template. Example: `{"first_name": "John", "order_id": "12345"}`.
</ParamField>

<ParamField body="cc" type="string | string[]">
  CC recipient(s).
</ParamField>

<ParamField body="bcc" type="string | string[]">
  BCC recipient(s).
</ParamField>

<ParamField body="reply_to" type="string">
  Reply-to email address.
</ParamField>

<ParamField body="priority" type="string">
  Email priority: `high` (OTP/transactional, fastest delivery), `normal` (default), or `low` (bulk/marketing).
</ParamField>

<ParamField body="attachments" type="array">
  Array of attachments. Each attachment has `filename`, `content` (base64), and `content_type`.
</ParamField>

<ParamField body="headers" type="object">
  Custom email headers.
</ParamField>

<ParamField body="tags" type="array">
  Custom tags for analytics. Each tag has `name` and `value`.
</ParamField>

<ParamField body="scheduled_for" type="string">
  ISO 8601 datetime for scheduled sending.
</ParamField>

<ParamField body="tracking" type="object">
  Control email tracking behavior.

  <Expandable title="tracking properties">
    <ParamField body="tracking.open" type="boolean" default="true">
      Enable open tracking. When `true`, a 1x1 invisible pixel is added to track email opens.
    </ParamField>

    <ParamField body="tracking.click" type="boolean" default="true">
      Enable click tracking. When `true`, links are rewritten to track clicks.
    </ParamField>
  </Expandable>
</ParamField>

### Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.unosend.co/emails \
    -H "Authorization: Bearer un_xxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "from": "hello@yourdomain.com",
      "to": ["user@example.com"],
      "subject": "Hello World",
      "html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
      "tracking": {
        "open": true,
        "click": false
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch('https://api.unosend.co/emails', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer un_xxxxxxxxxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      from: 'hello@yourdomain.com',
      to: ['user@example.com'],
      subject: 'Hello World',
      html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
      tracking: {
        open: true,
        click: false
      }
    })
  });
  ```

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

  requests.post('https://api.unosend.co/emails',
    headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
    json={
      'from': 'hello@yourdomain.com',
      'to': ['user@example.com'],
      'subject': 'Hello World',
      'html': '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
      'tracking': {
        'open': True,
        'click': False
      }
    }
  )
  ```

  ```go Go theme={null}
  payload := map[string]interface{}{
    "from": "hello@yourdomain.com",
    "to": []string{"user@example.com"},
    "subject": "Hello World",
    "html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
    "tracking": map[string]bool{
      "open": true,
      "click": false,
    },
  }
  body, _ := json.Marshal(payload)
  req, _ := http.NewRequest("POST", "https://api.unosend.co/emails", bytes.NewBuffer(body))
  req.Header.Set("Authorization", "Bearer un_xxxxxxxxxx")
  req.Header.Set("Content-Type", "application/json")
  ```

  ```php PHP theme={null}
  $ch = curl_init('https://api.unosend.co/emails');
  curl_setopt_array($ch, [
      CURLOPT_POST => true,
      CURLOPT_HTTPHEADER => ['Authorization: Bearer un_xxxxxxxxxx', 'Content-Type: application/json'],
      CURLOPT_POSTFIELDS => json_encode([
          'from' => 'hello@yourdomain.com',
          'to' => ['user@example.com'],
          'subject' => 'Hello World',
          'html' => '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
          'tracking' => [
              'open' => true,
              'click' => false
          ]
      ])
  ]);
  curl_exec($ch);
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'

  uri = URI('https://api.unosend.co/emails')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = 'Bearer un_xxxxxxxxxx'
  request['Content-Type'] = 'application/json'
  request.body = {
    from: 'hello@yourdomain.com',
    to: ['user@example.com'],
    subject: 'Hello World',
    html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>'
  }.to_json

  http.request(request)
  ```
</CodeGroup>

### Response

```json 200 theme={null}
{
  "success": true,
  "data": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "from": "hello@yourdomain.com",
    "to": ["user@example.com"],
    "status": "queued",
    "created_at": "2024-01-15T10:30:00.000Z"
  }
}
```
