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

# Send Email

> Sends a transactional or marketing email. Either templateId OR html/text content must be provided. If using a template, subject is optional.

export const APP_PATHS = {
  home: '/',
  quickstart: '/quickstart',
  domainConfiguration: '/domain',
  apiReference: '/api-reference',
  sendEmail: '/api-reference/mails/send',
  bulkSendEmail: '/api-reference/mails/bulk',
  upsertContactApiRef: '/api-reference/contacts/upsert-contact',
  transactional: '/transactional-emails',
  emailActivity: '/transactional-emails/email-activity',
  emailTemplates: '/transactional-emails/email-templates',
  sendingEmail: '/quickstart/email-using-api',
  transactionalTroubleshooting: '/transactional-emails/troubleshooting',
  marketing: '/marketing-emails',
  campaigns: '/marketing-emails/campaigns',
  contacts: '/marketing-emails/contacts',
  contactsIntroduction: '/marketing-emails/contacts/introduction',
  contactsImportCsv: '/marketing-emails/contacts/import-csv',
  contactsLists: '/marketing-emails/contacts/lists',
  contactsSegments: '/marketing-emails/contacts/segments',
  contactsCustomFields: '/marketing-emails/contacts/custom-fields',
  sender: '/marketing-emails/sender',
  unsubscribeGroups: '/others/unsubscribe-groups',
  webhookIntroduction: '/others/webhooks/introduction',
  webhookEventType: '/others/webhooks/event-type',
  webhookRetries: '/others/webhooks/retries',
  webhookVerifyRequests: '/others/webhooks/verify-requests',
  dynamicTemplates: '/dynamic-templates',
  guides: '/guides',
  sitemap: '/sitemap.xml',
  team: '/others/team',
  automations: '/automations',
  smtpIntroduction: '/quickstart/smtp',
  betterAuth: '/guides/better-auth',
  templateVariables: '/transactional-emails/variables',
  suppressions: '/others/suppressions',
  rateLimit: '/api-reference/rate-limit',
  nodejsSdk: '/sdk/nodejs',
  smtpIntegrationGuides: '/guides/smtp',
  apiKeys: '/api-keys',
  apiReferenceIntroduction: '/api-reference/introduction',
  lovableGuide: '/ai/integrations/lovable',
  aiIntroduction: '/ai/introduction',
  aiSkills: '/ai/skills',
  aiMcpServer: '/ai/mcp-server',
  aiLovable: '/ai/integrations/lovable',
  aiBolt: '/ai/integrations/bolt',
  aiV0: '/ai/integrations/v0',
  aiReplit: '/ai/integrations/replit',
  mcpClaude: '/ai/mcp-clients/claude',
  mcpCursor: '/ai/mcp-clients/cursor',
  mcpCopilot: '/ai/mcp-clients/copilot',
  mcpWindsurf: '/ai/mcp-clients/windsurf',
  mcpCodex: '/ai/mcp-clients/codex',
  mcpAntigravity: '/ai/mcp-clients/antigravity',
  mcpChatgpt: '/ai/mcp-clients/chatgpt',
  mcpRaycast: '/ai/mcp-clients/raycast',
  domainWarmup: '/marketing-emails/domain-warmup',
  projects: '/projects',
  createAutomationApi: '/api-reference/automations/create-automation'
};

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.autosend.com/v1/mails/send \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
    "to": {
      "email": "to@example.com",
      "name": "Jane Smith"
    },
    "cc": [
        {"email": "cc1@example.com", "name": "CC User 1"},
        {"email": "cc2@example.com", "name": "CC User 2"}
      ],
    "bcc": [{"email": "bcc@example.com"}],
    "from": {
      "email": "from@yourdomain.com",
      "name": "Your Company"
    },
    "subject": "Welcome to Our Platform!",
    "html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
    "dynamicData": {
      "name": "Jane"
    },
    "replyTo": {
      "email": "to@example.com"
    }
  }'
  ```

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

  url = "https://api.autosend.com/v1/mails/send"

  headers = {
      "Authorization": "Bearer <token>",
      "Content-Type": "application/json"
  }

  payload = {
      "to": {
          "email": "to@example.com",
          "name": "Jane Smith"
      },
      "cc": [
        {"email": "cc1@example.com", "name": "CC User 1"},
        {"email": "cc2@example.com", "name": "CC User 2"}
      ],
      "bcc": [{"email": "bcc@example.com"}],
      "from": {
          "email": "from@example.com",
          "name": "Your Company"
      },
      "subject": "Welcome to Our Platform!",
      "html": "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
      "dynamicData": {
          "name": "Jane"
      },
      "replyTo": {
          "email": "to@example.com"
      }
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  fetch('https://api.autosend.com/v1/mails/send', {
  	method: 'POST',
  	headers: {
  		Authorization: 'Bearer <token>',
  		'Content-Type': 'application/json',
  	},
  	body: JSON.stringify({
  		to: {
  			email: 'to@example.com',
  			name: 'Jane Smith',
  		},
  		from: {
  			email: 'from@example.com',
  			name: 'Your Company',
  		},
  		subject: 'Welcome to Our Platform!',
  		html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
  		dynamicData: {
  			name: 'Jane',
  		},
  		replyTo: {
  			email: 'to@example.com',
  		},
  	}),
  })
  	.then((response) => response.json())
  	.then((data) => console.log(data))
  	.catch((error) => console.error('Error:', error));
  ```

  ```php PHP theme={null}
  <?php

  $url = 'https://api.autosend.com/v1/mails/send';

  $data = [
      'to' => [
          'email' => 'to@example.com',
          'name' => 'Jane Smith'
      ],
      'from' => [
          'email' => 'from@example.com',
          'name' => 'Your Company'
      ],
      'subject' => 'Welcome to Our Platform!',
      'html' => '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
      'dynamicData' => [
          'name' => 'Jane'
      ],
      'replyTo' => [
          'email' => 'to@example.com'
      ]
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'Authorization: Bearer <token>',
      'Content-Type: application/json'
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      url := "https://api.autosend.com/v1/mails/send"

      payload := map[string]interface{}{
          "to": map[string]string{
              "email": "to@example.com",
              "name":  "Jane Smith",
          },
          "from": map[string]string{
              "email": "from@example.com",
              "name":  "Your Company",
          },
          "subject": "Welcome to Our Platform!",
          "html":     "<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>",
          "dynamicData": map[string]string{
              "name": "Jane",
          },
          "replyTo": map[string]string{
              "email": "to@example.com",
          },
      }

      jsonData, _ := json.Marshal(payload)

      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", "Bearer <token>")
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println("Error:", err)
          return
      }
      defer resp.Body.Close()

      fmt.Println("Response Status:", resp.Status)
  }
  ```

  ```java Java theme={null}
  import java.io.OutputStream;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.nio.charset.StandardCharsets;

  public class SendEmail {
      public static void main(String[] args) {
          try {
              URL url = new URL("https://api.autosend.com/v1/mails/send");
              HttpURLConnection con = (HttpURLConnection) url.openConnection();

              con.setRequestMethod("POST");
              con.setRequestProperty("Authorization", "Bearer <token>");
              con.setRequestProperty("Content-Type", "application/json");
              con.setDoOutput(true);

              String jsonInputString = "{\n" +
                  "  \"to\": {\n" +
                  "    \"email\": \"to@example.com\",\n" +
                  "    \"name\": \"Jane Smith\"\n" +
                  "  },\n" +
                  "  \"from\": {\n" +
                  "    \"email\": \"from@example.com\",\n" +
                  "    \"name\": \"Your Company\"\n" +
                  "  },\n" +
                  "  \"subject\": \"Welcome to Our Platform!\",\n" +
                  "  \"html\": \"<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>\",\n" +
                  "  \"dynamicData\": {\n" +
                  "    \"name\": \"Jane\"\n" +
                  "  },\n" +
                  "  \"replyTo\": {\n" +
                  "    \"email\": \"to@example.com\"\n" +
                  "  }\n" +
                  "}";

              try (OutputStream os = con.getOutputStream()) {
                  byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                  os.write(input, 0, input.length);
              }

              int status = con.getResponseCode();
              System.out.println("Response Status: " + status);

          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  ```

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

  uri = URI('https://api.autosend.com/v1/mails/send')

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri.path)
  request['Authorization'] = 'Bearer <token>'
  request['Content-Type'] = 'application/json'

  request.body = {
    to: {
      email: 'to@example.com',
      name: 'Jane Smith'
    },
    from: {
      email: 'from@example.com',
      name: 'Your Company'
    },
    subject: 'Welcome to Our Platform!',
    html: '<h1>Welcome, {{name}}!</h1><p>Thanks for signing up.</p>',
    dynamicData: {
      name: 'Jane'
    },
    replyTo: {
      email: 'to@example.com'
    }
  }.to_json

  response = http.request(request)
  puts response.body
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
  	"success": true,
  	"data": {
  		"emailId": "698afb75ff4bc5466e3a797a",
  		"message": "Email queued successfully.",
  		"totalRecipients": 1
  	}
  }
  ```
</ResponseExample>

***

### Authorizations

<ParamField path="Authorizations" type="string | header" required>
  Bearer authentication header of the form Bearer `<token>`, where `<token>` is your auth token.
</ParamField>

### Body

Email data to send

<ParamField path="to" type="object" required>
  Recipient email address and name

  <Expandable title="child attributes">
    <ParamField path="to.email" type="string<email>" required>
      Email address

      Example: `"to@example.com"`
    </ParamField>

    <ParamField path="to.name" type="string">
      Display name

      Example: `"Jane Smith"`
    </ParamField>
  </Expandable>

  <Info>
    To send to multiple recipients, use the <a href={APP_PATHS.bulkSendEmail}>send bulk email</a>{' '}
    endpoint.
  </Info>
</ParamField>

<ParamField path="cc" type="object[]">
  Cc Recipients array of email address and name object

  <Expandable title="child attributes">
    <ParamField path="email" type="string<email>" required>
      Email address

      Example: `"cc@example.com"`
    </ParamField>

    <ParamField path="name" type="string">
      Cc User name

      Example: `"Cc User Name"`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="bcc" type="object[]">
  Bcc Recipients array of email address and name object

  <Expandable title="child attributes">
    <ParamField path="email" type="string<email>" required>
      Email address

      Example: `"bcc@example.com"`
    </ParamField>

    <ParamField path="name" type="string">
      Bcc User name

      Example: `"Bcc User Name"`
    </ParamField>
  </Expandable>

  <Info>
    The total combined recipients across `to`, `cc`, and `bcc` cannot exceed 50 per email.
  </Info>
</ParamField>

<ParamField path="from" type="object" required>
  Sender email address (must be from a verified domain) and name

  <Expandable title="child attributes">
    <ParamField path="from.email" type="string<email>" required>
      Email address

      Example: `"from@example.com"`
    </ParamField>

    <ParamField path="from.name" type="string">
      Display name

      Example: `"Your Company"`
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="subject" type="string" required>
  Email subject line (max 998 characters). Required if not using templateId. Maximum length: `998`
  Example: `"Welcome to Our Platform!"`
</ParamField>

<ParamField path="html" type="string">
  HTML content of the email. Required if not using templateId. **Handlebars Template Variables:**
  Use Handlebars syntax for template variables in your HTML. Variables are wrapped in double curly
  braces: `{{ variableName }}`. Example: `html 	<h1>Hello {{ firstName }}!</h1> 	<p>Your order #{{ orderNumber }} has been shipped.</p> 	<p>Total: {{ orderTotal }}</p>
    	` Provide the values for these variables in the `dynamicData` field. Example: `jsx html: " 	<p>Hello {{ firstName }}! Sending this email via AutoSend.</p>" `
</ParamField>

<ParamField path="dynamicData" type="object">
  Key-value pairs for template variable substitution (Handlebars syntax)

  Example:

  ```jsx theme={null}
  dynamicData: {
    "name": "Jane",
    "firstName": "Jane",
    "orderNumber": "ORD-12345",
    "orderTotal": "$99.99"
  }
  ```
</ParamField>

<ParamField path="text" type="string">
  Plain text version of the email Example: `"Welcome! Thanks for signing up."`
</ParamField>

<ParamField path="templateId" type="string">
  ID of the email template to use. Required if not providing html/text. Example: `"A-abc123"`
</ParamField>

<ParamField path="replyTo" type="object">
  Reply-to email address and name

  <Expandable title="child attributes">
    <ParamField path="replyTo.email" type="string<email>" required>
      Email address

      Example: `"customer@example.com"`
    </ParamField>

    <ParamField path="replyTo.name" type="string">
      Display name

      Example: `"John Doe"`
    </ParamField>

    <ParamField path="replyTo.dynamicData" type="object">
      Key-value pairs for template variable substitution (Handlebars syntax)

      Example:

      ```jsx theme={null}
      {
          "name": "Jane",
          "firstName": "Jane",
          "orderNumber": "ORD-12345",
          "orderTotal": "$99.99"
      }
      ```
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="unsubscribeGroupId" type="string">
  ID of the unsubscribe group Example: `"unsub_group_123"`
</ParamField>

<ParamField path="trackingClick" type="boolean">
  Enable or disable click tracking for links in the email. When enabled, links are rewritten so clicks can be tracked. If omitted, the project-level setting configured in your AutoSend dashboard is used.

  Example: `false`
</ParamField>

<ParamField path="trackingOpen" type="boolean">
  Enable or disable open tracking for the email. When enabled, a tracking pixel is added to record opens. If omitted, the project-level setting configured in your AutoSend dashboard is used.

  Example: `false`
</ParamField>

<ParamField path="headers" type="object">
  Custom email headers to include with the message as key-value pairs.

  <Note>
    * Maximum 20 custom headers per email.
    * Header names must match `^[A-Za-z0-9-]{1,76}$` (ASCII letters, digits, and hyphens, up to 76 characters).
    * Header values can be up to 1000 characters.
    * Reserved headers managed by AutoSend or the underlying mail transport cannot be overridden, including: `From`, `To`, `Cc`, `Bcc`, `Subject`, `Date`, `Message-ID`, `Return-Path`, `Sender`, `Reply-To`, `Received`, `DKIM-Signature`, `MIME-Version`, `Content-Type`, `Content-Transfer-Encoding`, `List-Unsubscribe`, `List-Unsubscribe-Post`, `X-SES-Configuration-Set`, and `X-SES-Message-Tags`.
  </Note>

  Example:

  ```jsx theme={null}
  headers: {
    "X-Entity-Ref-ID": "order-12345",
    "X-Campaign-ID": "welcome-series"
  }
  ```
</ParamField>

<ParamField path="attachments" type="object[]">
  Filename and content of attachments.

  <Note>
    Maximum 20 files can be attached to an email. The total size of the email should be max 40MB after Base64 encoding of the attachments.
  </Note>

  <Expandable title="child attributes">
    <ParamField path="fileName" type="string" required>
      Filename of the attachment

      Example: `"attachment.pdf"`
    </ParamField>

    <ParamField path="content" type="string">
      Base64-encoded content of the attachment
    </ParamField>

    <ParamField path="contentType" type="string">
      Content type of the attachment (e.g. application/pdf, image/png, image/jpeg)
    </ParamField>

    <ParamField path="fileUrl" type="string">
      File URL where the attachment is hosted (required if content is not provided)
    </ParamField>

    <ParamField path="description" type="string">
      Description of the attachment (optional)
    </ParamField>
  </Expandable>

  <Expandable title="all supported types">
    `.adp`	`.app`	`.asp`	`.bas`	`.bat`
    `.cer`	`.chm`	`.cmd`	`.com`	`.cpl`
    `.crt`	`.csh`	`.der`	`.exe`	`.fxp`
    `.gadget`	`.hlp`	`.hta`	`.inf`	`.ins`
    `.isp`	`.its`	`.js`	`.jse`	`.ksh`
    `.lib`	`.lnk`	`.mad`	`.maf`	`.mag`
    `.mam`	`.maq`	`.mar`	`.mas`	`.mat`
    `.mau`	`.mav`	`.maw`	`.mda`	`.mdb`
    `.mde`	`.mdt`	`.mdw`	`.mdz`	`.msc`
    `.msh`	`.msh1`	`.msh2`	`.mshxml`	`.msh1xml`
    `.msh2xml`	`.msi`	`.msp`	`.mst`	`.ops`
    `.pcd`	`.pif`	`.plg`	`.prf`	`.prg`
    `.reg`	`.scf`	`.scr`	`.sct`	`.shb`
    `.shs`	`.sys`	`.ps1`	`.ps1xml`	`.ps2`
    `.ps2xml`	`.psc1`	`.psc2`	`.tmp`	`.url`
    `.vb`	`.vbe`	`.vbs`	`.vps`	`.vsmacros`
    `.vss`	`.vst`	`.vsw`	`.vxd`	`.ws`
    `.wsc`	`.wsf`	`.wsh`	`.xnk`
  </Expandable>

  Example:

  ```jsx theme={null}
  attachments: [
    {
      "fileName": "attachment.pdf",
      "content": "base64-encoded-content",
      "contentType": "application/pdf"
    }
  ]
  ```
</ParamField>

### Response

<span className="text-sm">Email queued successfully</span>

<ResponseField name="success" type="boolean">
  Indicates if the request was successful Example: `true`
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="child attributes">
    <ResponseField name="data.emailId" type="string">
      The ID of the queued email Example: `"698afb75ff4bc5466e3a797a"`
    </ResponseField>

    <ResponseField name="data.message" type="string">
      Success message indicating the email was queued Example: `"Email queued successfully."`
    </ResponseField>

    <ResponseField name="data.totalRecipients" type="number">
      Total number of recipients for the email Example: `1`
    </ResponseField>
  </Expandable>
</ResponseField>


## OpenAPI

````yaml POST /mails/send
openapi: 3.1.0
info:
  title: AutoSend API
  description: AutoSend REST API for managing contacts and sending emails
  version: 1.0.0
servers:
  - url: https://api.autosend.com/v1
security:
  - bearerAuth: []
paths:
  /mails/send:
    post:
      summary: Send Email
      description: >-
        Sends a transactional or marketing email. Either templateId OR html/text
        content must be provided. If using a template, subject is optional.
components: {}

````