Bulk profiles import + trigger mailing launch
Description
Add or update multiple profiles and then send a trigger mailing.
This request is a batch version of the Profile import + trigger mailing launch request.
note
The request body size is limited by default to 10 Mb, exception for files — 100 Mb.
Data field rules
The rules apply to the data object inside each element of the data array.
- The field value must be valid for the field type: numeric fields accept a number, "list" fields accept a variant name from the list or its ordinal number, etc. If the value does not match the field type (for example, a string that is not in the list of variants is passed to a list field), the request returns an error. Value formats for custom fields are listed in the Custom field value formats section.
- Only the fields explicitly passed in the
dataobject inside each element of thedataarray are updated. If some profile fields should not change, do not pass them in the request. - Each profile in the
dataarray is processed independently: if a field value in one profile fails validation, that profile is not imported and not sent to the trigger campaign, while the remaining profiles are processed. The error for this profile is returned in the request response. - For more flexible field value management, use database fields functional update.
Request URL
Method: POST
http://example.com/api/v1.1/campaigns/triggers/import_and_start_batch
Request parameters
| Parameters | Type | Example | Required | Description |
|---|---|---|---|---|
| Profile import | ||||
| 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 |
| 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. |
| 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 mailing ID |
| timeout | JSON object | | No | Trigger start timeout. Specify the days, hours, and minutes to set the timeout period. |
| expiration | string | "2026-02-22T21:00:00Z" | No | Message expiration date in RFC3339 format, after which it will be removed from the queue and a delivery failure event will be recorded |
| 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
| Parameter | Type | Description |
|---|---|---|
| error_text | string | Error text |
| error | int | Error code |
| result | array | IDs of successfully imported profiles |
Request example (matching by email)
- JSON
- XML
{
"trigger_id": 96,
"format": "json",
"skip_triggers": false,
"detect_geo": true,
"matching": "email",
"data": [
{
"data": {
"_fname": "Lili",
"_lname": "Collins",
"email": "example@example.com",
"phones": "+79000000000",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"priority": 0,
"resource_id": 21,
"status": 0
}
]
}
},
{
"data": {
"_fname": "Eva",
"_lname": "Collins",
"email": "example@example.com",
"phones": "+79000000001",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"priority": 0,
"resource_id": 21,
"status": 0
}
]
}
}
]
}
<xml>
<trigger_id>96</trigger_id>
<format>xml</format>
<skip_triggers>false</skip_triggers>
<detect_geo>true</detect_geo>
<matching>email</matching>
<data>
<_fname>Lili</_fname>
<_lname>Collins</_lname>
<email>example@example.com</email>
<phones>+79000000000</phones>
<subscriptions>
<channel>email</channel>
<email>example@example.com</email>
<priority>0</priority>
<resource_id>21</resource_id>
<status>0</status>
</subscriptions>
</data>
<data>
<_fname>Eva</_fname>
<_lname>Collins</_lname>
<email>example@example.com</email>
<phones>+79000000001</phones>
<subscriptions>
<channel>email</channel>
<email>example@example.com</email>
<priority>0</priority>
<resource_id>21</resource_id>
<status>0</status>
</subscriptions>
</data>
</xml>
Request example (matching by custom field)
- JSON
- XML
{
"trigger_id": 85,
"format": "json",
"skip_triggers": false,
"detect_geo": true,
"matching": "custom",
"field_name": "Custom_ID",
"data": [
{
"data": {
"_fname": "Adama",
"_lname": "Fuller",
"email": "example@example.com,
"phones": "+79000000000",
"Custom_ID": "345",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"priority": 0,
"resource_id": 21,
"status": 0
}
]
}
},
{
"data": {
"_fname": "Eva",
"_lname": "Fuller",
"email": "example@example.com",
"phones": "+79000000001",
"Custom_ID": "567",
"subscriptions": [
{
"channel": "email",
"email": "example@example.com",
"priority": 0,
"resource_id": 21,
"status": 0
}
]
}
}
]
}
<xml>
<trigger_id>85</trigger_id>
<format>xml</format>
<skip_triggers>false</skip_triggers>
<detect_geo>true</detect_geo>
<matching>custom</matching>
<field_name>custom_field</field_name>
<data>
<_fname>Irina</_fname>
<_lname>Depp</_lname>
<email>example@example.com</email>
<phones>+79000000000</phones>
<custom_field>343</custom_field>
<subscriptions array='true'>
<channel>email</channel>
<email>example@example.com</email>
<priority>0</priority>
<resource_id>21</resource_id>
<status>0</status>
</subscriptions>
</data>
<data>
<_fname>Will</_fname>
<_lname>Depp</_lname>
<email>example@example.com</email>
<phones>+79000000001</phones>
<custom_field>560</custom_field>
<subscriptions array='true'>
<channel>email</channel>
<email>example@example.com</email>
<priority>0</priority>
<resource_id>21</resource_id>
<status>0</status>
</subscriptions>
</data>
</xml>
Response example
- JSON
- XML
{
"error": 0,
"error_text": "Successful operation",
"result": [
{
"profile_id": "602103d65ae47a3bc65d5d83"
},
{
"profile_id": "601ec71c5ae47a15d1c9b472"
}
]
}
<xml>
<error>0</error>
<error_text>Successful operation</error_text>
<result>
<element>
<profile_id>602103d65ae47a3bc65d5d83</profile_id>
</element>
<element>
<profile_id>601ec71c5ae47a15d1c9b472</profile_id>
</element>
</result>
</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_debug>http: request body too large</error_debug>
<error_text>"Invalid request"</error_text>
</xml>