> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apten.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Opt Out

> Get notified when a lead opts out of messaging

The `optOut` webhook event is triggered whenever a lead opts out of receiving further messages from your Apten assistant. This can be used to update your CRM or other systems about the lead's communication preferences.

## Payload

### SMS Example

```json theme={null}
{
  "event": "optOut",
  "data": {
    "leadId": "a7e92c5d-f301-4b89-ae16-8f35d02cx9z",
    "externalLeadId": "003XX000004DHPY",
    "phone": "+13305551234",
    "channel": "sms",
    "optOutReason": null,
    "isTwilioOptOut": true,
    "optOutMessage": "STOP",
    "isDoNotContact": false
  },
  "timestamp": "2024-02-18T09:45:22Z"
}
```

### Email Example

```json theme={null}
{
  "event": "optOut",
  "data": {
    "leadId": "a7e92c5d-f301-4b89-ae16-8f35d02cx9z",
    "externalLeadId": "003XX000004DHPY",
    "phone": "+13305551234",
    "channel": "email",
    "optOutReason": "UNSUBSCRIBE_LINK",
    "isTwilioOptOut": null,
    "optOutMessage": "Please unsubscribe me from all future emails.",
    "isDoNotContact": false
  },
  "timestamp": "2024-02-18T09:45:22Z"
}
```

## Properties

| Property              | Type    | Description                                                                                                                                                                                                           |
| --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `event`               | string  | The webhook event type (`optOut`).                                                                                                                                                                                    |
| `data.leadId`         | string  | The unique identifier for the lead who opted out.                                                                                                                                                                     |
| `data.externalLeadId` | string  | The CRM lead ID (Salesforce, HubSpot, or Close CRM).                                                                                                                                                                  |
| `data.phone`          | string  | The phone number of the lead who opted out.                                                                                                                                                                           |
| `data.channel`        | string  | The communication channel for the opt-out. Can be `sms`, `email`, or `call`.                                                                                                                                          |
| `data.optOutReason`   | string  | The reason for the opt-out. Only set for email opt-outs, `null` for SMS and calls. Can be `MANUAL`, `COMPLAINT`, `BOUNCE`, or `UNSUBSCRIBE_LINK`.                                                                     |
| `data.isTwilioOptOut` | boolean | Indicates whether the opt-out was processed through Twilio. Will be `null` for email opt-outs.                                                                                                                        |
| `data.optOutMessage`  | string  | The message text that triggered the opt-out. Available for SMS and email opt-outs when the lead sent a message. Not included for call opt-outs or system-initiated opt-outs (bounces, complaints, unsubscribe links). |
| `data.isDoNotContact` | boolean | Whether the lead has an active do-not-contact flag at the time this opt-out was recorded. `true` only when the lead has explicitly requested to never be contacted on any channel (see the `doNotContact` event).     |
| `timestamp`           | string  | The ISO 8601 timestamp when the opt-out occurred.                                                                                                                                                                     |
