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

# Email

> Send broadcasts and transactional email to your customers, and operate a full email client — inboxes, threads, drafts, replies, labels, and sending domains — through the API.

**Email in Crevio is two things: a simple way to broadcast to your customers, and a full email client — inboxes, threads, messages, drafts, search, and replies — that lets you (or an agent) run your inbox programmatically.**

Use the broadcast side to blast an announcement to every paid customer, and the client side to read, reply to, and label inbound mail. You can just ask Crevio to draft and send a launch email, or wire up an agent that watches for incoming messages and replies on your behalf.

## Part 1 — Broadcast and transactional send

`POST /emails` sends an email to your customers. Filter recipients by `customer_type` or send to everyone with `send_to_all`. `from` defaults to your account's default sending address.

| Field           | Purpose                                        |
| --------------- | ---------------------------------------------- |
| `to`            | Array of explicit recipient addresses          |
| `subject`       | Email subject                                  |
| `body`          | Email body                                     |
| `customer_type` | Recipient filter (e.g. `paid`, `free`, `lead`) |
| `send_to_all`   | `true` to send to all matching customers       |
| `from`          | Override the sending address                   |

### Worked example: broadcast to all paid customers

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.crevio.co/v1/emails \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "subject": "Doors to the mastermind open Monday",
      "body": "Thanks for joining — our coaching mastermind kicks off Monday and your member space unlocks then.",
      "customer_type": "paid",
      "send_to_all": true
    }'
  ```

  ```typescript SDK theme={null}
  import { Crevio } from "@crevio/sdk";

  const crevio = new Crevio({ apiKeyAuth: "YOUR_API_TOKEN" });

  await crevio.emails.send({
    subject: "Doors to the mastermind open Monday",
    body: "Thanks for joining — our coaching mastermind kicks off Monday and your member space unlocks then.",
    customer_type: "paid",
    send_to_all: true,
  });
  ```

  ```text MCP (agent) theme={null}
  Email all my paid customers letting them know the mastermind kicks off Monday.
  ```
</CodeGroup>

<Tip>
  Let Crevio write the copy: ask it to draft the broadcast, review the draft, then send. See [Tasks](/developer/guides/tasks).
</Tip>

## Part 2 — The email client

Crevio also operates as a real mailbox built around **inboxes → threads → messages**, with drafts, search, labels, and attachments.

### Inboxes, threads, and messages

```bash theme={null}
# List inboxes
curl https://api.crevio.co/v1/email/inboxes \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# List threads in an inbox
curl https://api.crevio.co/v1/email/threads \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# Read the messages in a thread
curl https://api.crevio.co/v1/email/threads/thread_abc123/messages \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

### Worked example: reply to an inbound message

Reading a thread gives you its messages; reply directly to one.

```bash theme={null}
curl -X POST https://api.crevio.co/v1/email/messages/msg_abc123/reply \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "body": "Hi Jordan — yes, the group coaching calls are included. Want me to add you to the next mastermind cohort?"
  }'
```

The client also supports `reply-all` and `forward` on a message, the same way.

### Drafts, search, and labels

```bash theme={null}
# Create a draft
curl -X POST https://api.crevio.co/v1/email/drafts \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "to": ["jordan@example.com"], "subject": "Mastermind options", "body": "..." }'

# Search across mail
curl "https://api.crevio.co/v1/email/search?query=refund" \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# Label a thread
curl -X POST https://api.crevio.co/v1/email/threads/thread_abc123/labels \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "label": "support" }'
```

Attachments are available on messages, and drafts can be sent once finalized.

### Sending domains

To send from your own domain (rather than the platform default), add a sending domain and verify it. This is what makes broadcasts arrive from `hello@yourbrand.com`.

```bash theme={null}
# Add a sending domain
curl -X POST https://api.crevio.co/v1/email/domains \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "domain": "mastermind.coach" }'

# Verify it
curl -X POST https://api.crevio.co/v1/email/domains/edom_abc123/verify \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

<Note>
  You'll add the DNS records the response gives you at your registrar. If the domain is managed by Crevio, you can do that via the [Domains](/developer/guides/domains) zone-records API.
</Note>

## Email webhooks

The inbox is event-driven. Subscribe to `email_message.*` events to react to mail in real time instead of polling:

`email_message.received`, `email_message.sent`, `email_message.delivered`, `email_message.bounced`, `email_message.complained`, `email_message.failed`.

A common pattern: listen for `email_message.received`, run a [Task](/developer/guides/tasks) to draft a reply, and send it. See [Webhooks](/developer/guides/webhooks).

## Next steps

<CardGroup cols={2}>
  <Card title="Webhooks" icon="bell" href="/developer/guides/webhooks">
    React to inbound mail with `email_message.*` events.
  </Card>

  <Card title="Tasks" icon="robot" href="/developer/guides/tasks">
    Let an agent triage and reply to your inbox.
  </Card>

  <Card title="Customers" icon="users" href="/developer/api-reference/introduction">
    Segment who your broadcasts reach.
  </Card>

  <Card title="Domains" icon="globe" href="/developer/guides/domains">
    Manage DNS for your sending domain.
  </Card>
</CardGroup>
