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

# program_events/customer.moved_to_defected_segment

export const InsightWebhookPayload = () => <>
    <ResponseField name="customer" type="object" required>
      Customer object with the same shape as the{' '}
      <a href="/api-reference/v2/resources/customers/list-customers#response-customers">
        Customers API
      </a>{' '}
      response
    </ResponseField>

    <ResponseField name="new_insight_segment" type="string" required>
      The name of the insight segment that the customer has moved into
    </ResponseField>

    <ResponseField name="previous_insight_segment" type="string | null" required>
      The name of the insight segment that the customer has moved from, or <code>null</code>
      if they were not previously in a segment
    </ResponseField>

    <ResponseField name="frequency" type="number | null" required>
      The number of orders the customer has placed
    </ResponseField>

    <ResponseField name="total_spend" type="number | null" required>
      The total lifetime spend of the customer in currency subunits, e.g. $150 will be <code>15000</code>
    </ResponseField>

    <ResponseField name="last_order_date" type="string | null" required>
      <code>ISO 8601</code> timestamp of the customer's last order
    </ResponseField>

    <ResponseField name="average_basket_size" type="number | null" required>
      Average value of the customer's basket
    </ResponseField>

  </>;

This webhook triggers when a customer moves to the Win Back insight segment. Note
that while the webhook contains the word `defected` the segment is always
referred to as 'Win Back'.

To subscribe to this topic your access token needs to contain the
`read_customers` scope.

## Payload

<InsightWebhookPayload />

## Example

```json Example theme={null}
{
  "id": "bff1bddb-6cd8-4c2c-9619-18744657053c",
  "topic": "program_events/customer.moved_to_defected_segment",
  "created_at": "2018-01-01T03:00:05.000Z",
  "payload": {
    "customer": {
      "id": 6932,
      "merchant_id": "2134606599",
      "email": "jessica@example.com",
      "points_approved": 200,
      "points_pending": 300,
      "points_spent": 500,
      "rewards_claimed": 5,
      "rewards_used": 0,
      "properties": {},
      "metadata": {},
      "birthday": "1990-01-29",
      "blocked": false,
      "guest": false,
      "enrolled": true,
      "enrolled_at": "2015-12-10T03:00:00.000Z",
      "referral_id": null,
      "referred_by": null,
      "loyalty_tier_membership": null,
      "tier_eligibility": null,
      "insights_segment": "Win Back",
      "referral_url": "https://prz.io/KzByQ2Fa",
      "created_at": "2016-12-10T03:00:00.000Z",
      "updated_at": "2018-01-01T03:00:00.000Z"
    },
    "frequency": 1,
    "total_spend": 4500,
    "last_order_date": "2020-11-11T19:18:39.928Z",
    "average_basket_size": 4500,
    "new_insight_segment": "Win Back",
    "previous_insight_segment": "At Risk"
  }
}
```
