Import multiple profiles
Description
Adds or updates multiple profiles to or in a database.
Request URL
Method: POST
https://example.com/api/v1.1/profiles/import_batch
Request parameters
- For JSON body use the following header: Content-Type: application/json.
- For XML body use the following header: Content-Type: application/xml.
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
data | JSON array |
| Yes | Profile fields data |
db_id | int | 1 | Yes | Database ID |
skip_invalid_subscriptions | bool | true | No | Skip invalid subscriptions. By default – false |
skip_triggers | bool | true | No | Skip trigger events. By default – false |
detect_geo | bool | true | No | Detect location by _regip or _ip from data object |
Profile matching mode | ||||
matching | string | "email" "email_profile" "email_sub" "phone" "phone_sub" "profile_id" "push_sub" "custom" "custom_sub" "email_phone" "email_phone_sub" | No, if matched by email | Profile matching mode By default - email For each type of matching, certain fields must be passed in the request body. Learn more about these fields here. |
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 field name |
field_value | int/string | "123420" | "matching":"custom" | Custom 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 |
Subscriptions array
The subscriptions
array stores data about the profile's subscriptions to resources. One object is one subscription.
Parameter | Type | Example | Description |
---|---|---|---|
resource_id | int | 1 | Resource ID |
status | string | "subscribed" | Subscription status |
priority | int | 1 | Subscription priority |
custom_fields | object | { | System and custom subscription fields. You can get information about available subscription fields in a resource using the /v1.1/resources/fields_get method |
cats | array | [ | Resource categories to which to subscribe the profile. |
Email channel | |||
channel | string | "email" | Channel type |
string | "john@example.com" | ||
SMS channel | |||
channel | string | "sms" | Channel type |
phone | string | "+79000000000" | Phone number |
Push channel | |||
channel | string | "push" | Channel type |
provider | string | "Firefox" | Provider type |
subscription_id | string | "abcdefghijklmnqrstuvwxyz" | Subscription ID |
Telegram Bot channel | |||
channel | string | "telegram_bot" | Channel type |
cc_data | object | { | Telegram Bot chat ID |
WhatsApp channel | |||
channel | string | "whatsapp" | Channel type |
cc_data | object | { | Profile phone number on WhatsApp |
Viber channel | |||
channel | string | "viber" | Channel type |
cc_data | object | { | Profile phone number on Viber |
JSON request example
{
"data": [
{
"_fname": "John",
"_lname": "Doe",
"custom_id": "abcdefghijklmnqrstuvwxyz",
"email": "jane@example.com",
"subscriptions": [
{
"channel": "email",
"email_data": {
"email": "john@example.com"
},
"resource_id": 1,
"custom_fields": {
"_browser_name": "Firefox",
"_device_type": "web",
"custom_field_1": "test value"
},
"cats": [
"category_1",
"category_2"
]
}
]
}
],
"db_id": 1,
"matching": "custom",
"field_name": "custom_id",
"skip_triggers": true,
"detect_geo": true,
"token": "abcdefghijklmnqrstuvwxyz"
}
JSON response example
{
"error": 0,
"error_text": "Successful operation",
"result": [
{
"error": 0,
"error_text": "Successful operation",
"profile_id": "abcdefghijklmnqrstuvwxyz"
}
]
}
XML request example
<xml>
<token>e94ce55afc3e4e07bd64afb2227f8a5c</token>
<db_id>8</db_id>
<matching>email</matching>
<detect_geo>true</detect_geo>
<format>xml</format>
<skip_triggers>false</skip_triggers>
<data>
<lead>
<email>example@example.org</email>
<_fname>Leonid</_fname>
<_lname>Spartov</_lname>
<_bdate>1990-02-22T21:00:00Z</_bdate>
<_sex>M</_sex>
<_regip>94.231.119.122</_regip>
<custom_string>value1</custom_string>
<custom_integer>42</custom_integer>
<custom_date>1990-02-22T21:00:00Z</custom_date>
<custom_tags>tag1, tag2</custom_tags>
<custom_boolean>true</custom_boolean>
<custom_enum>2</custom_enum>
<custom_ip>94.231.119.122</custom_ip>
<subscriptions>
<subscription>
<resource_id>3</resource_id>
<channel>email</channel>
<email>example333@example.org</email>
</subscription>
<subscription>
<resource_id>3</resource_id>
<channel>phone</channel>
<phone>712345678550</phone>
</subscription>
<subscription>
<resource_id>3</resource_id>
<channel>push</channel>
<push_data>
<subscription_id>ONEOF77THESE11DAYS11dd1</subscription_id>
<provider>Firefox</provider>
</push_data>
</subscription>
</subscriptions>
</lead>
<lead>
<email>example2@example.org</email>
<_fname>Chuck</_fname>
<_lname>Norris</_lname>
<_bdate>1985-02-22T21:00:00Z</_bdate>
<_sex>M</_sex>
<_regip>94.232.119.122</_regip>
<custom_string>value2</custom_string>
<custom_integer>42</custom_integer>
<custom_date>1920-02-22T21:00:00Z</custom_date>
<custom_tags>tag3, tag4</custom_tags>
<custom_boolean>false</custom_boolean>
<custom_enum>3</custom_enum>
<custom_ip>94.234.119.122</custom_ip>
<subscriptions>
<subscription>
<resource_id>3</resource_id>
<channel>email</channel>
<email>example276@example.org</email>
</subscription>
<subscription>
<resource_id>3</resource_id>
<channel>phone</channel>
<phone>73214562290</phone>
</subscription>
<subscription>
<resource_id>3</resource_id>
<channel>push</channel>
<push_data>
<subscription_id>CU86TYOU5INTO34LITT25LEPIE55CES</subscription_id>
<provider>Chrome</provider>
</push_data>
</subscription>
</subscriptions>
</lead>
</data>
</xml>
XML response example
<result>
<error>0</error>
<error_text></error_text>
<result>
<error>0</error>
<error_text>Successful operation</error_text>
<error_field></error_field>
<profile_id>5dd3cfa5c484d021d6e5204f</profile_id>
</result>
<result>
<error>0</error>
<error_text>Successful operation</error_text>
<error_field></error_field>
<profile_id>5dd3cfd0c484d021d6e52050</profile_id>
</result>
</result>
Response parameters
Parameter | Type | Description |
---|---|---|
error | int | Error code |
error_text | string | Error text |
result | array of object | Update results by profiles The order of the objects in the returned result array repeats the order of the objects in the input data array. |
result.error | int | Error code, for profile |
result.error_text | string | Error text, for profile |
result.profile_id | string | Profile ID |