# Zapier and Groundmail

> **Early access.** The Groundmail app for Zapier is a beta that you install from a private invite link. It is not yet in Zapier's public app directory, so searching for "Groundmail" inside Zapier will not find it until you accept the invite. Invite link: [https://zapier.com/developer/public-invite/248164/3e89a0f9fd60ba08b25f3e10526fb505/](https://zapier.com/developer/public-invite/248164/3e89a0f9fd60ba08b25f3e10526fb505/)

With the app you can send email from a Zap and start Zaps instantly when an email is delivered, bounces, draws a spam complaint, or a reply arrives. If you would rather not use the beta, the same send works today with the built-in Webhooks by Zapier action; see [Without the app](#without-the-app).

---

## Prerequisites

- A Groundmail account with a [verified sending domain](https://docs.groundmail.dev/domains).
- A Zapier account.
- A Groundmail API key. A **full-access** key is the simplest choice: the triggers need it (see [Which key to use](#which-key-to-use)).

---

## Set up in five steps

1. Open the [invite link](https://zapier.com/developer/public-invite/248164/3e89a0f9fd60ba08b25f3e10526fb505/) while signed in to Zapier, and accept the invite.
2. Create a Zap (or edit an existing one).
3. For a trigger or action step, choose **Groundmail**.
4. Click **Sign in** to connect, and paste an API key from [app.groundmail.dev/api-keys](https://app.groundmail.dev/api-keys). The key starts with `gm_`.
5. Choose the event: **Send Email** as an action, or **Email Delivered**, **Email Bounced**, **Email Complained** or **Email Received** as a trigger.

### Which key to use

Use a full-access key. A send-only key can connect and can run **Send Email**, but the triggers need a full-access key: turning a Zap on registers a webhook, and the trigger's sample data reads your emails. If a trigger step shows a 403 `insufficient_scope` error, the key is send-only. A test key (`gm_test_…`, ticked as **Test key** on the API Keys page) runs the pipeline without delivering anything, which is handy for trying a Zap. Keys are described in [API keys](https://docs.groundmail.dev/api-keys).

---

## Send Email

| Field | Notes |
|-------|-------|
| From, To, Subject | Required. `from` must be on a verified domain. `To`, `CC`, `BCC` and `Reply-to` accept several addresses. |
| HTML body, Text body | Provide at least one. |
| Template, Template variables | Send a published [template](https://docs.groundmail.dev/templates) instead of writing the body in the Zap. |
| Tags | Up to 10 name and value pairs stored with the email. |
| Schedule at | Send later instead of right away. |
| Idempotency key | Map a value that is unique per email, such as an order id. Sending again with the same key within 24 hours returns the original result instead of a second email. See [Idempotency](https://docs.groundmail.dev/emails#idempotency). |

The step returns the email id and status. Follow delivery under **Emails** in the dashboard. Every field is described in [Emails](https://docs.groundmail.dev/emails).

---

## Triggers

Triggers fire instantly. Turning a Zap on registers a webhook with Groundmail, and turning it off removes it.

| Trigger | Fires when |
|---------|-----------|
| Email Delivered | An email reaches the recipient's mailbox provider. |
| Email Bounced | An email bounces. `bounce_type` is `hard` (the address cannot receive mail) or `block` (the receiving server refused the sender). |
| Email Complained | A recipient marks an email as spam. |
| Email Received | An email arrives on a domain with receiving turned on. Attachment names and sizes are included, not the file contents. |

### Test a trigger

Build a Zap with the trigger, then send an email to a simulator address from a **Send Email** step, the [API](https://docs.groundmail.dev/emails) or the dashboard. Simulator addresses never reach a real inbox:

| Trigger | Send to |
|---------|---------|
| Email Delivered | `delivered@simulator.groundmail.dev` |
| Email Bounced | `bounce@simulator.groundmail.dev` |
| Email Complained | `complaint@simulator.groundmail.dev` (a delivered event first, then the complaint a few seconds later) |

Simulator addresses are also accepted by apps and forms that check the domain's MX record before they allow an address, because `simulator.groundmail.dev` has one. The full list is in [Testing](https://docs.groundmail.dev/testing).

### Receiving email

**Email Received** needs a domain with inbound receiving turned on. Turn it on for the domain in the dashboard, add the MX record it shows, then send a message to any address at that domain. See [Inbound email](https://docs.groundmail.dev/api/inbound).

---

## Troubleshooting

**401 `unauthorized`.** The key is wrong, revoked or inactive. Check it on the API Keys page and reconnect Groundmail in Zapier with a fresh key.

**403 `insufficient_scope`.** The key lacks a permission. Triggers need a full-access key; sending needs at least `emails:send`. Create a full-access key and reconnect.

**403 `forbidden` or `domain_not_allowed`.** The domain in `from` is not verified on your account, the key is limited to other domains, or the account is still on the sandbox sender, which only sends to your own account email. Verify the domain under [Domains](https://docs.groundmail.dev/domains).

**429.** You hit a sending or request limit. Zapier retries after the time Groundmail asks for. See [Sending limits](https://docs.groundmail.dev/sending-limits).

**422 `validation_error` with `suppressed`.** Every recipient is on your suppression list. See [Suppressions](https://docs.groundmail.dev/suppressions).

**A send timed out (504).** The Zap stops instead of retrying, because the email may already be on its way. Check **Emails** in the dashboard before sending it again, or use an idempotency key.

More in [Errors](https://docs.groundmail.dev/errors).

---

## Without the app

You do not need the beta to send from Zapier. The **Webhooks by Zapier** action posts to the Groundmail API directly. This needs a Zapier plan that includes Webhooks by Zapier. Use a **Send only** key limited to your sending domain here: a key in a Zap is visible to anyone who can edit it.

### Add the action

1. In the Zap editor, click the plus icon and choose **Webhooks by Zapier**.
2. In the **Event** dropdown, choose **POST**, then continue.
3. Fill in the action:

| Zapier field | Value |
|--------------|-------|
| URL | `https://api.groundmail.dev/emails` |
| Payload Type | `JSON` |
| Data | One row per field, below |
| Headers | `Authorization` = `Bearer gm_…` |

Rows for **Data** (the key on the left, the value on the right; use fields from your trigger for the values):

| Key | Value |
|-----|-------|
| `from` | `notifications@yourdomain.com` |
| `to` | The recipient's email from your trigger |
| `subject` | Your subject line, with trigger fields if you like |
| `html` | The HTML body, for example `<p>Hi {{name}}, your order shipped.</p>` |
| `text` | A plain-text version of the same message |

`from` must be on a verified domain. At least one of `html` or `text` is required. Add `reply_to`, `cc` or `bcc` rows the same way; see [Emails](https://docs.groundmail.dev/emails) for every field.

To make a replayed Zap run harmless, add a second header, `Idempotency-Key`, set to a value from your trigger that is unique per event (an order id, for example). Groundmail returns the original response instead of sending twice for 24 hours. See [Idempotency](https://docs.groundmail.dev/emails#idempotency).

If you need the body to be exact JSON, or the API rejects the request as invalid, use the **Custom Request** event instead. It sends what you type without parsing it, so set the method to `POST`, add a `Content-Type: application/json` header next to the `Authorization` header, and paste the JSON body.

---

### Test it

Click **Test step**. With a test key (`gm_test_…`, created by ticking **Test key** on the API Keys page) Groundmail runs the whole pipeline but delivers nothing, so you can test with any recipient. A successful response looks like this:

```json
{ "id": "msg_…", "status": "sent", "test": true }
```

You can also use a live key and send to `delivered@simulator.groundmail.dev`, which never reaches a real inbox and produces a delivered event. To see what a failure looks like, use `bounce@simulator.groundmail.dev`. The full list is in [Testing](https://docs.groundmail.dev/testing).

Check the result under **Emails** in the Groundmail dashboard. When you are done, replace the test key with a live key.

To react to a bounce or delivery without the app, create a [webhook](https://docs.groundmail.dev/webhooks) pointing at a **Catch Hook** trigger in a second Zap.

---

## Also available

- [Webhooks](https://docs.groundmail.dev/webhooks) for any tool that can receive an HTTP request.
- [n8n](https://docs.groundmail.dev/guides/n8n), a community node for n8n.
- [Make](https://docs.groundmail.dev/integrations/http#make), using the HTTP app. A dedicated Make app is coming.
- [Pabbly Connect](https://docs.groundmail.dev/integrations/http#pabbly-connect), [Pipedream](https://docs.groundmail.dev/integrations/http#pipedream) and any other tool with an [HTTP step](https://docs.groundmail.dev/integrations/http).
