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

# Get Email Template Stats

> View delivery, open, and click statistics for email templates

## Overview

Track the performance of your email templates with detailed analytics including:

* **Delivery metrics**: Total sent, delivered, bounced
* **Engagement metrics**: Opens, clicks, unsubscribes
* **Time-based data**: Performance over time periods
* **Geographic data**: Where your emails are being opened (coming soon)

## Use Cases

<AccordionGroup>
  <Accordion title="Monitor Template Performance">
    Track which templates have the best engagement:

    ```javascript theme={null}
    const templates = await getTemplateList();

    for (const template of templates) {
      const stats = await getTemplateStats(template.id);
      console.log(`${template.name}: ${stats.openRate}% open rate`);
    }
    ```
  </Accordion>

  <Accordion title="A/B Testing">
    Compare performance between template variants:

    ```javascript theme={null}
    const templateA = await getTemplateStats('tmpl_variant_a');
    const templateB = await getTemplateStats('tmpl_variant_b');

    if (templateB.clickRate > templateA.clickRate) {
      console.log('Template B performs better');
    }
    ```
  </Accordion>

  <Accordion title="Dashboard Widgets">
    Display real-time stats in your application:

    ```javascript theme={null}
    async function updateDashboard() {
      const stats = await getTemplateStats('tmpl_welcome');
      
      document.getElementById('sent-count').textContent = stats.sent;
      document.getElementById('open-rate').textContent = `${stats.openRate}%`;
      document.getElementById('click-rate').textContent = `${stats.clickRate}%`;
    }
    ```
  </Accordion>
</AccordionGroup>

## Response Example

```json theme={null}
{
  "templateId": "tmpl_abc123",
  "templateName": "Order Confirmation",
  "period": "all_time",
  "metrics": {
    "sent": 1250,
    "delivered": 1230,
    "bounced": 20,
    "opened": 980,
    "clicked": 450,
    "unsubscribed": 5,
    "complained": 2
  },
  "rates": {
    "deliveryRate": 98.4,
    "openRate": 79.7,
    "clickRate": 36.6,
    "clickToOpenRate": 45.9,
    "bounceRate": 1.6,
    "unsubscribeRate": 0.4,
    "complaintRate": 0.2
  },
  "lastSent": "2025-11-13T14:30:00Z"
}
```

## Metrics Explained

### Volume Metrics

| Metric         | Description                                |
| -------------- | ------------------------------------------ |
| `sent`         | Total emails sent using this template      |
| `delivered`    | Successfully delivered to recipient inbox  |
| `bounced`      | Failed to deliver (hard or soft bounce)    |
| `opened`       | Unique opens (same recipient counted once) |
| `clicked`      | Unique clicks on links in the email        |
| `unsubscribed` | Recipients who unsubscribed                |
| `complained`   | Marked as spam by recipients               |

### Rate Metrics

| Rate              | Calculation                      | Good Benchmark |
| ----------------- | -------------------------------- | -------------- |
| `deliveryRate`    | (delivered / sent) × 100         | > 95%          |
| `openRate`        | (opened / delivered) × 100       | > 20%          |
| `clickRate`       | (clicked / delivered) × 100      | > 3%           |
| `clickToOpenRate` | (clicked / opened) × 100         | > 10%          |
| `bounceRate`      | (bounced / sent) × 100           | \< 5%          |
| `unsubscribeRate` | (unsubscribed / delivered) × 100 | \< 0.5%        |
| `complaintRate`   | (complained / delivered) × 100   | \< 0.1%        |

<Warning>
  High bounce or complaint rates can damage your sender reputation and affect email deliverability. Monitor these
  metrics closely.
</Warning>

## Time Periods (Coming Soon)

Future versions will support different time periods:

```bash theme={null}
GET /api/templates/email/{id}/stats?period=last_30_days
GET /api/templates/email/{id}/stats?period=last_week
GET /api/templates/email/{id}/stats?from=2025-11-01&to=2025-11-13
```

## Best Practices

### Monitoring Frequency

* **High-volume templates**: Check daily
* **Moderate-volume**: Check weekly
* **Low-volume**: Check monthly

### Setting Alerts

Monitor for issues:

```javascript theme={null}
async function checkTemplateHealth(templateId) {
  const stats = await getTemplateStats(templateId);

  if (stats.rates.bounceRate > 5) {
    alert('High bounce rate detected!');
  }

  if (stats.rates.complaintRate > 0.1) {
    alert('High complaint rate - review template content');
  }

  if (stats.rates.deliveryRate < 95) {
    alert('Delivery issues detected');
  }
}
```

### Improving Performance

**Low open rate?**

* Test different subject lines
* Optimize send time
* Segment your audience better

**Low click rate?**

* Make CTAs more prominent
* Reduce content complexity
* Test different button styles

**High bounce rate?**

* Clean your contact list
* Verify email addresses before sending
* Remove hard bounces immediately

## Exporting Data (Coming Soon)

Future versions will support exporting stats:

```bash theme={null}
GET /api/templates/email/{id}/stats/export?format=csv
```

## Related Endpoints

* [Send Email Template](/api-reference/messaging-channels/email/send-template) - Send emails with this template
* [List Email Templates](/api-reference/messaging-channels/email/list-templates) - View all templates


## OpenAPI

````yaml get /api/templates/email/{id}/stats
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/{id}/stats:
    get:
      summary: Retrieve Transactional Detail and Statistics
      description: >-
        Get detailed information and statistics for a specific transactional
        message using its ID.
      parameters:
        - name: id
          in: path
          required: true
          description: The unique ID of the transactional message.
          schema:
            type: integer
            example: 123
      responses:
        '200':
          description: Successful response with transactional detail and statistics.
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: string
                    format: date-time
                    description: Timestamp when the transactional message was created.
                    example: '2023-12-01T10:00:00Z'
                  openRate:
                    type: string
                    description: Percentage of recipients who opened the message.
                    example: 85%
                  clickRate:
                    type: string
                    description: >-
                      Percentage of recipients who clicked a link in the
                      message.
                    example: 50%
                  totalMessagesSent:
                    type: integer
                    description: >-
                      Total number of messages sent for this transactional
                      message.
                    example: 1000
        '400':
          description: Unauthorized access due to missing or invalid token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message.
                    example: Missing API client ID or API key
        '404':
          description: Transactional message not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message.
                    example: Transactional not found
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: mn-API_CLIENT_ID-API_KEY

````