Skip to main content

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

ParametersTypeExampleRequiredDescription
Profile import
tokenstring"abcdefghijklmnqrstuvwxyz"YesAPI token
dataJSON object
[
   {
      "data": {
         "_fname": "John",
         "_lname": "Lambert",
         "email": "profile4@example.com",
         "phones": "+790000000000"
      }
   },
   {
      "data": {
         "_fname": "Tom",
         "_lname": "Hard",
         "email": "profile3@example.com",
         "phones": "+790000000001"
      }
   }
]
YesProfile fields data
skip_triggersbooltrueNoSkip trigger events.
By default – false
skip_invalid_subscriptionsbooltrueNoSkip invalid subscriptions
By default – false
detect_geobooltrueNoDetect location by _regip or _ip from data object
Profile matching mode
matchingstring

"email"
"email_profile"
"phone"
"profile_id"
"custom"

No, if matched by email from profile or subscriptionsProfile matching mode
By default - email
emailstring"john@example.com""matching":"email" - both profile data and subscriptions

"matching":"email_profile" - profile data only
Email address
phonestring"+79000000000""matching":"phone"Phone number
profile_idstring"abcdefghijklmnqrstuvwxyz""matching":"profile_id"Profile ID
field_namestring"CRM_ID""matching":"custom"Custom profile data field name
field_valueint/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_idint24NoResource ID for email and phone matching
Trigger launch
trigger_idint13YesTrigger campaign ID
custom_dataJSON object
{
"sending_time": "12:31:12"
}
NoData used for integration Action hooks
contentJSON object
{
"page": "registration_form"
}
NoData you can use in a message template using {apicontent.fieldname} variable
attachJSON objects array
{
"data": "data:text/csv;base64,SEVMTE8K",
"name": "Attach.txt"
}
NoA file you can attach to an Email message

Response parameters

ПараметрТипОписание
error_textstringТекст ошибки
errorintКод ошибки
task_idstringИдентификатор задачи

Request example (matching by email)

{
"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"
}
]
}

Request example (matching by custom field)

{
"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"
}
}
]
}

Response example

{
"error": 0,
"error_text": "Successful operation",
"task_id": "1c1a5861-6d4c-4d6f-bd6a-3ca4f46b217d"
}

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

ParameterTypeExampleRequiredDescription
tokenstring"abcdefghijklmnqrstuvwxyz"ДаAPI token
task_idstring"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"
}