> ## 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 In

> Get notified when a lead re-subscribes after previously opting out

The `optIn` webhook event fires when a lead re-subscribes to a channel they had
previously opted out of. It is the mirror of the [`optOut`](/webhooks/opt-out)
event, and can be used to re-enable messaging for the lead in your CRM or other
systems.

Like `optOut`, this event fires **per channel**: if a lead re-subscribes to more
than one channel at once, you receive one event per channel.

## Payload

### SMS Example

A lead texts `START` to re-subscribe to SMS.

```json theme={null}
{
  "event": "optIn",
  "data": {
    "leadId": "a7e92c5d-f301-4b89-ae16-8f35d02cx9z",
    "externalLeadId": "003XX000004DHPY",
    "channel": "sms",
    "phone": "+13305551234",
    "email": null,
    "optInMessage": "START",
    "triggeredBy": "keyword"
  },
  "timestamp": "2024-02-18T09:45:22Z"
}
```

### API Example

A lead is re-subscribed through the
[`POST /leads/{leadId}/resubscribe`](/api-reference/leads/resubscribe) endpoint.

```json theme={null}
{
  "event": "optIn",
  "data": {
    "leadId": "a7e92c5d-f301-4b89-ae16-8f35d02cx9z",
    "externalLeadId": "003XX000004DHPY",
    "channel": "email",
    "phone": "+13305551234",
    "email": "lead@example.com",
    "triggeredBy": "manual"
  },
  "timestamp": "2024-02-18T09:45:22Z"
}
```

## Properties

| Property              | Type   | Description                                                                                                                                                                                              |
| --------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `event`               | string | The webhook event type (`optIn`).                                                                                                                                                                        |
| `data.leadId`         | string | The unique identifier for the lead who opted back in.                                                                                                                                                    |
| `data.externalLeadId` | string | The CRM lead ID (Salesforce, HubSpot, or Close CRM). Omitted when the lead has no linked CRM record.                                                                                                     |
| `data.channel`        | string | The channel the lead re-subscribed to. One of `sms`, `email`, or `call`.                                                                                                                                 |
| `data.phone`          | string | The phone number of the lead. `null` when no phone is on file.                                                                                                                                           |
| `data.email`          | string | The email address of the lead. `null` when no email is on file.                                                                                                                                          |
| `data.optInMessage`   | string | The message text that triggered the opt-in (e.g. `START`). Included only when the lead sent a message; omitted for API-initiated and coupled opt-ins.                                                    |
| `data.triggeredBy`    | string | What caused the opt-in. `keyword` — the lead sent a re-subscribe message. `manual` — the lead was re-subscribed through the API. `coupling` — the channel was re-subscribed alongside a coupled channel. |
| `timestamp`           | string | The ISO 8601 timestamp when the opt-in occurred.                                                                                                                                                         |

<Note>
  **Coupled channels.** When SMS and voice are coupled for your organization,
  re-subscribing one re-subscribes the other. The channel the lead acted on
  carries `triggeredBy: "keyword"` or `"manual"`; the coupled channel emits its
  own event with `triggeredBy: "coupling"`.
</Note>

<Note>
  This event fires only when a channel actually transitions from opted-out to
  opted-in. A channel that was never opted out produces no event. Because the
  event is delivered at least once, your endpoint should handle occasional
  duplicates idempotently.
</Note>

<Note>
  Opting back in on any channel also clears an active
  [do-not-contact](/webhooks/do-not-contact) flag for the lead. There is no
  separate event for this — treat any `optIn` as also clearing do-not-contact.
</Note>
