Task for bulk profiles import + trigger launch
Description
Add or update multiple profiles and then send a trigger campaign.
This request is a batch version of the Profile import + trigger campaign launch request.
Returns a response with the task id, without waiting for completion.
note
The request body size is limited by default to 10 Mb, exception for files — 100 Mb.
Request URL
Метод: POST
http://example.com/api/v1.1/campaigns/triggers/import_and_start_batch_task
Request parameters
Parameters | Type | Example | Required | Description |
---|---|---|---|---|
Profile import | ||||
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
data | JSON object | [ | Yes | Profile fields data |
skip_triggers | bool | true | No | Skip trigger events. By default – false |
skip_invalid_subscriptions | bool | true | No | Skip invalid subscriptions By default – false |
detect_geo | bool | true | No | Detect location by _regip or _ip from data object |
Profile matching mode | ||||
matching | string | "email" | No, if matched by email from profile or subscriptions | Profile matching mode By default - email |
string | "john@example.com" | "matching":"email" - both profile data and subscriptions "matching":"email_profile" - profile data only | 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 |
Trigger launch | ||||
trigger_id | int | 13 | Yes | Trigger campaign ID |
custom_data | JSON object |
| No | Data used for integration Action hooks |
content | JSON object |
| No | Data you can use in a message template using {apicontent.fieldname} variable |
attach | JSON objects array |
| No | A file you can attach to an Email message |
Response parameters
Параметр | Тип | Описание |
---|---|---|
error_text | string | Текст ошибки |
error | int | Код ошибки |
task_id | string | Идентификатор задачи |
Request example (matching by email)
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"matching": "email",
"data": [
{
"data": {
"_fname": "Victoria",
"_lname": " Beckham",
"email": "example1@example.com",
"phones": "+79000000000",
"subscriptions": [
{
"channel": "email",
"email": "example2@example.com",
"resource_id": 21
},
{
"channel": "phone",
"phone": "+79000005478",
"resource_id": 20
}
]
}
},
{
"data": {
"_fname": "David",
"_lname": " Beckham",
"email": "example3@example.com",
"phones": "+79000000001",
"subscriptions": [
{
"channel": "email",
"email": "example14@example.com",
"resource_id": 21
},
{
"channel": "phone",
"phone": "+79000000000",
"resource_id": 20
}
]
}
}
],
"trigger_id": 96,
"timeout": {
"days": 0,
"hours": 0,
"minutes": 5
},
"content": {
"page": "registration_form"
},
"attach": [
{
"data": "data:text/csv;base64,5LuK5pel44GvCg==",
"name": "Attach.txt"
}
]
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<matching>email</matching>
<data>
<_fname>Brooklyn</_fname>
<_lname>Beckham</_lname>
<email>example3@example.com</email>
<phones>+79000849376</phones>
<subscriptions>
<channel>email</channel>
<email>example9@example.com</email>
<resource_id>21</resource_id>
</subscriptions>
<subscriptions>
<channel>phone</channel>
<phone>+79000005475</phone>
<resource_id>20</resource_id>
</subscriptions>
</data>
<data>
<_fname>Romeo</_fname>
<_lname>Beckham</_lname>
<email>example32@example.com</email>
<phones>+79000000651</phones>
<subscriptions>
<channel>email</channel>
<email>@example.com</email>
<resource_id>21</resource_id>
</subscriptions>
<subscriptions>
<channel>phone</channel>
<phone>+79000880000</phone>
<resource_id>20</resource_id>
</subscriptions>
</data>
<trigger_id>96</trigger_id>
<timeout>
<days>0</days>
<hours>0</hours>
<minutes>5</minutes>
</timeout>
<content>
<page>registration_form</page>
</content>
<attach array='true'>
<data>data:text/csv;base64,5LuK5pel44GvCg==</data>
<name>Attach.txt</name>
</attach>
</xml>
Request example (matching by custom field)
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"trigger_id": 96,
"format": "json",
"skip_triggers": false,
"detect_geo": true,
"matching": "custom",
"field_name": "Custom_id",
"data": [
{
"data": {
"_fname": "Tom",
"_lname": "Cruise",
"email": "example@example.com",
"phones": "+79000000000",
"Custom_id": "0002"
}
},
{
"data": {
"_fname": "Lili",
"_lname": "Hard",
"email": "example@example.com",
"phones": "+79000000001",
"Custom_id": "0001"
}
}
]
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<trigger_id>96</trigger_id>
<format>xml</format>
<skip_triggers>false</skip_triggers>
<detect_geo>true</detect_geo>
<matching>custom</matching>
<field_name>Custom_ID</field_name>
<data>
<_fname>Viola</_fname>
<_lname>Lambert</_lname>
<email>example@example.com</email>
<phones>+79000000000</phones>
<Custom_ID>0002</Custom_ID>
</data>
<data>
<_fname>Will</_fname>
<_lname>Hard</_lname>
<email>example@example.com</email>
<phones>+79000000001</phones>
<Custom_ID>0001</Custom_ID>
</data>
</xml>
Response example
- JSON
- XML
{
"error": 0,
"error_text": "Successful operation",
"task_id": "1c1a5861-6d4c-4d6f-bd6a-3ca4f46b217d"
}
<xml>
<error>0</error>
<error_text>Successful operation</error_text>
<task_id>30421978-7f6d-4f39-913f-fb6cad8e2477</task_id>
</xml>
Response example when a request constraint is triggered
- JSON
- XML
{
"error":400,
"error_debug":"http: request body too large",
"error_text":"Invalid request"
}
<xml>
<error>400</error>
<error_text>Invalid request</error_text>
</xml>
Checking task status
Request URL
Method: POST
https://example.com/api/v1.1/tasks/status
Request parameters
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Да | API token |
task_id | string | "task_b2f9fk6a-2479-4a63-b592-f15d4e3b69c5" | Да | Task ID |
Request example
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"task_id": "task_b2f9fk6a-2479-4a63-b592-f15d4e3b69c5"
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<task_id>d521abe0-1abf-4e1d-b247-a790be66a424</task_id>
</xml>
Response example
- JSON
- XML
{
"data": {
"status": "completed",
"progress": 100,
"result": {
"error": 0,
"error_text": "",
"result": [
{
"profile_id": "61e947333f62fc26d384452c"
},
{
"profile_id": "61e947333f62fc26d384452e"
}
]
}
},
"error": 0,
"error_text": "Successful operation"
}
<xml>
<data>
<progress>100</progress>
<result>
<captured>0</captured>
<errors/>
<status>ok</status>
</result>
<status>completed</status>
</data>
<error>0</error>
<error_text>Successful operation</error_text>
</xml>