# Email for AI agents, in one prompt

> Email for AI agents: copy one prompt into Claude Code, Cursor or Codex and your coding agent adds transactional email to your app with the Cresca API.

Canonical: https://www.cresca.xyz/agents
Last updated: 2026-12-03

Copy one prompt into Claude Code, Cursor or Codex. Your coding agent adds email to your app with the Cresca API: password resets, sign-up emails and receipts, sent from your own domain.

- Claude Code
- Cursor
- Codex

Coding agents

## Works with your coding agent

Paste the prompt once, or save it in your agent's project instructions so every future session sends email the same way.

- Claude Code

    Paste the prompt into a Claude Code session.

    Save it in `CLAUDE.md`

- Cursor

    Paste it into Agent chat.

    Save it in `.cursor/rules`

- Codex

    Paste it into a Codex task.

    Save it in `AGENTS.md`

- GitHub Copilot

    Paste it into Copilot Chat in agent mode.

    Save it in `.github/copilot-instructions.md`

- Windsurf

    Paste it into Cascade.

    Save it in `.windsurf/rules`

How it works

## Add email for AI agents in four steps

1. Step 1

    ### Set up sending in Cresca

    Create a free account, verify your sending domain and add a sender address. Then create an API key with Sending access.

    - [Sending domains](https://app.cresca.xyz/sending-domains)
    - [API keys](https://app.cresca.xyz/api-keys)
2. Step 2

    ### Put the key in your environment

    Add it to your server environment as CRESCA\_API\_KEY, for example in .env.local. The prompt tells the agent never to hard-code, log or commit it.

3. Step 3

    ### Copy the prompt into your agent

    Paste it into Claude Code, Cursor or Codex in the project you want to add email to. The agent lists the emails your app needs before it writes any code.

4. Step 4

    ### Review and send a test

    Check the list and the code, then let the agent send a test email to your own address. A working send returns an email id you can look up in the app.

    - [Transactional emails](https://app.cresca.xyz/transactional)

What's in the prompt

## What the prompt teaches your agent

Agents write better integrations when they know the rules up front. The prompt is short, but it covers what usually goes wrong with email code.

- **It asks before it codes.** The agent reads your project, lists the emails your app needs and asks for anything missing first.

- **Your key stays out of chat.** It never asks you to paste your API key, and tells you to revoke one that gets pasted.

- **The API.** Base URL, bearer-token auth and the request body for POST /emails and POST /emails/batch.

- **Server-only sending.** Calls stay in API routes, server actions and jobs, never in browser or mobile code.

- **No duplicate emails.** An Idempotency-Key per event, so a retried request returns the first result.

- **Safe retries.** Only network errors, timeouts, 429s and 5xx responses are retried, with backoff.

- **Readable errors.** Every error has a stable name, such as invalid\_from\_address, for logs and alerts.

- **One small module.** A single sendEmail() function instead of fetch calls spread through the codebase.

- **Templates and extras.** Template ids with variables, scheduling, cc and bcc, tags and attachments.

- **Tests go only to you.** The agent sends a test to your own address, shows you the id and ends with a short report.

For agents that read docs

## Docs your agent can read

The prompt links to the docs. Every docs page also has a Markdown version, listed in llms.txt, so agents can read it as plain text.

- [Quickstart Domain, sender, API key and a first send.](https://www.cresca.xyz/docs/quickstart)
- [Send email API Every field POST /emails accepts.](https://www.cresca.xyz/docs/api-reference/send-email)
- [llms.txt A machine-readable index of the docs and site.](https://www.cresca.xyz/llms.txt)

FAQ

## Email for AI agents: questions

### Can an AI agent send email with Cresca?

Yes. A coding agent such as Claude Code, Cursor or Codex can add Cresca to your app: your server calls the Cresca REST API to send password resets, receipts and notifications from your own verified domain. The prompt on this page gives the agent everything it needs.

### Does Cresca give AI agents an email inbox?

No. Cresca sends email; it does not receive it. This page is for agents that build email sending into your app, not for agents that need their own inbox.

### Which API key should the agent use?

A key with Sending access, stored as CRESCA\_API\_KEY in your server environment. It can send email but cannot read your logs or change templates, so a leaked key does less damage.

### Do I need an SDK?

No. The API is plain JSON over HTTPS, so the agent uses fetch or your platform’s HTTP client. The quickstart links step-by-step tutorials with a copy-paste client for Node.js, Python, PHP, Go, Ruby, Java, C#, Next.js, Laravel and Django.

### Is it free to try?

Yes. The Free plan runs for 30 days with no credit card and includes 1,000 emails, the API and the AI email agent for campaigns.

Give your agent an email API that just works

Free for 30 days, no credit card. 1,000 emails, the API and the AI email agent included.

[Start free](https://app.cresca.xyz/signup) [Read the quickstart](https://www.cresca.xyz/docs/quickstart)

## The prompt

The prompt the copy button copies. Paste it into Claude Code, Cursor or Codex in the project that should send email.

```text
Add transactional email to this app with Cresca, a REST email API (https://www.cresca.xyz).

Goal: the app's server sends its own emails (password resets, sign-up verification, receipts, notifications) through Cresca, from my verified domain.

Before you start
- Read this project first: package.json or the equivalent, .env.example, and any code that already sends email. Don't search the web.
- Then reply before writing code: list every email the app needs, say where each one is triggered, and ask me for anything below that is missing.
- Cresca docs are plain Markdown if you add .md to a docs URL, for example https://www.cresca.xyz/docs/quickstart.md. The index of every page is https://www.cresca.xyz/llms.txt. Open a doc only when a step needs it.

What I set up in the Cresca app (https://app.cresca.xyz)
- A verified sending domain and a sender on it, for example "Acme <hello@mail.acme.com>".
- An API key with Sending access, stored in the server environment as CRESCA_API_KEY.
- Never ask me to paste the key into this chat. If I paste one, don't use it: tell me to revoke it on the API keys page and create a new one.

API
- Base URL: https://api.cresca.xyz/api/v1
- Auth header: Authorization: Bearer $CRESCA_API_KEY
- Send one email: POST /emails with a JSON body:
  { "from": "Acme <hello@mail.acme.com>", "to": "user@example.com", "subject": "...", "html": "...", "text": "..." }
  "to" can be an array of up to 50 recipients.
  Optional fields: cc, bcc, reply_to, scheduled_at (ISO 8601, up to 30 days ahead), tags, headers,
  attachments (up to 20 files, 7 MB in total; each { "filename", "content" (base64), "content_type" }),
  template: { "id": "<template id or alias>", "variables": { "NAME": "Ana" } } instead of html/text.
- Send up to 100 different emails in one request: POST /emails/batch with a JSON array of email objects (all or nothing).
- A successful send returns { "id": "..." }.

Rules
1. Call the API only from server code (API routes, server actions, background jobs), never from browser or mobile code. Never hard-code, log or commit the key.
2. Send an Idempotency-Key header built from the event, for example "password-reset/<userId>/<tokenId>", so a retry never sends the email twice.
3. Retry only network errors, timeouts, 429 (rate_limit_exceeded) and 5xx responses, with exponential backoff (1s, 2s, 4s) or the retry-after header. Never retry other 4xx errors.
4. Errors return a stable "name", for example invalid_from_address, missing_required_field, validation_error, invalid_api_key, monthly_quota_exceeded or rate_limit_exceeded. Log that name.
5. Put the client in one small module (for example lib/email) that exports sendEmail(). Don't scatter fetch calls through the codebase.
6. Use the platform's fetch or HTTP client with a 10-second timeout. No SDK is needed.
7. Keep email copy short and plain, and always include a text version.
8. Send test emails only to my own address. Ask me before sending to anyone else.

If the app already sends email with another provider
- Keep the existing function names and call sites and change only what is inside them.
- Leave the old provider's code and keys in place until I confirm the Cresca sends work.

Steps
1. Reply with the list of emails and anything missing from my setup. Wait for my answer.
2. Add the sendEmail() module with the timeout, retries and idempotency key described above.
3. Wire it into each flow.
4. Add a way to send a test email to my own address, run it, and show me the returned id.
5. Finish with a short report: what you set up, which files changed, what is left for me to do, and at most two next steps.

Docs: https://www.cresca.xyz/docs
Quickstart: https://www.cresca.xyz/docs/quickstart
Send email API: https://www.cresca.xyz/docs/api-reference/send-email
Errors: https://www.cresca.xyz/docs/errors
Idempotency: https://www.cresca.xyz/docs/idempotency
Machine-readable index: https://www.cresca.xyz/llms.txt
```
