Amplitude CDP’s cohort webhook allows you to receive cohort updates to your webhook endpoints. This allows for custom data enrichment, filtering, or aggregation based on the specific requirements of the webhook endpoint or internal systems. Integrate the transformed data into marketing automation platforms or other systems, enabling personalized and targeted marketing campaigns with up-to-date cohort insights.
To configure streaming from Amplitude to your webhook, collect the following information:
Create a new destination.
Enter the URL endpoint for the webhook. For example, https://mycompany.com/webhook
.
Amplitude doesn't have a single IP address for forwarding events and users, so ensure that your URL can receive payloads from any Amplitude hosts.
There are two preset headers for every webhook sync:
Content-Type: application/json
User-Agent: Amplitude/Webhook/1.0
After these preset headers, you can define five more headers. To create a new header:
Define the payload you want to receive in the webhook. You can choose to:
When satisfied with your configuration, click Save to complete the setup process.
See the FreeMarker guide to creating templates for more help.
{ "cohort_name": "${input.cohort_name}", "cohort_id": "${input.cohort_id}", "in_cohort": ${input.in_cohort?c}, "computed_time": "${input.computed_time}", "message_id": "${input.message_id}", "users": [ <#list input.users as user> { "user_id": "${user.user_id}" }<#sep>, </#list> ]}
{ "cohort_name": "My Test Cohort", "cohort_id": "7khm89cz", "in_cohort": true, "computed_time": "1692206763", "message_id": "9baaa88f-9d46-4ee5-a946-be0c6aea0046::enter::0", "users": [ { "user_id": "user_one@example.com" }, { "user_id": "user_two@example.com" }, { "user_id": "user_three@example.com" } ]}
{ "cohort_name": "${input.cohort_name}", "cohort_id": "${input.cohort_id}", "in_cohort": ${input.in_cohort?c}, "computed_time": "${input.computed_time}", "message_id": "${input.message_id}", "users": [ <#list input.users as user> { "user_id": "${user.user_id}", "user_properties": { <#list input.user_properties?keys as key> <#assign value = input.user_properties[key]> "${key}": <#if value?is_number || value?is_boolean>${value}<#else>${UtilClass.toJsonString(value)}</#if><#if key_has_next>,</#if> </#list> } }<#sep>, </#list>]}
{ "cohort_name": "My Test Cohort", "cohort_id": "7khm89cz", "in_cohort": true, "computed_time": "1692206763", "message_id": "9baaa88f-9d46-4ee5-a946-be0c6aea0046::enter::0", "users": [ { "user_id": "user_one@example.com", "user_properties": { "name": "John Doe", "country": "US", "city": "San Francisco" } }, { "user_id": "user_two@example.com", "user_properties": { "name": "Jane Smith", "country": "US", "city": "New York" } }, { "user_id": "user_three@example.com", "user_properties": { "name": "Alice Johnson", "country": "US", "city": "Los Angeles" } } ]}
Some webhook destinations would need a list of users as a batch. In the below example, set the cohort name and cohort id as a single boolean property determining whether the user is in the cohort or not.
[ < #list input.users.iterator() as user > { 'user_id': '${user.user_id}', 'amplitude_${input.cohort_name}_${input.cohort_id}': $ { input.in_cohort }} < #if user_has_next > , < /#if></#list > ]
{ [ { "user_id": "user_one@example.com", "amplitude_My Test Cohort_7khm89cz": true }, { "user_id": "user_two@example.com" "amplitude_My Test Cohort_7khm89cz": true }, { "user_id": "user_three@example.com" "amplitude_My Test Cohort_7khm89cz": true } ]}
${ ... }
constructs with the value of the expression inside the curly braces.input
is a reserved variable that refers to the event as an object. The "input" has the same format as the example payload above.input
has the following below format:
cohort_name
string. The display name of the cohort.cohort_id
string. The unique identifier of the cohort.in_cohort
boolean. Show if this batch of users is entering/leaving the cohort.compute_time
string. The time when Amplitude computes this update.message_id
string. The unique identifier of this update message. When a retry happens, you can use this value to de-duplicate.users
list of JSON objects. The actual user payload.
user_id
string. The Amplitude user_id
of the user.user_properties
JSON object. The user properties selected for this user during this cohort sync.July 23rd, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.