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

# AI agents

> Connect the Bevits API to Leme, Claude Code, Codex, and other agents.

Agents can use the Bevits REST API to answer questions about customers,
segments, purchases, flows, and campaigns. Each API key can access only the
organization it belongs to.

<Warning>
  Give the agent a dedicated key with the `read` scope. Do not paste the key
  into prompts, versioned files, or logs; provide it through an environment
  variable or the platform's secret manager.
</Warning>

## Leme

When creating a custom connection in Leme, use:

| Setting         | Value                                                 |
| --------------- | ----------------------------------------------------- |
| Base URL        | `https://api.bevits.com/v1`                           |
| Authentication  | API key / Bearer token                                |
| Header          | `Authorization: Bearer <API_KEY>`                     |
| Identity        | `GET /me`                                             |
| Discovery       | `GET /segments`, `GET /flows`, `GET /email-campaigns` |
| Connection type | Shared by the organization                            |

Validate the connection with `GET /me` first. The returned `organization.id`
is the connection's stable identity.

## Claude Code and Codex

Claude Code and Codex can test the API through their terminal tools. The Bevits
API is REST; it does not present itself directly as an MCP server.

Start the tool with the variable available in its environment:

```bash theme={null}
export BEVITS_API_KEY="bvt_live_..."
```

Then provide an instruction such as:

```text theme={null}
Use the Bevits API at https://api.bevits.com/v1.
Authenticate with Authorization: Bearer $BEVITS_API_KEY without printing the key.
Start by requesting /me. Paginate with starting_after and respect
X-RateLimit-* and Retry-After. Perform read-only operations.
```

## Recommended CRM workflow

To answer “who are the best customers in the VIP segment and what did they
buy?”, the agent can use only three steps:

1. `GET /segments?q=VIP` to find the segment.
2. `GET /segments/{segment_id}/customers?sort=total_spent` to rank its customers.
3. `GET /customers/{customer_id}/purchases` to query the selected customer's purchases.

<Tip>
  Instruct the agent to preserve IDs exactly as returned and to request human
  confirmation before any action outside the read-only endpoints.
</Tip>
