API triggered campaigns
Trigger personalised campaign templates from your backend systems using the Campaign Execute API
With API-triggered campaigns, you can create a campaign template in Xtremepush, make it live, and then trigger it using the Campaign Execute API when needed.
To create API-triggered campaigns, go to Campaigns > Create campaign > Single-stage/Multistage > API-triggered.
Once your template is live, you'll find the campaign ID under Campaigns> Existing campaigns > Live. This campaign ID is required to trigger the campaign using the Campaign Execute API.
Webhooks for deliveries and responsesFor API-based campaigns, you can post back delivery and click-through info to your own endpoints for tracking purposes, if necessary. This will work for both the template and trigger and create and send patterns. See details about how to configure these in the API campaign model properties.
Using Dynamic Content in API Triggered Campaigns
Both single-stage and multistage API-triggered campaigns support dynamic content. To add dynamic content, click the attribute icon in the message editor and select the attribute placeholder,{{attribute_name}},you want to insert as shown in the image below.
For more information on Twig syntax and personalisation, see Dynamic Programmable Content
In API-triggered campaigns, there are two ways to pass attribute values using the Campaign Execute API call:
params: Applies the same values to all users targeted in that call. Use this when the dynamic content is the same for every user, for example, a promotion name in a free bet promotion message.target_with_params: Lets you pass different values for each user in the same API call. Use this when each user needs unique content, for example, personalised account balances.
See Dynamic Content in API-triggered Multistage Campaigns below for examples of how to use params and target_with_params in the API call.
You can use
paramsandtarget_with_paramstogether in the same call. Values inparamsare applied as defaults to all targeted users, and values intarget_with_paramswill override or supplement those defaults for individual users.
Attribute values are applied in the following order of priority:
- Values passed in
paramsortarget_with_params - Attributes stored on the user's profile in Xtremepush
- Empty string, if neither exists
This means you only need to pass values for content that changes per trigger. User data like names can be stored on the user's profile and referenced in your campaign template without passing them using the Campaign Execute API.
Attribute values passed through the API are not stored against the user profile. This means that any values you pass are only available within the campaign.
Dynamic Content in API-triggered Single Stage Campaigns
Any available outbound channel may be triggered by an API execution and multiple channels can be used in your template if required.
Once your template is configured with the appropriate placeholders, use the Campaign Execute API to trigger it and pass the attribute values at the point of trigger. See the example below for how this works in practice.
Send transactional emails or SMS
If you want to use the API to send transactional emails or SMS, the principles would be the same in both cases. First, you create a template API campaign with necessary placeholders for dynamically changing content. To illustrate how this is used below is a classic transactional example of sending a gate update to an airline customer via an SMS message:

In this example, you would then use the campaign execute method to trigger the campaign when gate information becomes available on the backend. App token and campaign ID are used to target the right campaign in your project, and the params are set for the flight information (flight_num, time and gate_num). Finally to target users who are checked in for the flight we are adding a condition in the segment tab to target users who are on the list for the flight by targeting by user ID and providing an array of customer IDs to target.
curl --request POST \
--url https://external-api.xtremepush.com/api/external/execute/campaign \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"apptoken": "APP_TOKEN",
"id": "CAMPAIGN_ID",
"params": {
"flight_num": "EI105",
"time": "10:30",
"gate_num": "B100"
},
"target_by": "user_id",
"target": ["USER_ID"]
}If you want to construct the full content of the message on your backend you can just place single params in the various content fields on the template from the Xtremepush platform, such as in the example below, where {{from}} is included in the from name field to dynamically generate the from name and {{text}} in the text field:

From namesWhen populating an SMS from name dynamically, remember that from names must be between 3 and 11 characters long. For more details review our SMS settings guide.
The same principle outlined above for SMS can be applied to email, the main difference with email is the potential to have more complex content in the body of the email such as a list of personalised product recommendations with images, etc. There are examples of the more dynamic content that can be added to emails using this approach in the following user guides:
Dynamic Content in API-triggered Multistage Campaigns
For any API-triggered journey, parameters passed in params or target_with_params are available to every message node in the journey. Each message node only resolves the attribute placeholders referenced within it. Unused parameters are ignored.
For example, consider a journey where a user receives an SMS notification about a promotion, followed by a Web Push notification.
In this example, the messages use three variables: promo_name and match_name, which are the same for all users, and promo_code, which is unique to each user. The messages in each node are as follows:
- SMS Node: "Hi
{{first_name}}, your{{promo_name}}offer for{{match_name}}is now live." - Web-Push Node: ""Place your bet on
{{match_name}}. Use code{{promo_code}}to claim your{{promo_name}}offer."
In this example, you must use all three parameters (promo_name, match_name, promo_code) in your Campaign Execute API call:
{
"apptoken": "APP_TOKEN",
"id": "Campaign_ID",
"target_by": "user_id",
"target": ["user_1", "user_2", "user_3"],
"params": {
"promo_name": "Play-X-Get-Y",
"match_name": "Man Utd vs Liverpool"
},
"target_with_params": {
"user_1": {"promo_code": "PLAY50X"},
"user_2": {"promo_code": "PLAY75Y"},
"user_3": {"promo_code": "PLAY100Z"}
}
}{{first_name}}`is already stored on the user's profile and does not need to be passed in the API call.promo_nameandexpiry_dateare passed in params as they are the same for all userspromo_codeis passed intarget_with_paramsas it is unique per user.
In this example, in the SMS node, {{promo_name}} and {{match_name}}are resolved, and {{promo_code}} is ignored as it is not referenced in the SMS message. This means that only {{first_name}} ,{{promo_name}} , and {{match_name}} render in the SMS message.
In the Web Push node, {{match_name}}, {{promo_name}}, and {{promo_code}} are resolved, and and only these attribute values are rendered.
Updated 16 days ago