# Add email to your app with one prompt

Paste one prompt into Claude Code, Cursor, Codex or any coding agent that can run shell commands. The agent signs you in (or up), sends a test email to you, verifies your sending domain, creates a send-only key for your app and wires your first real email, such as a password reset or a receipt.

No API key to copy: the agent signs in through your browser. It asks you before it emails anyone but you, changes DNS or touches billing.

**Related:** [Agent Skills](https://docs.groundmail.dev/ai/agent-skills) · [MCP server](https://docs.groundmail.dev/ai/mcp) · [Test sends and idempotency](https://docs.groundmail.dev/ai/safe-defaults) · [Quickstart](https://docs.groundmail.dev/quickstart)

---

## The prompt

Copy this into your agent from the root of your project:

````text
Set up Groundmail (transactional email) in this project. Do the work yourself.
Ask me before anything that emails anyone except me, changes DNS, or touches billing.

## 1. Install and sign in
```bash
npm install -g groundmail-cli   # or put `npx -y groundmail-cli` in place of `groundmail` below
groundmail login
```
`login` opens my browser: tell me to sign up if I don't have an account yet, then click Approve. Then run `groundmail whoami`: it shows my account email, used below.
No API key is needed for this: the sign-in covers every `groundmail` command. (In CI, `GROUNDMAIL_API_KEY` is used instead.)

## 2. Prove it works (sandbox, no domain needed)
```bash
groundmail emails send --from noreply@mail.groundmail.dev --to <my account email> \
  --subject "Groundmail works" --html "<p>It works.</p>" --watch
```
`--watch` waits until the mail server for my inbox accepts it and prints that server's reply and how long it took (exit code 0 when delivered). Without it you get an id like `msg_…`; check on it with `groundmail emails get <id> --watch`.

## 3. Sending domain (ask me which domain first)
```bash
groundmail domains add <domain>
groundmail domains apply <domain> --provider cloudflare   # or vercel / godaddy
groundmail domains verify <domain>
```
If my DNS is somewhere else, show me the records from `groundmail domains get <domain>` to add. DNS can take a few minutes; re-run verify until it says verified.

## 4. Wire it into the app
- Make a send-only key for the app:
  `groundmail keys create --name "<app> production" --scopes emails:send`
- Save it as `GROUNDMAIL_API_KEY` wherever this project keeps secrets. Server-side only; never commit it or expose it to the browser.
- Install the SDK (`npm install groundmail`; Python, PHP, Ruby and Go SDKs exist too) and add one send helper that follows this project’s patterns. The API base URL is https://api.groundmail.dev.
- Use it for the first real flow I name (password reset, receipt, …).
- Give every send an `Idempotency-Key` header (SDK option `idempotencyKey`) unique to the message, and reuse it on retries.
- On an error, branch on `error.code` and follow `error.hint`. Retry only 429, 500, 502 and 503, with backoff and the same Idempotency-Key.
- Prefer the canonical field names (`html`, `text`, `reply_to`).

## 5. Before real traffic
The free plan only sends to my account email until a domain is verified and a payment method is on file (no charge unless I turn on pay as you go). If I need to add one, send me to https://app.groundmail.dev/settings/billing.

## Done when
- The test email arrived at my account email.
- The domain is verified.
- One real flow in the app sends through Groundmail.

## Reference
- Optional Agent Skills: `npx skills add Groundmail/groundmail-skills --skill groundmail -y` (https://docs.groundmail.dev/ai/agent-skills)
- Agent notes: https://docs.groundmail.dev/ai/agent-skill
- Quickstart: https://docs.groundmail.dev/quickstart
- Errors: https://docs.groundmail.dev/errors
- llms.txt: https://docs.groundmail.dev/llms.txt
- OpenAPI: https://docs.groundmail.dev/openapi.yaml
- Dashboard: https://app.groundmail.dev
````

Signed in already? The **Copy agent prompt** button on your dashboard **Home** page gives you the same prompt with your account email filled in.

---

## What you need

- **A domain you control**, and access to its DNS. With Cloudflare, Vercel, GoDaddy, Netlify, DigitalOcean or DNSimple the agent can add the records for you; anywhere else it shows you the records to add.
- **A payment method on file** before you email anyone except yourself. The Free plan is never charged: 3,000 emails a month, 100 a day. Everything before that, including the test email and domain verification, works without one.

---

## Make your agent better at email

Each of these is optional. They give your agent Groundmail's defaults (idempotency keys, error hints, safe test sends) every time it touches email, not only during setup.

| Agent | Install |
|-------|---------|
| Claude Code | `/plugin marketplace add Groundmail/groundmail-skills`, then `/plugin install groundmail@groundmail` (skills plus the MCP server) |
| Cursor, Codex, Gemini CLI and other agents | `npx skills add Groundmail/groundmail-skills -y` |
| Cursor (project rule) | [Cursor rules](https://docs.groundmail.dev/ai/cursor-rules) |
| Claude, ChatGPT, Cursor (MCP tools) | Connect `https://mcp.groundmail.dev/mcp` and sign in. See [MCP server](https://docs.groundmail.dev/ai/mcp) |

The skills cover sending with `POST /emails`, the SDKs (Node, Python, Go, PHP, Ruby), SMTP, domain verification, webhooks, test sends and error handling. Details: [Agent Skills](https://docs.groundmail.dev/ai/agent-skills).

---

## For agents: machine-readable docs

- [llms.txt](https://docs.groundmail.dev/llms.txt): index of every docs page, with key facts
- [llms-full.txt](https://docs.groundmail.dev/llms-full.txt): every docs page in one file
- [pricing.json](https://docs.groundmail.dev/pricing.json): every plan's price, monthly and daily limits, pay-as-you-go rates, domain and tenant limits, and the new-account sending ramp
- [OpenAPI](https://docs.groundmail.dev/openapi.yaml): the API contract
- [Agent Skills index](https://docs.groundmail.dev/.well-known/agent-skills/index.json)
