# Build with an AI agent

> Paste the prompt below into your coding agent. It reads the whole contract from `/docs/llms-full.txt`, checks every payload against the real API with the public test key `bk_test_public` before it has yours, and reads your key from `BAKER_EVENTS_KEY`, never from source. You decide which events matter and hand over the key; the agent does the rest.

Source: https://withbaker.com/docs/agents · Updated 2026-11-23

## The prompt

Paste it into Cursor, Claude Code, Codex, Copilot, Windsurf or any agent that can read a URL and run a command:

```text
Send our server-side events to Baker's API.

1. Read https://withbaker.com/docs/llms-full.txt first: it is the complete contract. Build from it.
2. Ask me which moments to send (for example a qualified lead, a deal won with its amount, a deal lost, an order paid, a refund) and where each person's email, phone or contact id lives in our code. If you cannot ask, choose, write the assumption in a code comment, and carry on.
3. Read the key from the BAKER_EVENTS_KEY environment variable. Never hardcode it, never print it, never commit it.
4. While building, run every payload against the real API with the public test key: BAKER_EVENTS_KEY=bk_test_public. It is checked exactly like ours and nothing is stored. Fix every entry in data.rejected until there are none.
5. Batch up to 500 events per request, give each event a stable event_id from our own records, retry 429 and 5xx with the same event_ids, and log data.rejected on every response.
6. Keep the header X-Baker-Mode: test until I say we are live.
```

## What your agent can do on its own

- **Read the contract**: every page is Markdown, and [/docs/llms-full.txt](https://withbaker.com/docs/llms-full.txt) is all of them in one file.
- **Validate a payload offline** against the [JSON Schema](https://withbaker.com/docs/event-batch.schema.json) of the request body.
- **Test against the real API** with `bk_test_public`: the same parse, the same per-event rules and the same answer your key gets, with nothing stored.
- **Fix what was refused**: every refusal has a closed `code`, and each code's fix is in [Errors and retries](https://withbaker.com/docs/errors.md).
- **Generate a client**: the [OpenAPI 3.1 description](https://withbaker.com/docs/openapi.json) works with any OpenAPI generator.

**Try it.** Send this to the real API with the public test key, `bk_test_public`: it is checked exactly like a company's request, answered the same way with `"mode": "test"`, and nothing is stored.

```bash
curl -X POST https://api.withbaker.com/v1/events \
  -H "Authorization: Bearer bk_test_public" \
  -H "Content-Type: application/json" \
  -d '{"events":[{"event_name":"lead","user_data":{"email":"laura@example.com"}}]}'
```

## What only a person does

- **Create the key** in Baker under **Settings → API Keys** (**Sending events only**), and put it in `BAKER_EVENTS_KEY` where the code runs. Never paste it into the agent's chat: a chat is a log somebody else keeps.
- **Decide what counts**: an event becomes a conversion when someone marks its name under **Conversions** in Baker. Nothing in a request can do it.
- **Go live**: remove `X-Baker-Mode: test` once the rehearsals come back clean.

## Add it to your repository

So every agent that works in your code later knows the rules, add this to your `AGENTS.md`, `CLAUDE.md` or `.cursorrules`:

```markdown
## Baker events API

- Contract: https://withbaker.com/docs/llms-full.txt (OpenAPI: https://withbaker.com/docs/openapi.json).
- POST https://api.withbaker.com/v1/events with Authorization: Bearer $BAKER_EVENTS_KEY. Never hardcode the key.
- Test with BAKER_EVENTS_KEY=bk_test_public and X-Baker-Mode: test; nothing is stored.
- A 200 can still refuse events: always read and log data.rejected.
- Every event carries a stable event_id from our own records, so retries count once.
```

## Every machine-readable file

| File | What it is |
| --- | --- |
| [/docs/llms.txt](https://withbaker.com/docs/llms.txt) | The index of these docs, in the llmstxt.org format. |
| [/docs/llms-full.txt](https://withbaker.com/docs/llms-full.txt) | Every page whole, in one file: hand this to an agent. |
| [/docs/openapi.json](https://withbaker.com/docs/openapi.json) | OpenAPI 3.1, generated from the schemas the API parses with. |
| [/docs/event-batch.schema.json](https://withbaker.com/docs/event-batch.schema.json) | The request body as JSON Schema (draft 2020-12). |
| `/docs/\<page>.md` | Any page as Markdown. Asking a page for `Accept: text/markdown` gets the same. |
| [/.well-known/api-catalog](https://withbaker.com/.well-known/api-catalog) | Where the API and its description are (RFC 9727). |

## Postman, Insomnia and Bruno

Import `https://withbaker.com/docs/openapi.json` as an OpenAPI file: every request, field and example arrives ready to send. Set the bearer token to `bk_test_public` to try it, or to your own key.

## Need help?

Write to support@withbaker.com: a person answers within 24 hours. The OpenAPI description is at https://withbaker.com/docs/openapi.json.
