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

# Email and drips

> Configure sending, templates, campaigns, suppressions, and unsubscribe.

Email supports transactional sends, hub-specific sending configuration, templates, drip campaigns, suppressions, webhooks, and unsubscribe.

## Configure hub sending

```text theme={null}
GET /v1/hubs/{hub_id}/email-config
PUT /v1/hubs/{hub_id}/email-config
POST /v1/hubs/{hub_id}/email-config/test
```

## Create templates

```text theme={null}
POST /v1/hubs/{hub_id}/email-templates
GET  /v1/hubs/{hub_id}/email-templates
POST /v1/hubs/{hub_id}/email-templates/{template_id}/preview
```

<Note>
  Invalid MJML in a preview request now returns `422 invalid_template_mjml` (previously returned `500`). Update error handling to check for `422` with code `invalid_template_mjml` when previewing templates.
</Note>

## Create a drip campaign

```text theme={null}
POST /v1/hubs/{hub_id}/drip-campaigns
POST /v1/hubs/{hub_id}/drip-campaigns/{campaign_id}/steps
POST /v1/hubs/{hub_id}/drip-campaigns/{campaign_id}/activate
```

Use drip campaigns for welcome sequences, content drip, cart recovery, post-purchase nurture, and reactivation.

## Suppressions and unsubscribe

Suppression endpoints help prevent sends to blocked or unsubscribed addresses:

```text theme={null}
GET  /v1/hubs/{hub_id}/email-suppressions
POST /v1/hubs/{hub_id}/email-suppressions
GET  /unsubscribe
POST /unsubscribe
```

<Note>
  Email routes currently remain under `/v1/...` instead of `/api/v1/...`. Treat the generated API reference as the exact path source for email until those routes are folded into the canonical API prefix.
</Note>

## Drip admin enrollment

Admin enrollment endpoints (`POST /enroll`, `DELETE /exit`, and list enrollments) are wired but the underlying campaign-authoring surface (create/update/delete campaigns and steps) is not yet built. Calling those unbuilt methods returns `404` with code `drip_admin_surface_unavailable` instead of a `500`. Track the campaign-authoring surface under the email phase-B milestone.

## Admin deliverability KPI

A per-hub email deliverability summary is available to team owners. This is distinct from the existing rolling member stats endpoint (`GET /v1/hubs/{hub_id}/email-stats`, hub-admin only, 24-hour rolling window).

```text theme={null}
GET /api/v1/teams/{team_id}/hubs/{hub_id}/analytics/email
Authorization: Bearer <team-owner-token>
```

**Authentication:** requires a team-owner JWT (not a contact/member JWT).

**Query parameters:**

| Parameter | Type              | Default      | Notes                         |
| --------- | ----------------- | ------------ | ----------------------------- |
| `from`    | ISO-8601 datetime | 24 hours ago | Start of the analytics window |
| `to`      | ISO-8601 datetime | now          | End of the analytics window   |

**Response (200):**

```json theme={null}
{
  "data": {
    "type": "analytics_email_deliverability",
    "id": "<hub_id>",
    "attributes": {
      "sent": 1420,
      "delivered": 1388,
      "bounced_hard": 8,
      "bounced_soft": 12,
      "complained": 3,
      "unsubscribed": 9,
      "bounce_rate": 0.014,
      "complaint_rate": 0.002
    }
  }
}
```

| Field            | Type    | Description                            |
| ---------------- | ------- | -------------------------------------- |
| `sent`           | integer | Total sends in the window              |
| `delivered`      | integer | Successfully delivered                 |
| `bounced_hard`   | integer | Permanent delivery failures            |
| `bounced_soft`   | integer | Temporary delivery failures            |
| `complained`     | integer | Spam complaints received               |
| `unsubscribed`   | integer | Unsubscribe events in the window       |
| `bounce_rate`    | float   | `(bounced_hard + bounced_soft) / sent` |
| `complaint_rate` | float   | `complained / delivered`               |

**Deliverability endpoint status:**

| Endpoint                                                    | Scope                  | Auth                    | Status |
| ----------------------------------------------------------- | ---------------------- | ----------------------- | ------ |
| `GET /v1/hubs/{hub_id}/email-stats`                         | Rolling 24h, hub-admin | Contact JWT (hub admin) | Live   |
| `GET /api/v1/teams/{team_id}/hubs/{hub_id}/analytics/email` | Custom window, per-hub | Team-owner JWT          | Live   |
