Skip to main content

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:

actionUsageField typevalue
setSet is a default operator for request parametersAll types: string, int, float, booleanAny field value
deleteDeletes a field from a profile. For custom fields only.All types: string, int, float, booleanNo value
incrIncreases field value. Integer type fields onlyint, floatInteger 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

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

Example request /v1.1/subscriptions/set to update custom subscription fields

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

Example request /v1.1/profiles/import to update subscription system fields

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

Example request /v1.1/profiles/import to update custom subscription fields

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