---
title: "Insider Webhook Templates"
description: "Send Lytics audience entrances and exits to Insider as profile updates and events, using an Audience Triggers Webhook job and a webhook template."
url: "https://www.contentstack.com/docs/lytics/insider-webhook-templates"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# Insider Webhook Templates

Send Lytics audience entrances and exits to Insider as profile updates and events, using an Audience Triggers Webhook job and a webhook template.

## Overview

This guide sends Lytics audience entrances and exits to Insider through an [Audience Triggers Webhook](/docs/lytics/webhooks) job, with a [template](/docs/lytics/templates-1) that shapes each request for Insider's APIs. Use it when you need control over the payload, for example to record each entrance and exit as an Insider event. To sync audience membership without writing a template, use the [Insider](/docs/lytics/insider) Export Audiences job instead.

The examples on this page are written in both Jsonnet and JavaScript. For the template languages and their helper libraries, see [Templates](/docs/lytics/templates-1).

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am2b08dbcced3266d9/250d576e13638df3cdee4b19/a057355-Group_3081.svg)

## Authorization

If you haven't already done so, you will need to set up an Insider account before you begin the process described below.

The requests go through the Webhooks integration, so the authorization is a Webhook authorization that sends your Insider credentials as request headers. If you are new to creating authorizations in Lytics, see the [Authorizations](/docs/lytics/keys-authorizations) documentation.

### Select Provider

Begin by selecting the **Webhooks** provider tile.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am39a9c5484019dcd2/72f915473794b0baf8e2012c/9c6ef6f-Screenshot_2023-09-14_at_11.21.21_AM.png)

### Select Method

Next, select an authorization method. If this is your first time creating an authorization for Insider, select **Provide authorization as request header or parameter**.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/amba078c82845bcfa3/da505ef9d4af4aecc7bceb2d/5fc3c4a-Screenshot_2023-09-14_at_11.22.25_AM.png)

### Configure Authorization

Next, configure the authorization to use the request headers provided by Insider. Configure all fields as outlined below, and leave any additional fields blank unless you fully understand the implications.

#### Label

Create a label for your authorization. This will only surface in the Lytics UI for easy navigation when selecting the authorization in additional workflows or reviewing the details and logs.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am5d23520d6e503f06/aeaea027806befe6a62bbe43/8de511c-Screenshot_2023-09-14_at_11.26.11_AM.png)

#### Description

Add an optional description to provide context for where the auth came from and how it will be used.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am753ca4bb729d8d89/422583506dd2958fb3f07441/b8c9fcd-Screenshot_2023-09-14_at_11.26.35_AM.png)

#### Webhook Request Headers

Insider will provide both the **X-PARTNER-NAME** and the **X-REQUEST-TOKEN**.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am270d69ca24806c93/58098abb2e2a02774e07a9ed/6475bd6-Screenshot_2023-09-14_at_11.29.27_AM.png)

```
X-PARTNER-NAME: XXXXXXX
X-REQUEST-TOKEN: XXXXXXX
```

#### Webhook Request Parameters

Leave this field blank.

## Audience Entrance Triggers

### Integration Details

*   **Implementation Type**: Server-side Integration.
*   **Implementation Technique**: REST API Integrations - Audience Trigger Integration - Webhook Integration
*   **Frequency**: Real-time Integration that continuously enriches users as they enter a source audience.
*   **Resulting data**: Updated profile in Insider with the correct segment membership.

This integration uses the [Audience Triggers Webhook](/docs/lytics/webhooks) to send a secure request to Insider when a user enters the source audience. The request is sent to the POST api/user/v1/upsert endpoint and contains the user data configured in the template described below, so Insider receives a Lytics profile with extended information about that user. The Insider [upsert API docs](https://academy.useinsider.com/docs/upsert-user-data-api) describe the information that can be sent. To enable this workflow:

1.  Create an **Authorization** to Insider.
2.  Create a **source audience** to determine which profiles need to be sent.
3.  Create a **webhook template** to format the outbound request so it sends new segment membership to the Insider APIs correctly.
4.  Create the real-time **webhook** sync between Lytics and Insider using the corresponding template.
5.  **Validate** that the webhook flow is working as expected.

### Authorization

Select or configure a new authorization as outlined [above](#authorization).

### Create the Entrance Template

Templates provide a flexible way to reformat the outbound payload of a webhook request to meet the recipient's requirements. In this case, the template formats identifiers, attributes, and event data for the Insider user API. This step may appear technical; if you need assistance, contact your technical account manager or primary point of contact.

The examples below show how to structure the template to send segment entrances, segment metadata, and profile attributes to Insider. Each one creates the template through the [Lytics API](/docs/lytics/api-created-templates). The Insider upsert [API docs](https://academy.useinsider.com/docs/upsert-user-data-api) have more information on how the data should be structured.

#### Jsonnet Example

```
echo 'local event = (import "lytemplates.libsonnet");
local eventDetails = event.get("segment_events", "")[0];
{
  "users": [
    {
      "insider_id": event.get("insider_id", ""),
      "identifiers": {
        "email": event.get("email", ""),
        "custom": {
          "lytics_id": event.get("_id", ""),
          "lytics_last_uid": event.get("_uid", "")
        }
      },
      "attributes": {
        "email": event.get("email", ""),
        "phone_number": event.get("phone", ""),
        "name": event.get("first_name", ""),
        "surname": event.get("last_name", ""),
        "gender": event.get("gender", ""),
        "age": event.get("age", ""),
        "language": event.get("user_language", ""),
        "country": event.get("visit_country", ""),
        "city": event.get("visit_city", ""),
        "email_optin": event.get("consent_email_status", ""),
        "gdpr_optin": event.get("consent_gdpr_status", ""),
        "sms_optin": event.get("consent_sms_status", ""),
        "whatsapp_optin": event.get("consent_whatsapp_status", ""),
        "custom": {
          "status":  event.get("status", ""),
          "lytics_computed_attr": event.get("_segments", [""]),
          "score_consistency": event.get("score_consistency", ""),
          "score_frequency": event.get("score_frequency", ""),
          "score_intensity": event.get("score_intensity", ""),
          "score_maturity": event.get("score_maturity", ""),
          "score_momentum": event.get("score_momentum", ""),
          "score_propensity": event.get("score_propensity", ""),
          "score_quantity": event.get("score_quantity", ""),
          "score_recency": event.get("score_recency", ""),
          "score_volatility": event.get("score_volatility", ""),
          "lytics_content": event.get("lytics_content", ""),
          "lytics_content_inferred": event.get("lytics_content_inferred", ""),
          "lytics_rollup": event.get("lytics_rollup", ""),
          "segment_prediction_percentile": event.get("segment_prediction_percentile", "")
        }
      },
      "not_append": true,
      "events": [
        {
          "event_name": "lytics_trigger",
          "timestamp": eventDetails["enter"],
          "event_params": {
            "custom": {
              "id": eventDetails["id"],
              "audience": eventDetails["slug"],
              "trigger": eventDetails["event"],
              "origin": "Lytics"
            }
          }
        }
      ]
    }
  ]
}' | http -v POST https://api.lytics.io/v2/template name==insider_temp type==jsonnet account_id=={YOUR-ACCOUNT-ID} key=={YOUR-API-TOKEN}
```

Each value in the example is read from the profile with event.get(). Its first argument is the field name as defined in your Lytics schema, so to send another field, add a line like this one:

```
local event = (import "lytemplates.libsonnet");
{
  "field_name_to_send_to_insider": event.get("lytics_field_name", ""),
}
```

#### JavaScript Example

The equivalent entrance template written in JavaScript reads profile fields directly from the data argument:

```
echo 'function template(data) {
  var eventDetails = (data.segment_events || [{}])[0];
  return {
    "users": [
      {
        "insider_id": data.insider_id || "",
        "identifiers": {
          "email": data.email || "",
          "custom": {
            "lytics_id": data._id || "",
            "lytics_last_uid": data._uid || ""
          }
        },
        "attributes": {
          "email": data.email || "",
          "phone_number": data.phone || "",
          "name": data.first_name || "",
          "surname": data.last_name || "",
          "gender": data.gender || "",
          "age": data.age || "",
          "language": data.user_language || "",
          "country": data.visit_country || "",
          "city": data.visit_city || "",
          "email_optin": data.consent_email_status || "",
          "gdpr_optin": data.consent_gdpr_status || "",
          "sms_optin": data.consent_sms_status || "",
          "whatsapp_optin": data.consent_whatsapp_status || "",
          "custom": {
            "status": data.status || "",
            "lytics_computed_attr": data._segments || [""],
            "score_consistency": data.score_consistency || "",
            "score_frequency": data.score_frequency || "",
            "score_intensity": data.score_intensity || "",
            "score_maturity": data.score_maturity || "",
            "score_momentum": data.score_momentum || "",
            "score_propensity": data.score_propensity || "",
            "score_quantity": data.score_quantity || "",
            "score_recency": data.score_recency || "",
            "score_volatility": data.score_volatility || "",
            "lytics_content": data.lytics_content || "",
            "lytics_content_inferred": data.lytics_content_inferred || "",
            "lytics_rollup": data.lytics_rollup || "",
            "segment_prediction_percentile": data.segment_prediction_percentile || ""
          }
        },
        "not_append": true,
        "events": [
          {
            "event_name": "lytics_trigger",
            "timestamp": eventDetails.enter,
            "event_params": {
              "custom": {
                "id": eventDetails.id,
                "audience": eventDetails.slug,
                "trigger": eventDetails.event,
                "origin": "Lytics"
              }
            }
          }
        ]
      }
    ]
  };
}' | http -v POST https://api.lytics.io/v2/template name==insider_temp type==js1 account_id=={YOUR-ACCOUNT-ID} key=={YOUR-API-TOKEN}
```

To send another field, read it with data.field\_name or data\["field\_name"\], with a default after ||:

```
function template(data) {
  return {
    "field_name_to_send_to_insider": data.lytics_field_name || ""
  };
}
```

## Audience Exit Triggers

### Integration Details

*   **Implementation Type**: Server-side Integration.
*   **Implementation Technique**: REST API Integrations - Audience Trigger Integration - Webhook Integration
*   **Frequency**: Real-time Integration that continuously updates users as they exit a source audience.
*   **Resulting data**: Updated profile in Insider with the correct segment membership.

This integration uses the [Audience Triggers Webhook](/docs/lytics/webhooks) to send a secure request to Insider when a user exits the source audience. The request is sent to the POST api/user/v1/attribute/delete endpoint and contains the user data configured in the template described below. The Insider [delete API docs](https://academy.useinsider.com/docs/delete-user-attribute) describe the information that can be sent. To enable this workflow:

1.  Create an **Authorization** to Insider.
2.  Create a **source audience** to determine which profiles need to be sent.
3.  Create a **webhook template** to format the outbound request so it sends segment membership removals to the Insider APIs correctly.
4.  Create the real-time **webhook** sync between Lytics and Insider using the corresponding template.
5.  **Validate** that the webhook flow is working as expected.

### Authorization

Select or configure a new authorization as outlined [above](#authorization).

### Create the Exit Template

The examples below show how to structure the template to send segment exits and metadata to Insider. The Insider delete [API docs](https://academy.useinsider.com/docs/delete-user-attribute) have more information on how the data should be structured.

#### Jsonnet Example

```
echo 'local event = (import "lytemplates.libsonnet");
local eventDetails = event.get("segment_events", "")[0];
{
  "users": [
    {
      "identifiers": {
        "email": event.get("email", ""),
        "custom": {
          "lytics_id": event.get("_uid", "")
        }
      },
      "attributes": {
        "custom": {
          "partial": {
            "lytics_computed_attr": event.get("_segments", [""])
          }
        }
      },
      "events": [
        {
          "event_name": "lytics_trigger",
          "timestamp": eventDetails["exit"],
          "event_params": {
            "custom": {
              "id": eventDetails["id"],
              "audience": eventDetails["slug"],
              "trigger": eventDetails["event"],
              "origin": "Lytics"
            }
          }
        }
      ]
    }
  ]
}' | http -v POST https://api.lytics.io/v2/template name==insider_temp type==jsonnet account_id=={YOUR-ACCOUNT-ID} key=={YOUR-API-TOKEN}
```

#### JavaScript Example

The equivalent exit template written in JavaScript:

```
echo 'function template(data) {
  var eventDetails = (data.segment_events || [{}])[0];
  return {
    "users": [
      {
        "identifiers": {
          "email": data.email || "",
          "custom": {
            "lytics_id": data._uid || ""
          }
        },
        "attributes": {
          "custom": {
            "partial": {
              "lytics_computed_attr": data._segments || [""]
            }
          }
        },
        "events": [
          {
            "event_name": "lytics_trigger",
            "timestamp": eventDetails.exit,
            "event_params": {
              "custom": {
                "id": eventDetails.id,
                "audience": eventDetails.slug,
                "trigger": eventDetails.event,
                "origin": "Lytics"
              }
            }
          }
        ]
      }
    ]
  };
}' | http -v POST https://api.lytics.io/v2/template name==insider_temp type==js1 account_id=={YOUR-ACCOUNT-ID} key=={YOUR-API-TOKEN}
```

## Configure the Webhook Job

In the final step, configure a webhook job that combines the authorization, template, and audience. Entrances and exits each need their own job, and each job must use the matching template: the two templates have different structures, so Insider won't be updated correctly if they're swapped.

### Select Provider

Begin by selecting the **Webhooks** provider tile.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am074e27d3c4235fdb/c7526697a463ad473cb4de89/ed85307-Screenshot_2023-09-14_at_12.52.09_PM.png)

### Select Job Type

Next, select the **Audience Triggers Webhook** job type.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/ame961c20e3d591735/71e5f19ecfafc89d4a7f5f20/7bde3c4-Screenshot_2023-09-14_at_12.52.47_PM.png)

### Configuration

The webhook job has more fields than are listed here; see the [Webhooks configuration](/docs/lytics/webhooks#configuration) for all of them. Below are the fields specific to the Lytics and Insider workflow.

#### Select Source Audiences

Select one or more audiences whose entrances or exits you want to send to Insider.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am954d2e485ffbb521/03e1ba87dc4c911a033b9103/4151bab-Screenshot_2023-09-14_at_12.54.09_PM.png)

#### Select Webhook Template

Select the entrance or exit template that you created in the previous step.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am25953c087934186c/69fd69cb0d7b496a3983928f/92d1866-Screenshot_2023-09-21_at_8.33.57_AM.png)

#### Set Webhook URL

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/amab967b0ed368dcfb/4aab25ce5694c6ca3e11852a/1d4c4a3-Screenshot_2023-09-14_at_1.04.48_PM.png)

```
// if doing an entry
https://unification.useinsider.com/api/user/v1/upsert

// if doing an exit
https://unification.useinsider.com/api/user/v1/attribute/delete
```

#### Set Audience Trigger Events

Set this to entrances or exits, to match the template the job uses.

![](https://images.contentstack.io/v3/assets/blt2d43f51baca745a8/am5911ce04d5519bcc/156cf3a36a8fdaa3ad8fa4ea/50b95bc-Screenshot_2023-09-14_at_1.07.39_PM.png)

#### Set Export Fields

Do not select any fields. This will default to syncing the entire profile based on the defined template.