# Email Campaigns

Create and send bulk broadcast email campaigns to segmented audiences. Supports tag-based and pipeline-based audience filters, delivery tracking (opens, clicks, bounces), and automatic unsubscribe management.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### GET /email-campaigns

List all email campaigns for the company. Filter by status.

**Scopes:** `email-campaigns:read` — [full detail](./email-campaigns/get-email-campaigns.md)

### POST /email-campaigns

Create a new draft email campaign. Provide a name at minimum. Set subject, body_html, and segment_filter before sending.

**Scopes:** `email-campaigns:write` — [full detail](./email-campaigns/post-email-campaigns.md)

### GET /email-campaigns/:id

Get a single campaign by ID with full content and delivery stats.

**Scopes:** `email-campaigns:read` — [full detail](./email-campaigns/get-email-campaigns-id.md)

### PATCH /email-campaigns/:id

Update a draft or scheduled campaign. Only draft and scheduled campaigns can be modified.

**Scopes:** `email-campaigns:write` — [full detail](./email-campaigns/patch-email-campaigns-id.md)

### DELETE /email-campaigns/:id

Delete a campaign. Only draft or failed campaigns can be deleted.

**Scopes:** `email-campaigns:delete` — [full detail](./email-campaigns/delete-email-campaigns-id.md)

### POST /email-campaigns/:id/send

Send a campaign immediately via Postmark broadcast stream. Campaign must be in draft or scheduled status, must have subject and body_html set, and must match at least one contact. Resolves audience, batches sends (up to 500 per batch), and records per-recipient status. This action cannot be undone.

**Scopes:** `email-campaigns:write` — [full detail](./email-campaigns/post-email-campaigns-id-send.md)

### GET /email-campaigns/:id/preview-audience

Preview the audience that would receive this campaign. Returns total count and up to 50 sample contacts. Use before sending to confirm the segment filter is correct.

**Scopes:** `email-campaigns:read` — [full detail](./email-campaigns/get-email-campaigns-id-preview-audience.md)

### GET /email-campaigns/:id/recipients

List per-recipient delivery records for a campaign. Filter by status or search by email. Statuses: queued, sent, delivered, opened, clicked, bounced, failed.

**Scopes:** `email-campaigns:read` — [full detail](./email-campaigns/get-email-campaigns-id-recipients.md)

### GET /email-campaigns/unsubscribes

List all email unsubscribe records for the company. Includes reason (link_click, hard_bounce, complaint, unsubscribe_header) and the campaign that triggered it.

**Scopes:** `email-campaigns:read` — [full detail](./email-campaigns/get-email-campaigns-unsubscribes.md)
