Skip to main content

Add or edit subscription

Description

Adds or edits profile subscriptions. Changes subscription status.

Request URL

Method: POST

https://example.com/api/v1.1/subscriptions/set

Request parameters

ParameterTypeExampleRequiredDescription
tokenstring"abcdefghijklmnqrstuvwxyz"YesAPI token
formatstring"json"NoResponse data format.
By default – json.
db_idint1YesDatabase ID
profile_idstring"abcdefghijklmnqrstuvwxyz"YesProfile ID
resource_idint1YesResource ID
statusstring"subscribed"NoSubscription status.

We recommend that you pass the parameter only when you need to update the subscription status.
priorityintNoSubscription priority
custom_fieldsobject
{
   "_browser_name": "Chrome",
   "_device_type": "web"
}
NoSystem and custom subscription fields.

You can get information about available subscription fields in a resource using the /v1.1/resources/fields_get method
catsarray
[
   "category_1",
   "category_2"
]
NoResource categories to which you need to subscribe a profile
datestring2018-08-22T00:00:00.000ZNoRegistration date in RFC 3339 format
ipstring10.250.13.5NoRegistration IP
urlstringhttps://example.com/NoRegistration URL
skip_triggersbooltrueNoSkip trigger events.
By default – false.

Additionally for the Email channel:

ParametersTypeExampleDescription
channelstring"email"Channel type
emailstring"john@example.com"Email address

Additionally for the Push channel:

ParametersTypeExampleDescription
channelstring"push"Channel type
providerstring"Firefox"Push provider
subscription_idstring"abcdefghijklmnqrstuvwxyz"Subscription ID

Additionally for the SMS channel:

ParametersTypeExampleDescription
channelstring"sms"Channel type
phonestring"+79000000000"Phone number

Additionally for the Telegram channel:

ParametersTypeExampleDescription
channelstring"telegram_bot"Channel type
cc_dataobject
{
"id": 1
}
Chat ID between Telegram bot and user

Additionally for the WhatsApp* channel:

ParametersTypeExampleDescription
channelstring"whatsapp"Channel type
cc_dataobject
{
"phone": "+79000000000"
}
WhatsApp* user's phone number

Request example

{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"resource_id": 1,
"channel": "email",
"email": "example@example.com",
"priority": 10,
"profile_id": "abcdefghijklmnqrstuvwxyz",
"status": "suspended"
}

Response example

{
"data": {
"action": "subscribed",
"is_new_channel": false,
"is_new_contact": false,
"is_new_subscription": true,
"is_restored": false,
"is_safe": true
},
"error": 0,
"error_text": "Successful operation"
}
caution

Please note that the "Increase priority for new subscriptions" option in the resource works only if a priority is not explicitly specified when adding a new subscription. If the priority for the new subscription is passed in the API request, then the priorities of existing subscriptions for the profile will not change.

Response parameters

ParameterTypeDescription
errorintError code
error_textstringError text
actionstringSubscription update result
is_safeboolSafe and successful operation (no hard bounces etc)
is_new_subscriptionboolNew for this resource
is_new_channelboolNew for this channel of an existing resource
is_new_contactboolNew subscription for an existing channel
is_restoredboolA previously deleted subscription restored

*The Meta organization, which owns Instagram, Facebook and WhatsApp products, has been declared as extremist and banned in Russia.