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

# Email Message Reference

<CodeGroup>
  ```typescript Javascript SDK highlight={2,8-9,12-13} theme={"dark"}
  const ensend = new Client({
    secret: "your_project_secret",
  });

  const { data, error } = await ensend.SendApi.SendMailMessage({
    subject: "Ensend Test Email",
    sender: {
      name: "your_identity_name",
      address: "your_sender_identity"
    },
    recipients: [{
      name: "your_recipient_name",
      address: "your_recipient_address"
    }],
     message: "<b>It works 🎉</b>",
    // ...see additional fields below
  });
  ```

  ```go Golang SDK theme={"dark"}
  import "github.com/express-labs/ensend-client-go"
  client := ensend.New(option.WithProjectSecret("your_project_secret"))
  ```

  ```shellscript Rest API highlight={2,7-8,11-12} theme={"dark"}
  curl -X POST 'https://api.ensend.co/send/mail' \
    -H 'Authorization: Bearer <your_project_secret>' \
    -H 'Content-Type: application/json' \
    -d '{
      "subject": "Ensend Test Email",
      "sender": {
        "name": "your_identity_name",
        "address": "your_sender_identity"
      },
      "recipients": [{
        "name": "your_recipient_name",
        "address": "your_recipient_address"
      }],
      "message": "<b>It works 🎉</b>"
      # ...see additional fields below
    }'
  ```
</CodeGroup>

## Request Body

<ParamField path="subject" type="string" required>
  The subject line of the email as it should appear in recipients’ inbox.
</ParamField>

<ParamField path="preheader" type="string (optional)">
  The text that appears below the subject line in notifications from inbox clients (like Gmail, Outlook, Apple Mail). This is perfect for sensitive message previews like OTPs in notification.
</ParamField>

<ParamField path="sender" type="object" required>
  <Expandable title="Child Attributes" defaultOpen>
    <ParamField path="name" type="string">
      The name of the sender as it should appear in recipients' inbox.

      If a name is not provided, the `username` part of the sender address is used. Example: `hello` becomes the sender name for [hello@ensend.co](mailto:hello@ensend.co).
    </ParamField>

    <ParamField path="address" type="string" required>
      The email address of the sender as it should appear in recipients' inbox.

      The sender address can any of the sender identities available to your project. [Learn more about creating a sender identity.](/credentials#sender-identities)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="message" type="string (optional if using template)">
  The body of the email as it should appear in recipients’ inbox. This can either be in `plaintext` or `html` format.
</ParamField>

<ParamField path="template" type="object (optional if using message)">
  <Expandable title="Child Attributes" defaultOpen>
    <ParamField path="ref" type="string" required>
      This is a reference to any email template available in your project.

      You can only obtain a `ref` after creating an email template in your project. [Learn more about creating a template.](#)
    </ParamField>

    <ParamField path="variables" type="object (optional)">
      A key-value pair that assign values to template variables. These variables are treated as global variables and are applied to every message.

      When variables are specified for each recipient, these are treated as a fallback values.

      ```jsonc theme={"dark"}
      // Example
      {
      	"displayPhoto": "https://link-to-avatar.png",
      	"citizenship": "Global Citizen"
      }
      ```
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="recipients" type="object[]">
  This is the list of users the broadcast will be delivered to. Recipients can be added in batches, `limited to 10 recipients` per request.

  If you're looking to send to a large list, [consider using the broadcast api](/reference) which lets you send to up to 250 recipients per request.

  <Expandable title="Child Attributes" defaultOpen>
    <ParamField path="name" type="string">
      This is the name of the recipient as it will in your audience list. This name is also used when deriving traits like `{{recipient.firstName}}` , so you want to ensure it is accurate.

      If a name is not provided, the `username` part of the recipient address is used.<br />Example: `tenotea` becomes the recipient name for [tenotea@ensend.co](mailto:hello@ensend.co).
    </ParamField>

    <ParamField path="address" type="string">
      The email address of the recipient the broadcast message will be delivered to. This can be any email address which you have received explicit permission to send an email to.
    </ParamField>

    <ParamField path="variables" type="object">
      A key-value pair that assign values to template variables. These variables override global variables and are only applied to the corresponding recipient, unlocking message personalization at scale.

      ```jsonc theme={"dark"}
      // Example
      {
      	"displayPhoto": "https://link-to-profile-picture.png",
      	"citizenship": "Brazilian Citizen"
      }
      ```
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="replyAddress" type="string">
  The email address where replies to your email is sent to.
</ParamField>

<ParamField path="attachments" type="object[]">
  <Expandable title="Child Attributes" defaultOpen>
    <ParamField path="name" type="string">
      The name of the attached file as it should appear in the recipient's inbox.

      <Note>
        You are expected to provide the extension name of the file here. e.g - Resume.pdf
      </Note>
    </ParamField>

    <ParamField path="url" type="string (optional if using content)">
      A public link to the direct file being attached.
    </ParamField>

    <ParamField path="content" type="string (optional if using url)">
      Base64 content of the file to be attached, useful when sending auto-generated files like receipts.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="options" type="object">
  <Expandable title="Child Attributes" defaultOpen>
    <ParamField path="acquiringAudience" type="string">
      Provide a reference to the audience group recipients of this message should be added to during recipient indexing. Your audience ref can be gotten through the Ensend dashboard. This is useful for adding users to segments.
    </ParamField>
  </Expandable>
</ParamField>
