Trigger launch (API call)
Top priority instantly launched trigger campaigns.
To launch a trigger at the precise time of a new profile import you can use Import + trigger request.
Version 1.1
Description
It has several advantages compared with API V. 1.0:
- Requests can change campaign content for each launch.
- Sends messages to an audience instead of single profiles.
- Advanced audience matching — profile ID, custom fields, external database queries.
- API token in message body for advanced security.
Static request URL /api/v1.1/campaigns/triggers/start/
as compared to a dynamically generated link bound to a certain profile database.
Request URL
Method: POST
https://example.com/api/v1.1/campaigns/triggers/start/
Request parameters
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
id | string | 5511 | Yes | Trigger campaign ID |
content | JSON object | { "field": "value" } | No | Additional content for API content filter node and template apicontent variables |
attach | JSON array | [] | No | Attach file(s) to campaign messages |
custom_data | JSON object | { "x": "y"} | No | Data used for integration action hooks |
Profile matching mode | ||||
matching | string | "email" "phone" "profile_id" "custom" | No, if matched by email | Profile matching mode By default - email |
string | "john@example.com" | "matching":"email" | Email address | |
phone | string | "+79000000000" | "matching":"phone" | Phone number |
profile_id | string | "abcdefghijklmnqrstuvwxyz" | "matching":"profile_id" | Profile ID |
field_name | string | "CRM_ID" | "matching":"custom" | Custom profile data field name |
field_value | int/string | "123420" | "matching":"custom" | Custom profile data field value. tip Searching by combination of tags is available for tag type profile fields. Values are recorded as a string: "tag-1, tag-2". |
resource_id | int | 24 | No | Resource ID for email and phone matching |
custom_request | JSON object |
| When no matching specified | Custom MongoDB database query |
subscription_filter | JSON object | Push example:"subscription_filter": {Email example: "subscription_filter": {SMS example: "subscription_filter": { | No | Selects a profile's subscription to send message Not used if custom_request is set. not_strict determines what to do when a certain subscription is not found. If "true" — another fitting subscription will be used instead. |
Request example
This example triggers a campaign for a single subscriber:
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"id": 84,
"matching": "profile_id",
"profile_id": "abcdefghijklmnqrstuvwxyz"
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<id>84</id>
<matching>profile_id</matching>
<profile_id>abcdefghijklmnqrstuvwxyz</profile_id>
</xml>
Send messages to subscribers with Custom_IDs
from a list ["IpHicQquekzYkufl", "xzFKLXeaJkCYHuMb", "SRNOwHVZiWFItJhr"]
.
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"id": 84,
"custom_request":{"Custom_ID": {"$in": ["IpHicQquekzYkufl", "xzFKLXeaJkCYHuMb", "SRNOwHVZiWFItJhr"]}}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<id>84</id>
<custom_request>{"Custom_ID": {"$in": ["IpHicQquekzYkufl", "xzFKLXeaJkCYHuMb", "SRNOwHVZiWFItJhr"]}}</custom_request>
</xml>
Insert text "New videos on your favorite channels"
to replace {apicontent.email_title}
message content variable.
Attach files "日本.txt" and US.txt".
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"id": 96,
"matching": "profile_id",
"profile_id": "6606e08f10bcdd88297057a7",
"attach": [
{
"data": "data:text/csv;base64,5LuK5pel44GvCg==",
"name": "日本.txt"
},
{
"data": "data:text/csv;base64,SEVMTE8K",
"name": "US.txt"
}
],
"content": {
"data_lines": [
"Channel A",
"Channel B"
],
"email_title": "New videos on your favorite channels"
}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<id>96</id>
<matching>profile_id</matching>
<profile_id>6606e08f10bcdd88297057a7</profile_id>
<attach>
<data>data:text/csv;base64,5LuK5pel44GvCg==</data>
<name>日本.txt</name>
</attach>
<attach>
<data>data:text/csv;base64,SEVMTE8K</data>
<name>US.txt</name>
</attach>
<content>
<data_lines>Channel A</data_lines>
<data_lines>Channel B</data_lines>
<email_title>New videos on your favorite channels</email_title>
</content>
</xml>
Response example
- JSON
- XML
{
"data": null,
"error": 0,
"error_text": "Successful operation"
}
<xml>
<data/>
<error>0</error>
<error_text>Successful operation</error_text>
</xml>
Version 1.0
Description
Methods: GET, POST
In this version, each API trigger has a unique link that is displayed after it is created.
http://<your.tracking.domain>/trg/<base16_value_d1d93d9cca76a7c1742a2f23fbacd>/<email|md5|xxh>
The link will change if you change the trigger database.
Using link 1.0 allows you to send a trigger to only one profile per request.
"email"
is a deprecated parameter.
GET request {#Triggerlaunch(APIcall)-Method:GET}
Sends a message with no optional parameters.
Matches profiles by email, md5 hash or XX hash. XX hash profile matching example:
http://trk.example.org/trg/465ea6fedf0a75fa9ee0b5fb8f9d5fe89af34054909af8bb/dd78094ad0e36ca3
POST JSON request {#Triggerlaunch(APIcall)-Method:POST}
The same link is used as in the GET request.
http://trk.example.org/trg/465ea6fedf0a75fa9ee0b5fb8f9d5fe89af34054909af8bb/dd78094ad0e36ca3
With POST method you have an option to attach JSON data to message body.
You can override database field values for a campaign message or even update database fields.
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"id": 96,
"matching": "profile_id",
"profile_id": "6606e08f10bcdd88297057a7",
"fields": [
{
"name": "FirstName",
"value": "Jason",
"option": 0
},
{
"name": "Order",
"value": "123abc456-78",
"option": 1
}
]
}
<xml>
<token>2fefb577533d4cae919350c450755239</token>
<id>96</id>
<matching>profile_id</matching>
<profile_id>6606e08f10bcdd88297057a4</profile_id>
<fields>
<name>FirstName</name>
<value>Jason</value>
<option>0</option>
</fields>
<fields>
<name>Order</name>
<value>123abc456-78</value>
<option>1</option>
</fields>
</xml>
"name"
— profile database field name. If no field matches this name — it won't be used."value"
— profile database field value. Must match field data type."option"
— ( 0 | 1 | 2 ) determines data usage options."option": 0
— if a database field is not empty — request data will be ignored."option": 1
— request field value will be used in the message, but will not rewrite database value."option": 2
— request field value will be used in the message and will rewrite database value.