# Webhook events (/webhook-events)

Use these events as the trigger of a workflow with a **Webhook** step. Setting one up is covered in [Webhooks](/webhooks).

## Internal events [#internal-events]

Plunk automatically tracks a set of internal events that you can use as workflow triggers. These events cannot be manually tracked via the API — they are generated by the system.

### Email events [#email-events]

| Event             | Description                                                                                              |
| ----------------- | -------------------------------------------------------------------------------------------------------- |
| `email.sent`      | An email was successfully sent                                                                           |
| `email.delivery`  | An email was delivered to the recipient                                                                  |
| `email.open`      | A contact opened an email. Opens SES marks as automated are left out                                     |
| `email.click`     | A contact clicked a link in an email                                                                     |
| `email.bounce`    | An email bounced (hard or soft bounce)                                                                   |
| `email.complaint` | A contact marked an email as spam                                                                        |
| `email.received`  | An email was received at your verified domain (requires [inbound email setup](/receiving-emails)) |

### Contact events [#contact-events]

| Event                  | Description                                             |
| ---------------------- | ------------------------------------------------------- |
| `contact.subscribed`   | A contact's subscription status changed to subscribed   |
| `contact.unsubscribed` | A contact's subscription status changed to unsubscribed |

### Segment events [#segment-events]

| Event                  | Description                 |
| ---------------------- | --------------------------- |
| `segment.<name>.entry` | A contact entered a segment |
| `segment.<name>.exit`  | A contact exited a segment  |

<Callout title="Segment event names" type="info">
Segment events use a slugified version of the segment name. For example, a segment called "VIP Users" would produce
the events `segment.vip-users.entry` and `segment.vip-users.exit`.
</Callout>

## Webhook payload [#webhook-payload]

When using the default payload (no custom body configured), Plunk sends a JSON request with the following structure:

```json
{
  "contact": {
    "email": "user@example.com",
    "subscribed": true,
    "data": {
      "name": "John",
      "plan": "pro"
    }
  },
  "workflow": {
    "id": "wf_abc123",
    "name": "Bounce Notifications"
  },
  "execution": {
    "id": "exec_xyz789",
    "startedAt": "2025-01-15T10:30:00.000Z"
  },
  "event": {
    "subject": "Welcome to Plunk",
    "from": "hello@example.com",
    "fromName": "Plunk Team",
    "messageId": "ses-message-id",
    "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
    "templateId": null,
    "campaignId": "camp_abc123",
    "sourceType": "CAMPAIGN",
    "bounceType": "Permanent",
    "bouncedAt": "2025-01-15T10:30:00.000Z"
  }
}
```

The `event` field contains the data associated with the event that triggered the workflow. The exact contents depend on the event type.

### Event data by type [#event-data-by-type]

#### Email events [#email-events-1]

Most email events share a common set of base fields:

<TypeTable type={{"subject":{"type":"string","description":"The email subject line."},"from":{"type":"string","description":"The sender email address."},"fromName":{"type":"string","description":"The sender display name."},"messageId":{"type":"string","description":"Provider-side message identifier (useful for correlating with delivery logs)."},"emailId":{"type":"string","description":"The Plunk email record ID — returned from `POST /v1/send`, used for correlating webhooks with API responses."},"templateId":{"type":"string","description":"The template ID, if the email was sent using a template. Otherwise `null`."},"campaignId":{"type":"string","description":"The campaign ID, if the email was part of a campaign. Otherwise `null`."},"sourceType":{"type":"string","description":"How the email was triggered. One of `TRANSACTIONAL`, `CAMPAIGN`, `WORKFLOW`, or `INBOUND`."}}} />

In addition to these base fields, each event includes the following event-specific fields. The base fields above (`subject`, `from`, `fromName`, `messageId`, `emailId`, `templateId`, `campaignId`, `sourceType`) are present on every email event in addition to the event-specific fields shown below.

<Tabs items={["email.sent","email.delivery","email.open","email.click","email.bounce","email.complaint","email.received"]}>
<Tab value="email.sent">
```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "sentAt": "2025-01-15T10:30:00.000Z"
}
```

<TypeTable type={{"sentAt":{"type":"string","description":"ISO 8601 timestamp of when the email was accepted for delivery."}}} />
</Tab>

<Tab value="email.delivery">
```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": "camp_abc123",
  "sourceType": "CAMPAIGN",
  "deliveredAt": "2025-01-15T10:30:05.000Z"
}
```

<TypeTable type={{"deliveredAt":{"type":"string","description":"ISO 8601 timestamp of when the email was delivered to the recipient."}}} />
</Tab>

<Tab value="email.open">
```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "openedAt": "2025-01-15T11:00:00.000Z",
  "opens": 1,
  "isFirstOpen": true
}
```

<TypeTable type={{"openedAt":{"type":"string","description":"ISO 8601 timestamp of the first open."},"opens":{"type":"number","description":"Total number of times this email has been opened."},"isFirstOpen":{"type":"boolean","description":"`true` if this is the first time the contact opened this email."}}} />
</Tab>

<Tab value="email.click">
```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "link": "https://example.com/pricing",
  "clickedAt": "2025-01-15T11:05:00.000Z",
  "clicks": 1,
  "isFirstClick": true
}
```

<TypeTable type={{"link":{"type":"string","description":"The URL that was clicked."},"clickedAt":{"type":"string","description":"ISO 8601 timestamp of the first click."},"clicks":{"type":"number","description":"Total number of clicks on links in this email."},"isFirstClick":{"type":"boolean","description":"`true` if this is the first click from this contact on this email."}}} />
</Tab>

<Tab value="email.bounce">
Permanent bounce:

```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "bounceType": "Permanent",
  "bouncedAt": "2025-01-15T10:31:00.000Z"
}
```

Transient (soft) bounce:

```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "bounceType": "Transient",
  "transientBounce": true
}
```

<TypeTable />

<Callout title="Bounce rate impact" type="warn">
Only `Permanent` bounces count toward your project's bounce rate and trigger automatic contact unsubscription.
`Transient` bounces are tracked for visibility only.
</Callout>

When `suppressedByProvider` is `true`, the address previously hard-bounced or reported spam and the email was not
sent. The contact is unsubscribed, but the event carries no `bouncedAt` and does not count toward your bounce rate.
</Tab>

<Tab value="email.complaint">
```json
{
  "subject": "Welcome to Plunk",
  "from": "hello@example.com",
  "fromName": "Plunk Team",
  "messageId": "ses-message-id",
  "emailId": "ac32f08e-c6b9-45d3-9824-a73dff1e3bbf",
  "templateId": null,
  "campaignId": null,
  "sourceType": "TRANSACTIONAL",
  "complainedAt": "2025-01-15T10:35:00.000Z",
  "complaintFeedbackType": "abuse",
  "complaintSubType": null,
  "userAgent": "Microsoft Junk Mail Reporting Program",
  "feedbackId": "feedback-id",
  "arrivalDate": "2025-01-15T10:34:12.000Z"
}
```

<TypeTable />
</Tab>

<Tab value="email.received">
This event fires when an email is received at your verified domain. See [Receiving Emails](/receiving-emails) for setup instructions.

```json
{
  "messageId": "ses-message-id",
  "from": "sender@example.com",
  "fromHeader": "Jane Smith <sender@example.com>",
  "to": "support@yourdomain.com",
  "subject": "Re: Your question",
  "timestamp": "2025-01-15T10:30:00.000Z",
  "recipients": ["support@yourdomain.com"],
  "hasContent": true,
  "body": "<html><body>This is the email body content...</body></html>",
  "spamVerdict": "PASS",
  "virusVerdict": "PASS",
  "spfVerdict": "PASS",
  "dkimVerdict": "PASS",
  "dmarcVerdict": "PASS",
  "processingTimeMillis": 142
}
```

<TypeTable />
</Tab>
</Tabs>

#### Contact events [#contact-events-1]

`contact.subscribed` and `contact.unsubscribed` carry no event data by default. The `event` field will be an empty object `{}`.

The exception is when an unsubscription is triggered automatically by an email bounce or complaint — in that case `event` includes a `reason` field:

```json
{
  "reason": "bounce"
}
```

<TypeTable type={{"reason":{"type":"string","description":"Why the contact was unsubscribed. One of `bounce` or `complaint`. Only present when triggered automatically by a bounce or complaint."}}} />

#### Segment events [#segment-events-1]

Both `segment.<name>.entry` and `segment.<name>.exit` include:

```json
{
  "segmentId": "seg_abc123",
  "segmentName": "VIP Users"
}
```

<TypeTable type={{"segmentId":{"type":"string","description":"The ID of the segment."},"segmentName":{"type":"string","description":"The display name of the segment."}}} />

#### Custom events [#custom-events]

Custom events tracked via the API include whatever data you passed in the `data` field when calling `track`.

#### No event data [#no-event-data]

For events that carry no data, the `event` field will be an empty object `{}`.