Subscription fields functional update
When you use requests to update profile's subscription fields, you can include functions in field values.
A function here is a set of an operator and a value:
{
"action": "set",
"value": "x",
}
action
operator can be:
action | Usage | Field type | value |
---|---|---|---|
set | Set is a default operator for request parameters | All types: string, int, float, boolean | Any field value |
delete | Deletes a field from a profile. For custom fields only. | All types: string, int, float, boolean | No value |
incr | Increases field value. Integer type fields only | int, float | Integer number |
tip
You can find a description of the resource subscription fields at this link.
Example request /v1.1/subscriptions/set to update subscription system fields
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"channel": "email",
"db_id": 1,
"email": "example@example.com",
"profile_id": "6527e4e2097c54377ee0e41d",
"resource_id": 1,
"status": "subscribe",
"cats": [
"category_1",
"category_2"
],
"custom_fields": {
"_ad_id": {
"action":"set",
"value":"qwerty123"
},
"_ad_track":{
"action":"set",
"value":true
},
"_app_id": {
"action":"delete"
},
"_app_iid": {
"action":"set",
"value":"example iid"
},
"_app_ver": {
"action":"set",
"value": "v1.2.3.4"
},
"_browser_name":{
"action":"set",
"value":"Chrome"
},
"_browser_ver": {
"action":"set",
"value":"4.5.6.7.8"
},
"_device_model": {
"action":"set",
"value":"Device model"
},
"_device_name":{
"action":"set",
"value":"Device name"
},
"_device_type": {
"action":"set",
"value":"Mobile"
},
"_os": {
"action":"set",
"value":"Android"
},
"_os_language": {
"action":"set",
"value":"ru"
},
"_os_tz": {
"action":"set",
"value":"Europe/Moscow"
},
"_os_ver": {
"action":"set",
"value": "v1.2.3.4"
}
}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<channel>email</channel>
<db_id>1</db_id>
<email>example@example.com</email>
<profile_id>66102b984a5d12bd6cc09132</profile_id>
<resource_id>29</resource_id>
<status>subscribe</status>
<cats>category_1</cats>
<cats>category_2</cats>
<custom_fields>
<_ad_id>
<action>set</action>
<value>qwerty123</value>
</_ad_id>
<_ad_track>
<action>set</action>
<value>true</value>
</_ad_track>
<_app_id>
<action>delete</action>
</_app_id>
<_app_iid>
<action>set</action>
<value>example iid</value>
</_app_iid>
<_app_ver>
<action>set</action>
<value>v1.2.3.4</value>
</_app_ver>
<_browser_name>
<action>set</action>
<value>Chrome</value>
</_browser_name>
<_browser_ver>
<action>set</action>
<value>4.5.6.7.8</value>
</_browser_ver>
<_device_model>
<action>set</action>
<value>Device model</value>
</_device_model>
<_device_name>
<action>set</action>
<value>Device name</value>
</_device_name>
<_device_type>
<action>set</action>
<value>Mobile</value>
</_device_type>
<_os>
<action>set</action>
<value>Android</value>
</_os>
<_os_language>
<action>set</action>
<value>ru</value>
</_os_language>
<_os_tz>
<action>set</action>
<value>Europe/Moscow</value>
</_os_tz>
<_os_ver>
<action>set</action>
<value>v1.2.3.4</value>
</_os_ver>
</custom_fields>
</xml>
Example request /v1.1/subscriptions/set to update custom subscription fields
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"channel": "email",
"db_id": 1,
"email": "example@example.com",
"profile_id": "6527e4e2097c54377ee0e41d",
"resource_id": 1,
"status": "subscribe",
"cats": [
"category_1",
"category_2"
],
"custom_fields": {
"custom_str_field": {
"action": "set",
"value": "example value"
},
"custom_int_field_1": {
"action": "incr",
"value": 1000
},
"custom_int_field_2": {
"action": "incr",
"value": -1000
},
"custom_bool_field": {
"action": "delete"
}
}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<channel>email</channel>
<db_id>1</db_id>
<email>example@example.com</email>
<profile_id>6613c4bf4a5d12bd6cc0916b</profile_id>
<resource_id>29</resource_id>
<status>subscribe</status>
<cats>category_1</cats>
<cats>category_2</cats>
<custom_fields>
<custom_str_field>
<action>set</action>
<value>example value</value>
</custom_str_field>
<custom_int_field_1>
<action>incr</action>
<value>1000</value>
</custom_int_field_1>
<custom_int_field_2>
<action>incr</action>
<value>-1000</value>
</custom_int_field_2>
<custom_bool_field>
<action>delete</action>
</custom_bool_field>
</custom_fields>
</xml>
Example request /v1.1/profiles/import to update subscription system fields
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"matching": "email",
"email": "example@example.com",
"data": {
"_fname": "John",
"_lname": "Doe",
"email": "example@example.com",
"subscriptions": [
{
"channel": "push",
"subscription_id": "9f135a38-aa7e-4bf3-8d75-de971d597cf0",
"provider": "MR",
"resource_id": 1,
"custom_fields": {
"_ad_id": {
"action": "set",
"value": "qwerty123"
},
"_ad_track": {
"action": "set",
"value": true
},
"_app_id": {
"action": "set",
"value": "123"
},
"_app_iid": {
"action": "set",
"value": "123"
},
"_app_ver": {
"action": "set",
"value": "v1.2.3.4"
},
"_browser_name": {
"action": "set",
"value": "Chrome"
},
"_browser_ver": {
"action": "set",
"value": "4.5.6.7.8"
},
"_device_model": {
"action": "set",
"value": "Device model"
},
"_device_name": {
"action": "set",
"value": "Device name"
},
"_device_type": {
"action": "set",
"value": "Mobile"
},
"_os": {
"action": "set",
"value": "Android"
},
"_os_language": {
"action": "set",
"value": "ru"
},
"_os_tz": {
"action": "set",
"value": "Europe/Moscow"
},
"_os_ver": {
"action": "set",
"value": "v1.2.3.4"
}
}
}
]
}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<db_id>1</db_id>
<matching>email</matching>
<email>example@example.com</email>
<data>
<_fname>Fillippina</_fname>
<_lname>Doe</_lname>
<email>example@example.com</email>
<subscriptions array='true'>
<channel>push</channel>
<subscription_id>9f135a38-aa7e-4bf3-8d75-de971d597cf0</subscription_id>
<provider>MR</provider>
<resource_id>26</resource_id>
<custom_fields>
<_ad_id>
<action>set</action>
<value>qwerty123</value>
</_ad_id>
<_ad_track>
<action>set</action>
<value>true</value>
</_ad_track>
<_app_id>
<action>delete</action>
</_app_id>
<_app_iid>
<action>set</action>
<value>example iid</value>
</_app_iid>
<_app_ver>
<action>set</action>
<value>v1.2.3.4</value>
</_app_ver>
<_browser_name>
<action>set</action>
<value>Chrome</value>
</_browser_name>
<_browser_ver>
<action>set</action>
<value>4.5.6.7.8</value>
</_browser_ver>
<_device_model>
<action>set</action>
<value>Device model</value>
</_device_model>
<_device_name>
<action>set</action>
<value>Device name</value>
</_device_name>
<_device_type>
<action>set</action>
<value>Mobile</value>
</_device_type>
<_os>
<action>set</action>
<value>Android</value>
</_os>
<_os_language>
<action>set</action>
<value>ru</value>
</_os_language>
<_os_tz>
<action>set</action>
<value>Europe/Moscow</value>
</_os_tz>
<_os_ver>
<action>set</action>
<value>v1.2.3.4</value>
</_os_ver>
</custom_fields>
</subscriptions>
</data>
</xml>
Example request /v1.1/profiles/import to update custom subscription fields
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"matching": "email",
"email": "example@example.com",
"data": {
"_fname": "John",
"_lname": "Doe",
"email": "example@example.com",
"subscriptions": [
{
"channel": "email",
"channel_sid": "email",
"email": "example@example.com",
"resource_id": 1
},
{
"channel": "sms",
"phone": "+79203214111",
"resource_id": 1
},
{
"channel": "push",
"subscription_id": "9f135a38-aa7e-4bf3-8d75-de971d597cf0",
"provider": "MR",
"resource_id": 1,
"custom_fields": {
"custom_str_field": {
"action": "set",
"value": "example value"
},
"custom_int_field": {
"action": "incr",
"value": 1000
},
"custom_bool_field": {
"action": "delete"
}
}
}
]
}
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<db_id>1</db_id>
<matching>email</matching>
<email>example@example.com</email>
<data>
<_fname>Fillippina</_fname>
<_lname>Doe</_lname>
<email>example@example.com</email>
<subscriptions>
<channel>email</channel>
<channel_sid>email</channel_sid>
<email>example@example.com</email>
<resource_id>1</resource_id>
</subscriptions>
<subscriptions>
<channel>sms</channel>
<phone>+79203214111</phone>
<resource_id>1</resource_id>
</subscriptions>
<subscriptions>
<channel>push</channel>
<subscription_id>9f135a38-aa7e-4bf3-8d75-de971d597cf0</subscription_id>
<provider>MR</provider>
<resource_id>1</resource_id>
<custom_fields>
<custom_str_field>
<action>set</action>
<value>example value</value>
</custom_str_field>
<custom_int_field>
<action>incr</action>
<value>1000</value>
</custom_int_field>
<custom_bool_field>
<action>delete</action>
</custom_bool_field>
</custom_fields>
</subscriptions>
</data>
</xml>