Logo

REST API

REST API #

The REST API provides an integration mechanism for those cases where there is no native SDK that can be integrated with the Marketing Automation Platform.

In all cases, APIs support the EDN format, which has advantages when compared to JSON since different data types are allowed to avoid having to always send information encoded as a string.

In case you still want to use JSON as a serialization format, you must specify the Content-Type and Accept HTTP headers as application/json.

Traces #

The trace API provides a generic traceability mechanism regardless of the type of action or platform where it occurs. As such, it assumes no channel capacity to persist session identifiers -cookies, for example- and each API user must resolve the persistence and association of such information independently.

For cases where, if there is such availability, for example, Internet Browsers, it is recommended to use the existing native SDK.

Trace #

Customers interact with the platform in different sessions or interactions that we call visits (trails). Traces are used to group these visits. In the most usual case, a pre-conversion client interacts several times with different sections of the website, mobile app, or another channel.

Before creating a new trail, it must belong to a trace, so if there is no trace we have to create it. The trace must be generated either the first time a user visits or enters the application, or when they want to close a previous trace, perhaps because the user has already converted to another promotion.

URLmethoddata
/API/traces/tracePOSTEDN or JSON

The format of the posted information is an EDN or JSON object with two fields, both optional.

data = {
    :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
    :customer-id "5114932"
}
data = {
    "app-token": "D17C100F-0668-400A-AF91-967FE1A09A9E",
    "customer-id": "5114932"
}
ParameterDescription
App-tokenIntegrated application identifier making notification request
customer-idClient ID starting the trace

The customer-id parameter can be empty if the person interacting is not identified, in which case the system will create an anonymous client for this interaction identifier.

The response is an EDN or JSON object with a trace identifier generated, this trace identifier must be used after each new visit to keep it linked. In case the trace is generated with an identifier of an anonymous client, it will be returned as part of the result.

response = {
    :trace-id "D17C100F-0668-400A-AF91-967FE1A09A9E"
    :customer-id "5114932"
}
response = {
    "trace-id": "D17C100F-0668-400A-AF91-967FE1A09A9E",
    "customer-id": "5114932"
}

The result of the operation is given by one of the following HTTP status codes.

CodeDescription
200The operation was completed successfully
500The trace could not be created

Visits #

A new visit must be generated whenever a user visits the website or opens the mobile application (or uses any other alternative channel).

urlmethod:trace-iddata
/api/traces/:trace-id/trailPOSTTrace Identifier to which to associate this visitEDN or JSON

The format of the posted information is an EDN or JSON object with three fields, where two of them (platform and language) are optional.

data = {
    :language "en-US"
    :platform "Chrome Browser"
    :channel: :atm
}
data = {
    "language": "en-US",
    "platform": "Chrome Browser",
    "channel": "atm"
}
ParameterDescription
languageLanguage of the device used to make the visit
platformPlatform used to make the visit
channelThe channel used for the visit

The response is an EDN or JSON object with the visit identifier generated, which will have to be used in the subsequent actions generated within this visit.

response = {
    :trail-id "D17C100F-0668-400A-AF91-967FE1A09A9E"
}
response = {
    "trail-id": "D17C100F-0668-400A-AF91-967FE1A09A9E"
}

The result of the operation is given by one of the following HTTP status codes:

CodeDescription
200The operation was completed successfully
500The visit could not be created

Activity #

As mentioned in the First Steps document, there are different types of activities that can be done within a visit:

TypeDescription
locationIt is a visit to a page or screen
actionAn action initiated by the user, for example, a button
conversionThe user finished successfully
dismissThe user indicates that they are not interested
entry-pointThe user initiates the conversion funnel
funnel-stepThe user advances a step in the conversion funnel
eventEvents not generated by the user

The execution is made through the action API, and the format of the posted information is an EDN or JSON object:

urlmethod:trace-iddata
/api/traces/trail/:trail-id/actionPOSTtrace Identifier to which to associate this actionEDN or JSON
data = {
    :name "conversion"
    :type :trail-action/conversion
    :data [
        {
            :name "field1"
            :value "value1"
        }
        {
            :name "field2"
            :value "value2"
        }
    ]
}
data = {
    "name": "conversion",
    "type": "conversion",
    "data": [
        {
            "name": "field1",
            "value": "value1"
        },
        {
            "name": "field2"
            "value": "value2"
        }
    ]
}
ParameterDescription
nameName of the activity, it is directly related to the activity type
typeOne of the Activity types described before, there must be a keyword such as :trail-action/type
dataData associated with the desired action to persist

The result of the operation is given as one of the following HTTP status codes:

CodeDescription
200The operation was completed successfully
500The activity could not be created

Conversion and No interest #

By using the action API it is possible to indicate when a client converts or if there is a lack of interest in a campaign. Each action has a corresponding type, and the only required parameter to send is tracking-token obtained previously in the channel.

The following information is sent along with the action. For JSON, the action type must be sent without a preffix.

data = {
    :name "conversion"
    :type :trail-action/conversion
    :data [{:name "tracking-token" :value "value"}]
}

data = {
    :name "dismiss"
    :type :trail-action/dismiss
    :data [{:name "tracking-token" :value "valor"}]
}
data = {
    "name": "conversion",
    "type": "conversion",
    "data": [{"name": "tracking-token", "value": "value"}]
}

data = {
    "name": "dismiss",
    "type": "dismiss",
    "data": [{"name": "tracking-token", "value": "value"}]
}

IMPORTANT: Once conversion or dismiss are invoked on a trace, it cannot be used again and a new trace must be created to mark subsequent actions, visits, and synchronizations. In case the same trace is used an invalid request error 400 will be returned.

Campaigns #

Campaign functionalities.

Active Campaigns #

This API allows us to obtain all the campaigns that are active for any given client.

The execution is made through the API:

urlmethoddata
/api/campaigns/activePOSTEDN

The format of the posted information is an EDN object:

data = {
    :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
    :customer-id "5114932"
    :category "Sales"
    :group "Cars"
    :trail-id  "882252f3-fe70-4402-9195-639d8037f339"
}
ParameterDescription
app-tokenIntegrated application identifier making request
customer-idClient identifier if available
categoryOptional Name of the category of campaigns to look for, optional parameter to filter by
groupOptional Name of the campaign groups to look for, optional parameter filter by
trail-idAssociated visit identifier

Banners and Popups #

Banners and popups as obtained as a result of the app screen synchronization. Whenever the user goes to a new page or screen, several banners can be recovered together, or a single popup for that screen. These actions are made by invoking a single API (sync-page) that obtains all the elements corresponding to that screen for the client.

urlmethoddata
/api/campaigns/sync-pagePOSTEDN o JSON

The format of the posted information is an EDN or JSON object:

data = {
    :app-token "D17C100F-0668-400A-AF91-967FE1A09A9E"
    :customer-id "5114932"
    :trail-id "882252f3-fe70-4402-9195-639d8037f339"
    :sync-popups true
    :page-location "http://my.domain/page"
    :placeholders [{:placeholder "id-placeholder1"} {:placeholder "id-placeholder2"}]
}
data = {
    "app-token": "D17C100F-0668-400A-AF91-967FE1A09A9E",
    "customer-id": "5114932",
    "trail-id": "882252f3-fe70-4402-9195-639d8037f339",
    "sync-popups": "true",
    "page-location": "http://my.domain/page",
    "placeholders": [{"placeholder": "id-placeholder1"}, {"placeholder": "id-placeholder2"}]
}
ParameterDescription
app-tokenIntegrated application identifier making a request
customer-idClient identifier if available
placeholdersList of defined placeholders on the page from which we want to recover banners
trail-idassociated visit identifier
page-locationIdentifier of screen or page currently visited
sync-popupsBoolean value indicating whether or not to recover popups from current page-location

The response is an EDN or JSON object containing two types of information:

  1. Banners to display in each placeholder
  2. Information of the Popup to unfold in case it corresponds.
response = {
    :popup = {}
    :placeholders = [{} {}]
}
response = {
    "popup": {},
    "placeholders": [{}, {}]
}

The pop-up information structure contains the following data:

popup = {
    :tracking-token
    :campaign
    :show-close
    :funnel
}
ResponseDescription
tracking-tokenIdentifier of interaction traceability
campaigncampaign identifier
show-closeBoolean value indicating whether or not to recover the pop-up’s current page-location
funnelFunner configuration parameters, see ‘funnel detail’ below in this document

In order to display the funnel corresponding to this popup, the conformed URL must be used in the following way: /api/campaigns/:campaign/funnel?d=:tracking-token&a=:app-token&t=:trail-id&popup=true

Placeholders #

The placeholders attribute in the sync-page API response includes the result of banners to display in each of the requested placeholders that contain information. In case a given placeholder does not have associated banners to display for the identified client, no results will be returned.

The response structure of each placeholder is the following:

placeholder = {
    :customer-id "5114932"
    :banners-list [{b1} {b2}]
    :is-popup false
    :popup-timeout 1000
    :transition-time 5000
    :width 800
    :height 600
}

Result description:

ParameterDescription
customer-idClient identifier, if the client were anonymous, a temporarily created identifier will be returned
banners-listList of banners associated with a placeholder, see banner detail
transition-timeTime of transition between images if placeholder is unfolding in carousel mode
is-popupBoolean value indicating if any banner is due to unfold or not in a popup according to the configuration.
popup-timeoutTime of timeout in which the popup is due to close in case the banner is unfolding as such.

Banner detail:

Each object in banners-list contains the detail of one of the banners to display for that placeholder. In case there is more than one, it will be possible to display them in different formats: carousel mode, grid, etc.

The detail of each banner object returned is as follows:

banner-detail = {
    :banner {banner object}
    :funnel {funnel object}
}

Description of the banner object:

ParameterDescription
widthDefined width of placeholder
heightDefined height of placeholder
campaignCampaign banner identifier
tracking-tokenInteraction traceability identifier
LinkOptional, Image link in case it is an image banner
HTML-contentOptional, HTML content in case the banner is an HTML banner

Funnel object description:

Within the funnel object, there are properties related to the identified user’s conversion process, along with the data corresponding to the first step of the funnel:

ParameterDescription
styleParticular styles to apply to the funnel, in CSS format
allow-dismissIt indicates if this campaign has activated the functionality to allow “I’m not interested” by the user.
landing-pageIt indicates if the campaign has a defined landing page
always-use-landingIt indicates if the page must always open with the landing page
show-progress-barIt indicates if the funnel progress bar should or not be displayed
new-widowIt indicates if the funnel should be displayed in a new window

Funnel steps #

In order to obtain the defined steps of the funnel, use the advance-funnel. This API obtains the steps, one by one, as the previous steps are completed.

If there are forks in the funnel, based on the data or other user parameters, the next step in the funnel will only be determined after the current step is completed. This is why we must use the API to obtain the first funnel step when the user is interested in the campaign, as well as the following steps as each step is completed.

URLmethoddata
/api/campaigns/advance-funnelPOSTEDN or JSON

The format of the posted information is an EDN or JSON object.

data = {
    :trail-id  "882252f3-fe70-4402-9195-639d8037f339"
    :campaign-id 123123101
    :tracking-token "12312-21919-j1b3-121m-1212"
    :step-data {}
}
data = {
    "trail-id": "882252f3-fe70-4402-9195-639d8037f339",
    "campaign-id": "123123101",
    "tracking-token": "12312-21919-j1b3-121m-1212",
    "step-data": {}
}
ParameterDescription
trail-idAssociated visit identifier
campaign-idCampaign identifier to initiate funnel
tracking-tokenInteraction traceability identifier
step-dataIf the client is coming from a previous step, map with information of the step

The campaign-id and tracking-token parameters must correspond to the interaction the user has made. For example, if the user clicked on a banner, the campaign and tracking-token data corresponding to that banner must be sent. On the other hand, the step-data parameter must not be sent when the user initiates the funnel. In other cases, it must always be sent even if empty, in order to advance in the funnel.

The response structure is the following:

response = {
    :type data-capture | message | redirect
    :config {}
}
ResponseDescription
typeStep Type to execute
configStep configuration detail, depending on its type

The configuration detail for each step type is described below.

Message Step #

step = {
    :title
    :message
    :actions
    :remaining-steps
    :max-steps
}
step = {
    "title":
    "message":
    "actions":
    "remaining-steps":
    "max-steps":
}
DataDescription
titleTitle of the message
messageMessage to display
actionsList of actions available in the step: next, cancel, etc
remaining-stepsHow many steps are in the funnel
max-stepsMaximum steps in the funnel

Data Capture Step #

step = {
    :fields
    :actions
    :remaining-steps
    :max-steps
}
step = {
    "fields":
    "actions":
    "remaining-steps":
    "max-steps":
}
DataDescription
fieldsList of fields to capture
actionsList of actions available in the step: next, cancel, etc
remaining-stepsHow many steps are in the funnel
max-stepsMaximum steps in the funnel

The fields list indicates which fields must be requested from the client in this step, and it includes the following structure for each field:

field = {
    :label
    :name
    :control-type
    :value
}
field = {
    "label":
    "name":
    "control-type":
    "value":
}
DataDescription
labelLabel to display in the field capture
nameName of the field to capture
control-typeType of control to use for the capture of the data
valueCurrent value of the data that the client already has, if any

When the next step is requested with advance-funnel, the step data must contain the values of the captured fields using name as a reference.

Redirect Step #

step = {
    :url
    :method
    :parameters
    :include-system-params
    :new-window
}
step = {
    "url":
    "method":
    "parameters":
    "include-system-params":
    "new-window":
}
DataDescription
URLURL to where to make the redirection
methodget or post, according to the type of redirection
parametersList of parameters to be sent as part of the query string
include-system-paramsBoolean, it indicates if campaign-id, trail-id, and tracking-token system parameters must be sent along as part of the query string
new-windowBoolean, it indicates if redirection should be made in a new window

Customers #

This API allows you to create or update the information of a new or existing customer through the URL shown below:

urlmethoddata
/api/customers/POSTEDN or JSON

The format of the posted information is an EDN or JSON object.

data = {
    :customer {:id 12345 :field "xxyyzz"}
    :app-token "882252f3-fe70-4402-9195-639d8037f339"
}
data = {
    "customer": {"id": "12345", "field": "xxyyzz"},
    "app-token": "882252f3-fe70-4402-9195-639d8037f339"
}

| Parameter | Description | | ————- | ———————————– ————————————————– ————- | | app-token | Integrated application identifier making the request, it must be an application that has the REST platform selected | | customer | Client to update, the id data is required, and the rest of the fields that are sent must exist in the defined schema and coincide with the data type. |

The result of the operation is given by one of the following HTTP status codes:

CodeDescription
200The operation was successfully completed
404The application token is invalid
400There are errors in the type of data sent
500Could not update the database

Business Events #

Campaigns can be triggered based on certain Business Events. The nature of a Business Event is of course particular for each company. Prisma provides a way to set up Business Events and trigger campaigns when one of those events occurs.

Business Events have meaning only in the scope of an application. For that reason, the administrator must configure the application that will potentially trigger business events and then define each possible event as a part of the application. This is done in Settings/Applications.

Each business event has a name (which must be unique) and a description and can be added to a campaign in Campaign Settings/Business Events. They apply to all the customers that match the campaign segment but, if needed, a filter can be configured.

When a Business Event is triggered through a POST request, the campaign is selected based on orchestration settings (after proper filtering), this means that the same Business Event can be configured in different campaigns and the system will select the best campaign for the specified event and customer.

urlmethoddata
/api/campaigns/business-eventPOSTEDN or JSON

The request body must contain the following data:

DataDescription
app-tokenApplication token
event-nameThe name of the event, as defined in application settings
customer-idThe customer’s unique ID

An invalid application token or an event name that is not defined in the application will result in a 404 response. An empty customer identifier will result in a 400 response. If no customer is found a new one is created.

The field customer-id can be a string representing the customer’s unique identifier or a search specification, i.e.: an object containing key-value pairs. For example:

{
    :app-token "882252f3-fe70-4402-9195-639d8037f339"
    :event-name "newsletter-registration"
    :customer-id {:email "jane.doe@example.com"}
}
{
    "app-token": "882252f3-fe70-4402-9195-639d8037f339"
    "event-name": "newsletter-registration",
    "customer-id": {"email": "jane.doe@example.com"},
}

Providing a field that does not exist in the customer schema will result in a 400 response. If no customer is found a new one is created and the provided data is merged into the new customer.

The request body may also contain the following optional data:

DataDescription
contextAn object containing additional parameters
force-funnel-restart?Boolean flag. When true, forces the customer to restart the funnel

The server will reply with 202 Accepted in case of success, and a 404 Not Found if no matching campaigns are found. Additionally, the response includes the following fields:

DataDescription
campaignName of the campaign that was triggered
trace-idUnique ID of the trace generated for this funnel
tracking-tokenGenerated tracking token
customer-idCustomer’s unique identifier

Note: The server may reply with an EDN or JSON object depending on the content of the Accept and Content-Type headers, where the former is mandatory. The response field customer-id is the same as the one provided in the request body unless the provided value was a search specification, in which case the response contains the customer identifier of the customer that was found or created.