Event-Triggered Campaign API

An event-triggered campaign entity is a message template that is triggered to be sent after the Vibes system receives an event. You can configure and request information about event-triggered campaigns using public API calls.

You can create these campaigns either in the platform or via an API call. To learn how to do it in the platform, please see this guide.

It’s important to note that creating this template won’t automatically send a text message or push notification. Once the template is set up, the message will only be sent if an event of the specified event_type is sent to the Vibes system.

To learn how to define an event, see our Event API.

Available API Methods

Available Callbacks

Elements & Attributes

ElementTypeDescriptionRequired?
event_triggered_message_idIntegerUnique identifier for each event-triggered message campaign.no (system generated)
statusStringThe status of the event-triggered campaign. Possible values include (always lowercase):

- scheduled: the campaign will become active on the start_date
- in_progress: the campaign is active
- ended: the campaign is no longer active because the end_date has passed
- canceled: The campaign has been canceled
no (system generated)
nameStringThe descriptive name of the event-triggered campaign. Example: "Order update SMS message".yes
event_typeStringEvents that are POST-ed with the same event_type value will invoke this message template. Valid characters are alphanumeric, dash and underscore.

Note: event_type values are NOT case sensitive.
yes
start_dateTimestampISO-8601 format: yyyy-mm-dd

Date string indicating when the status should become in_progress. This field is required on-create (POST) but may be left blank on update (PUT). Once the start_date has passed and the status becomes in_progress, this value may not be changed (must exactly match current value if included). For new or scheduled messages, this value may be set in the past, causing the status to immediately become in_progress.
yes (on-create)
end_dateTimestampISO-8601 format: yyyy-mm-dd

Date string indicating when the campaign status should become ended. Leaving this value blank (null) results in an open-ended campaign. Must be later than the start_date. May not be changed once the end_date (if set) has passed and the status is ended.
no
targetingObjectThe targeting information for the event-triggered campaign, including message content, filter criteria, and channel-specific attributes.yes
targeting.message_templateStringTemplated message content that will be rendered for a given recipient. May include valid Liquid personalization tags, including:
- Attributes from the Event API call – e.g., {{ ev.order_id }}
- Mobile database custom fields – e.g., {{ first_name }}
- other custom mobile database tags e.g. {{ cm.wallet | token: “xyz123” }} or {{ incentive_code | pool_id: 1 }}
For SMS & push: yes
For MMS: no
targeting.short_url_baseStringA valid HTTP URL that has been registered for use with Vibes URL shortener. Defaults to NULL if not provided. When NULL, will use the Vibes system default URL for the environment and region (e.g., US Production is "http://vbs.cm").no
targeting.shorten_urlsBooleanIf set to true, any URLs found in the message content will be converted to a unique short URL for each recipient. URL shortening is the final rendering step, enabling dynamic short URLs to be generated per-recipient by using Liquid tags in the URL.yes (on-update
targeting.channelStringThe delivery channel associated with this message. Current valid options are: SMS or PUSH. May not be changed on-update. An additional SMS or PUSH attribute should be included, matching the specified channel (see below).yes
targeting.message_formatStringA read-only field that defines the message format.

If the targeting channel is sms, the value will be sms or mms. If the targeting channel is push, the value will push.
no
targeting.smsObjectChannel-specific attributes for SMS messages.yes, for SMS sends
targeting.sms.sourcecodeStringThe short, long or alphanumeric code value.yes, for SMS sends
targeting.sms.country_codeStringThe E.164 Country Calling Code for the country where the code is provisioned.yes, for SMS sends
targeting.sms.sourcecode_typeString"SC" for short or long numeric codes; "ANC" for alphanumeric codes.yes, for SMS sends
targeting.mmsObjectChannel-specific attributes for MMS messages.

Note: MMS is supported in the US only.
yes, for MMS sends
targeting.mms.sourcecodeStringThe short, long or alphanumeric code value.yes, for MMS sends
targeting.mms.country_codeStringThe E.164 Country Calling Code for the country where the code is provisioned.yes, for MMS sends
targeting.mms.sourcecode_typeString"SC" for short or long numeric codes; "ANC" for alphanumeric codes.yes, for MMS sends
targeting.mms.subjectStringThe subject line that will appear in your mms send. Limit 50 characters.no
targeting.mms.content [ ]List of objectsAn object containing a list of objects for your MMS.

Your MMS may contain either an uploaded asset or a media URL, which represent the media part of your send. Sends with an uploaded asset or media URL may also contain text in a body object after the media object. You can also have a text-only send, in which case body will be the only object.
yes, for MMS sends
UPLOADED ASSET ELEMENT

targeting.mms.content[].asset_id
StringA read-only string identifying the asset.

Note: MMS sends using uploaded assets must be created in the Vibes UI Platform. After the asset is uploaded, an asset_id will be generated, but can only be accessed via API calls.
no
UPLOADED ASSET ELEMENT

targeting.mms.content[].mime_type
StringA read-only string identifying the MIME type of the uploaded asset. For example: image/jpegno
MEDIA URL ELEMENT

targeting.mms.content[].media_url
StringA URL link to the media to be included in the MMS

OR

If you are personalizing the media element, you can add a liquid template variable . The media_url should then be present in the event payload.

Notes for using an URL:

- Include the HTTP or HTTPS portion of the URL.
- The URL must be publicly available.
- The URL will be fetched when the MMS is triggered to be sent.
- The response must be under 500KB.
- Available MIME types are: image/jpeg, image/png, or image/gif.
- If the URL is unavailable at send time or the response is too large, the message will fail to send.
yes, if including a media url element
MEDIA URL ELEMENT

targeting.mms.content[].description
StringAn optional description of the media.no
TEXT ELEMENT

targeting.mms.content[].body
StringThe body text included in the MMS send.yes, if including text
TEXT ELEMENT

targeting.mms.content[].mime_type
StringA string identifying the MIME type of the element. Must be text/plain for the body object.yes, if including text
targeting.pushObjectChannel-specific attributes for Push messages.yes (if channel="push”)
targeting.push.mdn_territoryStringISO 2-character country code (such as "US" or "GB") that represents the territory non-E.164 MDNs are expected to be in (when submitted through the Event API). The MDNs will be parsed and validated against number patterns for that territory. If not supplied, mdn_territory will default to an appropriate value based on the country_code.no
targeting.push.app_idStringVibes-specific UUID for the specific app.Yes (both iOS and Android)
targeting.push.silent_pushBooleanA silent—or “background”—push will send information to the app without sending a visible message to the customer. Typically used in combination with custom properties, this function will wake up the app for a specific prebuilt function.no (both iOS and Android)
targeting.push.subjectStringSubject line displayed in a push message. Supports personalization using Liquid tags.no (both iOS and Android)
targeting.push.media_urlStringRich Media adds an image, video, or audio file for iOS or an image to a notification. Requires Rich Media support in the operating system and device hardware. Supports personalization using Liquid tags.no (both iOS and Android)
targeting.push.soundStringApp notification sound may be customized to a brand specific sound or set to the user's device default. The notification sound defaults to silent. Custom sounds must be built into the app.no (both iOS and Android)
targeting.push.badgeStringBadge count will reset the total badge value on the app icon.no (iOS only)
targeting.push.metadataStringArbitrary metadata sent to the app when the mobile consumer taps on the push notification. It is not seen by the user and can be used for deep-linking or customization purposes.no (both iOS and Android)
targeting.push.client_custom_dataObjectCustom Properties are used to send information to the app when the mobile consumer taps on the push notification. It is not seen by the user and can be used for deep linking or customization purposes. 10 rows maximum. Supports personalization using Liquid tags.no (both iOS and Android)
targeting.push.collapse_idStringIdentical collapse_id values on two notifications will allow a previous notification to be replaced with an incoming notification. If not populated, this value will be set to a unique default value, so it will always be possible to replace a notification. Supports personalization using Liquid tags.no (both iOS and Android)
targeting.push.categoryStringA category can be used to trigger predefined actions that have been built into your app. iOS only.no (iOS only)
targeting.push.notification_channelStringNotification channel, aka category, is used to group certain types of notifications together so apps can configure specific actions and users can manage their opt-in status per channel.no (Android 8+ only)
targeting.push.expiration_offsetIntegerOS Expiration is how long Apple or Google will attempt to send the message if the device is offline, up to 28 days. If 0, the message will attempt to send just once. Value is in milliseconds.no (both iOS and Android)
targeting.filtersArrayAn array of filter objects that can be used to restrict the target recipients for this message. If not included, this is equivalent to setting it to an empty array.no (defaults to empty set)
targeting.filters.nameStringName of the filter that is being used.yes
targeting.filters.transformStringOptional transform (depends on type of filter being used)no
targeting.filters.selectorStringMethod of selection. Options include: any, all, and various others depending on the type of filter being used.yes*

if targeting.filters array is used.
targeting.filters.valueArrayAn array of values to filter on. The type and valid options depend on the filter being used.yes
urlStringUnique resource URL for the event-triggered campaign.no (system generated)
created_byStringThe email address or user ID of the person who created the event-triggered campaign.no (system generated)
created_by_applicationStringThe application used to create the event-triggered campaign.no (system generated)
created_atTimestampISO-8601 Date string indicating the date and time at which this event-triggered campaign was created.no (system generated)
updated_atTimestampISO-8601 Date string indicating the date and time at which this event-triggered campaign was last updated.no (system generated)

Entity Examples

The following is the JSON representation of an Event-Triggered SMS Campaign entity within the APIs.

{
  "event_triggered_message_id": 1,
  "status": "scheduled",
  "name": "Order Delivered SMS Message",
  "event_type": "order_delivered",
  "start_date": "2020-12-01T23:00:00Z",
  "end_date": null,
  "created_by": "123",
  "created_by_application": "API",
  "targeting": {
    "message_template": "Your order #{{ ev.order_id }} has been successfully delivered!",
    "short_url_base": "http://vbs.cm",
    "shorten_urls": true,
    "channel": "sms",
    "sms": {
      "sourcecode": "12345",
      "country_code": "1",
      "sourcecode_type": "SC",
      "mdn_territory": "US"
    },
    "filters": []
  },
  "url": "/companies/xyz123/mobiledb/event_triggered_messages/1",
  "created_at": "2020-12-01T22:24:46Z",
  "updated_at": "2020-12-01T22:24:46Z"
}

The following is the JSON representation of an Event-Triggered MMS Campaign entity with only a subject and text element.

{
  "event_triggered_message_id": 2,
  "status": "scheduled",
  "name": "Order Delivered SMS Message",
  "event_type": "order_delivered",
  "start_date": "2020-12-01T23:00:00Z",
  "end_date": null,
  "created_by": "123",
  "created_by_application": "API",
  "targeting": {
    "message_template": null,
    "short_url_base": "http://vbs.cm",
    "shorten_urls": true,
    "channel": "sms",
    "message_format": "mms",
    "mms": {
      "sourcecode": "12345",
      "country_code": "1",
      "sourcecode_type": "SC",
      "mdn_territory": "US",
      "subject": "Order #{{ ev.order_id }} update",
      "content": [
        {
          "body": "Your order #{{ ev.order_id }} has been successfully delivered!",
          "mime_type": "text/plain"
        }
      ]
    },
    "filters": []
  },
  "url": "/companies/wZVasTXH/mobiledb/event_triggered_messages/1",
  "created_at": "2020-12-01T22:24:46Z",
  "updated_at": "2020-12-01T22:24:46Z"
}

The following is the JSON representation of an Event-Triggered MMS Campaign entity that includes a subject, text, and an asset uploaded into the Vibes UI.

{
  "event_triggered_message_id": 2,
  "status": "scheduled",
  "name": "Order Delivered SMS Message",
  "event_type": "order_delivered",
  "start_date": "2020-12-01T23:00:00Z",
  "end_date": null,
  "created_by": "123",
  "created_by_application": "API",
  "targeting": {
    "message_template": null,
    "short_url_base": "http://vbs.cm",
    "shorten_urls": true,
    "channel": "sms",
    "message_format": "mms",
    "mms": {
      "sourcecode": "12345",
      "country_code": "1",
      "sourcecode_type": "SC",
      "mdn_territory": "US",
      "subject": "Order #{{ ev.order_id }} update",
      "content": [
        {
          "asset_id": "86f03b74-63da-4295-82ac-83a4b1ac8219",
          "mime_type": "image/jpeg"
        },
        {
          "body": "Your order #{{ ev.order_id }} has been successfully delivered!",
          "mime_type": "text/plain"
        }
      ]
    },
    "filters": []
  },
  "url": "/companies/wZVasTXH/mobiledb/event_triggered_messages/1",
  "created_at": "2020-12-01T22:24:46Z",
  "updated_at": "2020-12-01T22:24:46Z"
}

The following is the JSON representation of an Event-Triggered MMS Campaign entity that includes a subject, text, and a URL link to the media to include in your message. Note that you can also replace the URL with a liquid template variable.

{
  "event_triggered_message_id": 2,
  "status": "scheduled",
  "name": "Order Delivered SMS Message",
  "event_type": "order_delivered",
  "start_date": "2020-12-01T23:00:00Z",
  "end_date": null,
  "created_by": "123",
  "created_by_application": "API",
  "targeting": {
    "message_template": null,
    "short_url_base": "http://vbs.cm",
    "shorten_urls": true,
    "channel": "sms",
    "message_format": "mms",
    "mms": {
      "sourcecode": "12345",
      "country_code": "1",
      "sourcecode_type": "SC",
      "mdn_territory": "US",
      "subject": "Order #{{ ev.order_id }} update",
      "content": [
        {
          "media_url": "https://example.com/delivered.jpeg",
          "description": "Delivery image"
        },
        {
          "body": "Your order #{{ ev.order_id }} has been successfully delivered!",
          "mime_type": "text/plain"
        }
      ]
    },
    "filters": []
  },
  "url": "/companies/wZVasTXH/mobiledb/event_triggered_messages/1",
  "created_at": "2020-12-01T22:24:46Z",
  "updated_at": "2020-12-01T22:24:46Z"
}

The following is the JSON representation of an Event-Triggered Push Campaign entity within the APIs.

{
  "event_triggered_message_id": 2,
  "status": "in_progress",
  "name": "Order Delivered Push Message",
  "event_type": "order_delivered",
  "start_date": "2020-12-01T23:00:00Z",
  "end_date": null,
  "created_by": "123",
  "created_by_application": "API",
  "targeting": {
    "message_template": "Your order #{{ ev.order_id }} has been successfully delivered!",
    "short_url_base": null,
    "shorten_urls": false,
    "channel": "push",
    "push": {
      "app_id": "6e4f85c9-5cc9-4925-8ea7-398630ef7e3f"
    },
    "filters": []
  },
  "url": "/companies/xyz123/mobiledb/event_triggered_messages/2",
  "created_at": "2020-12-01T22:55:44Z",
  "updated_at": "2020-12-01T23:16:26Z"
}