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

# Send Email Template

> Send transactional or automated emails using predefined templates

## Overview

Use this endpoint to send emails based on templates you've created in the Minimo dashboard. Perfect for:

* **Transactional emails**: Order confirmations, password resets, receipts
* **Automated messages**: Welcome series, onboarding flows
* **Triggered notifications**: Account alerts, status updates

<Tip>
  This API is intended for **server-side usage only**. Requests from client-side applications will be blocked for
  security reasons.
</Tip>

## Before You Start

1. **Create a template** in the Minimo dashboard under Templates → Email
2. **Get the template ID** from the templates list
3. **Define custom fields** in your template using `{{variableName}}` syntax
4. **Test your template** using the dashboard preview before API integration

## Template Variables

Templates support dynamic content using variables:

**Template Example**:

```html theme={null}
Hello {{firstName}}, Your order {{orderNumber}} has been confirmed! Total: {{orderTotal}} Estimated delivery:
{{deliveryDate}}
```

**API Request**:

```json theme={null}
{
  "templateId": "tmpl_abc123",
  "recipient": "customer@example.com",
  "customFields": {
    "firstName": "Jane",
    "orderNumber": "ORD-12345",
    "orderTotal": "$99.99",
    "deliveryDate": "November 20, 2025"
  }
}
```

## Use Cases

<AccordionGroup>
  <Accordion title="Order Confirmation">
    Send instant confirmation when an order is placed:

    ```json theme={null}
    {
      "templateId": "tmpl_order_confirm",
      "recipient": "customer@example.com",
      "customFields": {
        "orderNumber": "ORD-12345",
        "items": "3 items",
        "total": "$149.99",
        "trackingUrl": "https://track.example.com/12345"
      }
    }
    ```
  </Accordion>

  <Accordion title="Password Reset">
    Send password reset links securely:

    ```json theme={null}
    {
      "templateId": "tmpl_password_reset",
      "recipient": "user@example.com",
      "customFields": {
        "resetLink": "https://app.example.com/reset?token=abc123",
        "expiresIn": "24 hours"
      }
    }
    ```
  </Accordion>

  <Accordion title="Welcome Email">
    Onboard new users with a welcome message:

    ```json theme={null}
    {
      "templateId": "tmpl_welcome",
      "recipient": "newuser@example.com",
      "customFields": {
        "firstName": "John",
        "loginUrl": "https://app.example.com/login",
        "supportEmail": "support@example.com"
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Best Practices

### Email Deliverability

<Tip>
  To improve deliverability: - Use verified sender domains in Minimo dashboard - Avoid spam trigger words in templates -
  Include unsubscribe links for marketing emails - Test with email testing tools before production
</Tip>

### Template Design

* **Keep it simple**: Plain text or simple HTML works best
* **Test responsiveness**: Templates should work on mobile devices
* **Include branding**: Add your logo and brand colors
* **Clear call-to-action**: Make buttons and links obvious

### Error Handling

Always handle potential errors:

```javascript theme={null}
try {
  const response = await fetch('https://app.minimo.it/api/templates/email/send', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${apiKey}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      templateId: 'tmpl_abc123',
      recipient: 'customer@example.com',
      customFields: { name: 'Jane' },
    }),
  });

  if (!response.ok) {
    const error = await response.json();
    console.error('Email send failed:', error);
    // Log error, retry, or notify admin
  }
} catch (error) {
  console.error('Network error:', error);
  // Handle network issues
}
```

## Common Errors

| Error                  | Cause                          | Solution                             |
| ---------------------- | ------------------------------ | ------------------------------------ |
| `template_not_found`   | Invalid template ID            | Verify template ID in dashboard      |
| `invalid_recipient`    | Invalid email address          | Validate email format before sending |
| `missing_custom_field` | Template variable not provided | Include all required custom fields   |
| `rate_limit_exceeded`  | Too many requests              | Implement rate limiting, use queues  |
| `sender_not_verified`  | Email domain not verified      | Verify sender domain in dashboard    |

## Tracking & Analytics

After sending, track email performance:

* **Delivery status**: Check if email was delivered
* **Open rate**: See who opened your emails
* **Click rate**: Track link clicks in your templates
* **Bounce rate**: Monitor bounced emails

Access analytics in the Minimo dashboard or via the [Get Email Template Stats](/api-reference/messaging-channels/email/stats) endpoint.

## Related Endpoints

* [List Email Templates](/api-reference/messaging-channels/email/list-templates) - Get all available templates
* [Get Email Template Stats](/api-reference/messaging-channels/email/stats) - View template analytics


## OpenAPI

````yaml post /api/templates/email/send
openapi: 3.1.0
info:
  title: API Documentation
  description: Documentation for transactional and subscribe APIs
  version: 1.0.0
servers:
  - url: https://app.minimo.it
security:
  - bearerAuth: []
paths:
  /api/templates/email/send:
    post:
      summary: Send transactional emails
      operationId: sendTransactionalEmails
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    recipient:
                      type: string
                      description: Email address of the recipient
                    uid:
                      type: string
                      description: UID of the transactional email
                    customFields:
                      type: object
                      additionalProperties: true
                      description: Custom fields specific to the email
                  required:
                    - recipient
                    - uid
                - type: array
                  items:
                    type: object
                    properties:
                      recipient:
                        type: string
                        description: Email address of the recipient
                      uid:
                        type: string
                        description: UID for the transactional email
                      customFields:
                        type: object
                        additionalProperties: true
                        description: Custom fields specific to the email
                    required:
                      - recipient
                      - uid
              examples:
                - recipient: email@minimo.it
                  uid: ABCDE143
                  customFields:
                    customKey1: customValue1
                    customKey2: customValue2
                    customKey3: customValue3
          multipart/form-data:
            schema:
              type: object
              properties:
                recipient:
                  type: string
                  format: email
                  description: Email address of the recipient
                uid:
                  type: string
                  description: UID for the transactional email
                customFields.*:
                  type: string
                  description: Custom field key-value pairs for the email
              required:
                - recipient
                - uid
              examples:
                - recipient: email@minimo.it
                  uid: ABCDE143
                  customFields.customKey1: customValue1
                  customFields.customKey2: customValue2
                  customFields.customKey3: customValue3
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                recipient:
                  type: string
                  format: email
                  description: Email address of the recipient
                uid:
                  type: string
                  description: UID for the transactional email
                customFields.*:
                  type: string
                  description: Custom field key-value pairs for the email
              required:
                - recipient
                - uid
              examples:
                - recipient: email@minimo.it
                  uid: ABCDE143
                  customFields.customKey1: customValue1
                  customFields.customKey2: customValue2
                  customFields.customKey3: customValue3
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    examples:
                      - 200
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    examples:
                      - Missing recipient address
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    examples:
                      - Internal server error
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import requests


            url = 'https://app.minimo.it/api/templates/email/send'

            headers = {'Authorization': 'Bearer {{BEARER_TOKEN}}',
            'Content-Type': 'application/json'}

            data = {
                'recipient': '{{recipient}}',
                'uid': '{{uid}}',
                'customFields': {
                    '{{customKey1}}': '{{customValue1}}',
                    '{{customKey2}}': '{{customValue2}}',
                    '{{customKey3}}': '{{customValue3}}'
                }
            }

            response = requests.post(url, json=data, headers=headers)

            print(response.json())
        - lang: JavaScript
          source: >-
            fetch('https://app.minimo.it/api/templates/email/send', {
                method: 'POST',
                headers: {
                    'Authorization': 'Bearer {{BEARER_TOKEN}}',
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify({
                    'recipient': '{{recipient}}',
                    'uid': '{{uid}}',
                    'customFields': {
                        '{{customKey1}}': '{{customValue1}}',
                        '{{customKey2}}': '{{customValue2}}',
                        '{{customKey3}}': '{{customValue3}}'
                    }
                })
            }).then(response => response.json()).then(data =>
            console.log(data));
        - label: CLI
          lang: cURL
          source: |-
            curl --request POST \
              --url https://app.minimo.it/api/templates/email/send \
              --header 'Authorization: Bearer {{BEARER_TOKEN}}' \
              --header 'Content-Type: application/json' \
              --data '{
              "recipient": "{{recipient}}",
              "uid": "{{uid}}",
              "customFields": {
                "{{customKey1}}": "{{customValue1}}",
                "{{customKey2}}": "{{customValue2}}",
                "{{customKey3}}": "{{customValue3}}"
              }
             }'
        - lang: PHP
          source: |
            <?php

            $curl = curl_init();

            curl_setopt_array($curl, array(
                CURLOPT_URL => 'https://app.minimo.it/api/templates/email/send',
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_ENCODING => '',
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 0,
                CURLOPT_FOLLOWLOCATION => true,
                CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                CURLOPT_CUSTOMREQUEST => 'POST',
                CURLOPT_POSTFIELDS =>'{
                    "recipient": "{{recipient}}",
                    "uid": "{{uid}}",
                    "customFields": {
                        "{{customKey1}}": "{{customValue1}}",
                        "{{customKey2}}": "{{customValue2}}",
                        "{{customKey3}}": "{{customValue3}}"
                    }
                }',
                CURLOPT_HTTPHEADER => array(
                    'Authorization: Bearer {{BEARER_TOKEN}}',
                    'Content-Type: application/json'
                ),
            ));

            $response = curl_exec($curl);

            curl_close($curl);
            echo $response;
        - lang: Java
          source: |-
            import java.net.HttpURLConnection;
            import java.net.URL;
            import java.io.OutputStream;
            import java.io.InputStreamReader;
            import java.io.BufferedReader;

            public class Main {
                public static void main(String[] args) {
                    try {
                        URL url = new URL('https://app.minimo.it/api/templates/email/send');
                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                        conn.setRequestMethod('POST');
                        conn.setRequestProperty('Authorization', 'Bearer {{BEARER_TOKEN}}');
                        conn.setRequestProperty('Content-Type', 'application/json');
                        conn.setDoOutput(true);
                        String jsonInputString = '{"recipient": "{{recipient}}", "uid": "{{uid}}", "customFields": {"{{customKey1}}": "{{customValue1}}", "{{customKey2}}": "{{customValue2}}", "{{customKey3}}": "{{customValue3}}"}}';
                        try(OutputStream os = conn.getOutputStream()) {
                            byte[] input = jsonInputString.getBytes('utf-8');
                            os.write(input, 0, input.length);
                        }
                        try(BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), 'utf-8'))) {
                            StringBuilder response = new StringBuilder();
                            String responseLine = null;
                            while ((responseLine = br.readLine()) != null) {
                                response.append(responseLine.trim());
                            }
                            System.out.println(response.toString());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: mn-API_CLIENT_ID-API_KEY

````