# Zapier

> Source: https://developers.anymail.watch/zapier/

The anymail app on Zapier sends events from your workspace to other tools the moment they happen, and lets other tools add prospects to anymail. It uses the [REST API](/) and [webhook subscriptions](/webhook-subscriptions/) underneath, so it does the same things you could build yourself, without code.

## Connect your account

1. In anymail open **Settings**, **Integrations**, **API keys** and create a key with the `read` and `write` scopes. It starts with `sgn_`.
2. In Zapier create a Zap, pick **anymail** as the app and choose a trigger or an action.
3. When Zapier asks you to sign in, paste the key. Zapier checks it with `GET /api/v1/workspaces` and names the connection after your workspace.

One key belongs to one workspace. To connect a second workspace, add a second connection with that workspace's key. To disconnect, delete the key in anymail. Zaps that use it stop with an authentication error.

## Triggers

All triggers are instant. When you turn a Zap on, Zapier subscribes a URL with `POST /api/v1/hooks`. When you turn it off, Zapier removes the subscription with `DELETE /api/v1/hooks/{id}`.

| Trigger | Fires when |
|---|---|
| New Reply | A prospect replies. It fires before the reply is classified. |
| Prospect Interested | A reply is classified as interested, by the classifier or by a person. |
| Prospect Maybe Later | A reply is classified as neutral. |
| Prospect Not Interested | A reply is classified as not interested. |
| Auto-Reply Received | A reply is recognised as an autoresponder. |
| Email Bounced | A message to a prospect bounces. |
| Prospect Unsubscribed | A prospect uses the one-click unsubscribe link. |
| Link Clicked | A prospect clicks a tracked link. |
| Email Opened | A tracked message is opened. Apple Mail loads the pixel without a person, so treat it as a weak signal. |
| New Prospect | A prospect is created in the app, by an import or through the API. |
| Campaign Paused | A campaign is paused, by a person or automatically. |
| Campaign Completed | A campaign ends. |

Every trigger returns the [webhook payload](/webhooks/#payload): `id`, `type`, `occurred_at`, `prospect_id`, `prospect_email`, `campaign_id`, `campaign_name` and `metadata`. In the Zap editor the **Test trigger** step shows the three latest real events of that kind from `GET /api/v1/hooks/samples?event=<event>`. Before the first event, it shows a sample.

## Actions

| Action | What it does |
|---|---|
| Create or Update Prospect | Looks the email up. A new address is created with `POST /api/v1/prospects`. An existing one is updated with `PATCH /api/v1/prospects/{id}`, and fields you leave empty keep their current value. Custom fields are merged. With a campaign selected, the prospect is also enrolled. |
| Add Prospect to Campaign | Enrols an existing prospect by email. The `result` field says `enrolled`, `already-enrolled`, `suppressed` or another outcome from [enrolment](/campaigns/). An address that is not a prospect stops the Zap with an error. |
| Add to Suppression List | Adds an email address or a whole domain to the [suppression list](/suppressions/). anymail never emails it again. An address that is already suppressed counts as done, not as an error. |

## Examples

- **Interested reply to a CRM deal.** Trigger: Prospect Interested. Action: create a deal in your CRM with `prospect_email` and `campaign_name`.
- **Form to campaign.** Trigger: a new form submission (Typeform, Tally, HubSpot). Action: Create or Update Prospect with the campaign selected.
- **Unsubscribe everywhere.** Trigger: Prospect Unsubscribed. Action: mark the contact as unsubscribed in your newsletter tool.
- **Bounces to a sheet.** Trigger: Email Bounced. Action: add a row to Google Sheets for list cleaning.

## Limits

Zapier calls count toward the [rate limit](/rate-limits/) of the key: 60 requests per minute. Create or Update Prospect makes up to four calls. Deliveries to Zapier are retried as described in [Webhooks](/webhooks/#delivery-and-retries).

## Troubleshooting

| Message | What to do |
|---|---|
| `anymail rejected the API key` | The key was deleted or mistyped. Create a new key and reconnect. |
| `insufficient_scope` | The key is read-only. Create a key with `write`. |
| `<email> is not a prospect in this workspace` | Use Create or Update Prospect before Add Prospect to Campaign, or use only the first with a campaign selected. |
| A trigger does not fire | Check that the Zap is on and that **Settings**, **Integrations** lists the subscription. Tracked opens and clicks need a verified [tracking domain](/domains/). |
