Insider Webhook Templates

View as Markdown
Last updated November 5, 2026

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 job, with a template 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 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.

Click to enlarge

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 documentation.

Select Provider

Begin by selecting the Webhooks provider tile.

Click to enlarge

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.

Click to enlarge

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.

Click to enlarge

Description

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

Click to enlarge

Webhook Request Headers

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

Click to enlarge

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 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 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.

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. The Insider upsert API docs 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 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 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.

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 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.

Click to enlarge

Select Job Type

Next, select the Audience Triggers Webhook job type.

Click to enlarge

Configuration

The webhook job has more fields than are listed here; see the 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.

Click to enlarge

Select Webhook Template

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

Click to enlarge

Set Webhook URL

Click to enlarge

// 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.

Click to enlarge

Set Export Fields

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