API triggered campaigns

Template campaigns executed by the external API

Template campaigns can be created using the UI on the platform, but triggered later via the Campaign Execute API.

You can find API triggered campaigns on the Create Campaign page (Campaigns > Create campaign), build them like any regular campaign.

Any available outbound channel may be triggered by an API execution and multiple channels can be used in your template if required.

These message are typically transactional with a mixture of fixed content in the template and variables sent via API. Use the double curly brace syntax to add variables, eg. {{variable_name}}. Further information can be found in the guide on dynamic content.

Once the template is configured with channel, content, variables, etc., put the campaign live with the Review & Launch button like any other campaign. The campaign will be listed in Existing campaigns > Live Campaigns. Here you will find the campaign ID, which is needed to trigger the campaign using the Campaign Execute API.

Sending transactional emails or SMS

If you want to use the API to send transactional email 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_number, time and gate_number). 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_number": "EI105", 
      "time": "10:30",
      "gate_number": "B100" 
    },
    "target_by": "user_id",
    "target": ["USER_ID"]
}

If you want to construct the full content of message on your backend you can just place single params in the various content fields on the template from the Xtremepush platform, such in the example below, where we include {{from}} in the from name field to dynamically generate the from name and {{text}} in the text field:

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:

Updated 3 months ago


API triggered campaigns


Template campaigns executed by the external API

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.