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 |
Request example
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"matching": "custom",
"field_name": "Custom_ID",
"skip_triggers": true,
"data": [
{
"_fname": "Lala",
"_lname": "Doe",
"Custom_ID": 77,
"email": "example@example.com",
"subscriptions": [
{
"channel": "email",
"email_data": {
"email": "example@example.com"
},
"resource_id": 28,
"custom_fields": {
"custom_field": "test value"
},
"cats": [
"category_1",
"category_2"
]
}
]
},
{
"_fname": "Victor",
"Custom_ID": 88,
"email": "example@example.com"
}
]
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<db_id>1</db_id>
<matching>custom</matching>
<field_name>Custom_ID</field_name>
<skip_triggers>true</skip_triggers>
<data>
<_fname>Lala</_fname>
<_lname>Doe</_lname>
<Custom_ID>77</Custom_ID>
<email>example@example.com</email>
<subscriptions array='true'>
<channel>email</channel>
<email_data>
<email>example@example.com</email>
</email_data>
<resource_id>28</resource_id>
<custom_fields>
<custom_field>test value</custom_field>
</custom_fields>
<cats>category_1</cats>
<cats>category_2</cats>
</subscriptions>
</data>
<data>
<_fname>Alex</_fname>
<Custom_ID>345</Custom_ID>
<email>example@example.com</email>
</data>
</xml>
Response example
- JSON
- XML
{
"error": 0,
"error_text": "Successful operation",
"result": [
{
"error": 0,
"error_text": "Successful operation",
"profile_id": "abcdefghijklmnqrstuvwxyz"
}
]
}
<xml>
<error>0</error>
<error_text>Successful operation</error_text>
<result>
<error>0</error>
<error_text>Successful operation</error_text>
<profile_id>abcdefghijklmnqrstuvwxyz</profile_id>
</result>
</xml>
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 |
*The Meta organization, which owns Instagram, Facebook and WhatsApp products, has been declared as extremist and banned in Russia.