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

# Use Brew with AI agents

> Brew is built to be operated by any AI agent. OpenClaw, Claude, Replit, Lovable, and Viktor all work out of the box.

Brew is an AI-native ESP. The product is built so any AI agent that can call an HTTP API can drive Brew end-to-end, extracting brands, generating emails, creating automations, sending, and tracking results.

<Tip>
  **The fastest way to connect an agent is the [Brew MCP server](/api-reference/mcp/overview).** Add one URL to Claude, Cursor, or any Model Context Protocol client and your agent gets the full Brew toolset (generate, send, schedule, automate, segment, analyze) with no custom HTTP wiring. See the [MCP quickstart](/api-reference/mcp/quickstart).
</Tip>

This works today with any agent platform that supports HTTP tool-calling, including:

* **OpenClaw**
* **Claude** (via tools/function calling, computer use, or MCP)
* **Replit** agents
* **Lovable** ([worked example](/integrations/ai-tools/lovable))
* **Viktor**
* **Custom agents** built on OpenAI, Anthropic, Google, or open-source LLMs

## How It Works

Agents talk to Brew through Brew's REST API. The same endpoints that power the Brew app are available to your agent, there's no separate "agent API."

Your agent gets:

* **An API key** from Brew (**Settings → API**)
* **The OpenAPI spec** from the API Reference tab
* **The right scopes** for what it needs (read contacts, create automations, send emails, etc.)

From there, the agent can:

| Capability                                  | How                                                                                                               |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| Discover the whole API (no auth)            | `GET /v1/help` (structured JSON) or `GET /v1/llms.txt` (prose guide)                                              |
| Generate an email design                    | `POST /v1/emails` with a `prompt` (designs are untyped)                                                           |
| Create or update contacts                   | `POST /v1/contacts` (single OR batch: up to 1000 rows per request)                                                |
| Define a custom event trigger               | `POST /v1/automations/triggers` (no `provider` field, server hardcodes `brew_api`)                                |
| Author + publish an automation graph        | `POST /v1/automations` → `PATCH /v1/automations/{automationId}` with `{ published: true }`                        |
| Fire an automation on a real event          | `POST /v1/automations/triggers/{triggerEventId}/fire` with `{ payload, idempotencyKey }`                          |
| Inspect a run + per-node logs               | `GET /v1/automations/runs?automationRunId=…&include=logs`                                                         |
| Send a one-off email                        | `POST /v1/sends` (provide a brand-owned `audienceId` or an inline `to` list ≤ 50; `{ test: true }` for a QA send) |
| Read send status, stats, and events         | `GET /v1/analytics/sends?sendId=…&include=events`                                                                 |
| Look up contacts                            | `POST /v1/contacts/search` (`filters`, `audienceId`, `search`)                                                    |
| Discover saved audiences / verified domains | `GET /v1/audiences`, `GET /v1/domains`                                                                            |

> Brand creation is **not** part of the public v1 API, brands are
> managed in the dashboard (one brand per API key). Analytics, by
> contrast, **are** part of the API: read sends, campaigns,
> automations, and the unified event feed under `/v1/analytics/*`.
> The fire endpoint auto-upserts the contact derived from the
> trigger payload, so most agent use cases don't need to call
> `POST /v1/contacts` separately.

See the [API Reference](/api-reference/api/api-introduction) for the
full contract, the [agentic cookbook](/sdks/typescript/agentic-cookbook)
for end-to-end recipes, and `https://brew.new/api/v1/llms.txt` for
the machine-discoverable agent operations guide.

## Pattern: Function-Calling Agent

Most modern agents support tool/function calling. Wire Brew's API into your agent's tool definitions and the agent picks the right call based on the user's request.

A typical setup:

1. Define each Brew endpoint as a tool in your agent's tool registry
2. Provide auth headers using your Brew API key
3. Let the agent call the right tool, generating an email, sending it, building an automation, based on conversation

Your agent's user can now say *"Send a welcome email to the new signups from yesterday"* and the agent figures out: pull the contacts, generate the email, send.

## Pattern: Backend Trigger

If your agent runs on a backend (Replit, Lovable's Edge Functions, your own API), wire it to call Brew's trigger endpoints when events happen in your app:

* New user signs up → trigger your `user_signup` event in Brew
* Customer abandons cart → trigger `cart_abandoned`
* Payment fails → trigger `payment_failed`

The agent doesn't have to be in the loop for every send. It just sets up the automations once, and Brew fires them automatically.

## Pattern: Chat-Driven Brand and Email Creation

Some agents (Lovable, Viktor) generate full apps and need to ship email as part of the build. Brew handles this too:

1. User connects their brand in the Brew dashboard (one-time setup that produces an API key bound to that brand)
2. Agent generates the email designs it needs (`POST /v1/emails { prompt }`, designs are untyped; the same design can be sent transactionally or wired into a flow)
3. Agent assembles an automation graph (`POST /v1/automations { name, triggerEventId, nodes, connections }`) and publishes it (`PATCH /v1/automations/{automationId} { published: true }`)
4. Agent wires the user's app backend to fire the trigger from the real event: `POST /v1/automations/triggers/{triggerEventId}/fire { payload, idempotencyKey }`

The user gets fully on-brand email behavior in their app without ever opening Brew directly.

## Authentication

Every API request needs an API key in the header:

```bash theme={null}
X-API-Key: brew_YOUR_API_KEY
```

Or:

```bash theme={null}
Authorization: Bearer brew_YOUR_API_KEY
```

Create keys under **Settings → API** in Brew. Each key is scoped to a brand.

## What to Read Next

<CardGroup cols={2}>
  <Card title="API Reference" icon="code" color="#c44925" href="/api-reference/api/api-introduction">
    Full endpoint reference, authentication, and code examples.
  </Card>

  <Card title="Lovable" icon="heart" color="#c44925" href="/integrations/ai-tools/lovable">
    Worked example using Brew API from a Lovable app via Supabase Edge Functions.
  </Card>

  <Card title="Automations" icon="diagram-project" color="#c44925" href="/create-emails/automations">
    Build flows and configure the trigger events your agent will fire.
  </Card>
</CardGroup>

## Need help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

<Tabs>
  <Tab title="Self-Service Tools">
    <CardGroup cols="2">
      <Card title="Search Documentation" icon="magnifying-glass" color="#c44925">
        Type in the "Ask any question" search bar at the top left to instantly find relevant documentation pages.
      </Card>

      <Card title="ChatGPT/Claude Integration" icon="robot" color="#c44925">
        Click "Open in ChatGPT" at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.
      </Card>
    </CardGroup>
  </Tab>

  <Tab title="Talk to Our Team">
    <CardGroup cols="2">
      <Card title="Schedule a Call" icon="calendar" color="#c44925" href="https://calendar.google.com/calendar/u/0/appointments/schedules/AcZssZ1iYoRUG1J792XQpbuQLjSRRDupr7MwraFK-HQRCtTYdBmrQi8nZu2qXfzKQigb8gbKJK3KN3-R">
        Book time with our founders for personalized guidance on strategy, best practices, or complex implementation questions.
      </Card>

      <Card title="Call Us Directly" icon="phone" color="#c44925">
        Need immediate assistance? Reach us at **+1-(332)-203-2145** for urgent issues or time-sensitive questions.
      </Card>

      <Card title="Slack Channel" icon="slack" color="#c44925">
        Our preferred support channel. You'll receive an invite after signup for direct founder support and fast responses.
      </Card>

      <Card title="Email Support" icon="envelope" color="#c44925" href="mailto:support@brew.new">
        Contact us at **[support@brew.new](mailto:support@brew.new)** for detailed inquiries or if you prefer not to use Slack.
      </Card>
    </CardGroup>
  </Tab>
</Tabs>
