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 | Add some data to be used in Action hooks. The parameter can be passed either at the root of the request or separately in each data object. |
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
Parameter | Type | Description |
---|---|---|
error_text | string | Error text |
error | int | Error code |
task_id | string | Task identifier |
Request example (matching by email)
{
"token": "abcdefghijklmnqrstuvwxyz",
"matching": "email",
"data": [
{
"data": {
"_fname": "John",
"_lname": "Lambert",
"email": "profile4@example.com",
"phones": "+790000000000",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"resource_id": 1
},
{
"channel": "phone",
"phone": "+790000000000",
"resource_id": 1
}
]
}
},
{
"data": {
"_fname": "Tom",
"_lname": "Hard",
"email": "profile3@example.com",
"phones": "+790000000001",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"resource_id": 1
},
{
"channel": "phone",
"phone": "+790000000000",
"resource_id": 1
}
]
}
}
],
"trigger_id": 13,
"content": {
"page": "registration_form"
},
"attach": [
{
"data": "data:text/csv;base64,5LuK5pel44GvCg==",
"name": "Attach.txt"
}
]
}
Request example (matching by custom field)
{
"token": "abcdefghijklmnqrstuvwxyz",
"trigger_id": 455,
"format": "json",
"skip_triggers": false,
"detect_geo": true,
"matching": "custom",
"field_name": "New_field_1",
"data": [
{
"data": {
"_fname": "NUMBER1",
"_lname": "Lambert",
"email": "profile01@example.com",
"phones": "+790000000000",
"New_field_1" : "0002"
}
},
{
"data" : {
"_fname": "NUMBER2",
"_lname": "Hard",
"email": "profile02@example.com",
"phones": "+790000000001",
"New_field_1" : "0001"
}
}
]
}
Response example
{
"error": 0,
"error_text": "Successful operation",
"task_id": "30421978-7f6d-4f39-913f-fb6cad8e2477"
}
Response example when a request constraint is triggered
{
"error":400,
"error_debug":"http: request body too large",
"error_text":"Invalid request"
}
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
{
"token": "abcdefghijklmnqrstuvwxyz",
"task_id": "task_b2f9fk6a-2479-4a63-b592-f15d4e3b69c5"
}
Response example
{
"data": {
"status": "completed",
"progress": 100,
"result": {
"error": 0,
"error_text": "",
"result": [
{
"profile_id": "61e947333f62fc26d384452c"
},
{
"profile_id": "61e947333f62fc26d384452e"
}
]
}
},
"error": 0,
"error_text": "Successful operation"
}