# Email campaigns

> Add every matching lead to an email campaign automatically.

Every section below does the same job: in the dashboard (Guide), from your code (API) or through an AI assistant (MCP).

## Guide — In the dashboard

Source: /docs/automations/email-campaigns

Each lead that matches the automation is added to an email campaign as a contact and starts its sequence from the first step, from the mailboxes you choose.

1. **Automations → New automation**, then **Add to email campaign**.
2. **Pick the campaign** and, if you like, the mailboxes that send.
3. **Save.** The campaign must be active for the emails to go out.


---

## API — From your code

Source: /docs/automations/email-campaigns/api

Authenticated with `?privateKey=YOUR_KEY` (see [Authentication](/docs/authentication)).

<Endpoints ops={["POST /admin/automations", "GET /admin/automations", "PATCH /admin/automations/{id}", "GET /admin/email-campaigns"]} />

<ApiPlayground
  method="post"
  path="/admin/automations"
  tool="create_automation"
  args={`{
  "name": "Docs example: send-to-emailCampaign",
  "isActive": true,
  "website": "64b7f0a1c2d3e4f5a6b7c8d9",
  "when": "new-lead-is-identified",
  "then": "send-to-emailCampaign",
  "interval": "immediately",
  "actions": {
    "sentToEmailCampaign": {
      "emailCampaign": "6a3f00000000000000000004"
    }
  }
}`}
/>

### Use case: Find the campaign [#use-case-find-the-campaign]

`GET /admin/email-campaigns` lists your campaigns; use one's `_id` as `emailCampaign`.


---

## MCP — AI agents

Source: /docs/automations/email-campaigns/mcp

Connect the [MCP server](/docs/mcp#quickstart), then just ask.

<Tools names={["create_automation", "list_campaigns"]} />

### Use case [#use-case]

> Add every hot lead to my 'Website visitors' campaign.

<McpToolCall name="create_automation">

```json
{
  "websiteId": "64b7f0a1c2d3e4f5a6b7c8d9",
  "name": "Hot leads to campaign",
  "trigger": {
    "then": "send-to-emailCampaign"
  },
  "actions": [
    {
      "emailCampaign": "6a3f00000000000000000004"
    }
  ]
}
```

</McpToolCall>

