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
Parameter | Type | Example | Required | Description |
---|---|---|---|---|
token | string | "abcdefghijklmnqrstuvwxyz" | Yes | API token |
format | string | "json" | No | Response data format. By default – json. |
db_id | int | 1 | Yes | Database ID |
profile_id | string | "abcdefghijklmnqrstuvwxyz" | Yes | Profile ID |
resource_id | int | 1 | Yes | Resource ID |
status | string | "subscribed" | No | Subscription status. We recommend that you pass the parameter only when you need to update the subscription status. |
priority | int | No | Subscription priority | |
custom_fields | object | { | No | 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 | [ | No | Resource categories to which you need to subscribe a profile |
date | string | 2018-08-22T00:00:00.000Z | No | Registration date in RFC 3339 format |
ip | string | 10.250.13.5 | No | Registration IP |
url | string | https://example.com/ | No | Registration URL |
skip_triggers | bool | true | No | Skip trigger events. By default – false. |
Additionally for the Email channel:
Parameters | Type | Example | Description |
---|---|---|---|
channel | string | "email" | Channel type |
string | "john@example.com" | Email address |
Additionally for the Push channel:
Parameters | Type | Example | Description |
---|---|---|---|
channel | string | "push" | Channel type |
provider | string | "Firefox" | Push provider |
subscription_id | string | "abcdefghijklmnqrstuvwxyz" | Subscription ID |
Additionally for the SMS channel:
Parameters | Type | Example | Description |
---|---|---|---|
channel | string | "sms" | Channel type |
phone | string | "+79000000000" | Phone number |
Additionally for the Telegram channel:
Parameters | Type | Example | Description |
---|---|---|---|
channel | string | "telegram_bot" | Channel type |
cc_data | object | { | Chat ID between Telegram bot and user |
Additionally for the WhatsApp* channel:
Parameters | Type | Example | Description |
---|---|---|---|
channel | string | "whatsapp" | Channel type |
cc_data | object | { | WhatsApp* user's phone number |
Request example
- JSON
- XML
{
"token": "abcdefghijklmnqrstuvwxyz",
"db_id": 1,
"resource_id": 1,
"channel": "email",
"email": "example@example.com",
"priority": 10,
"profile_id": "abcdefghijklmnqrstuvwxyz",
"status": "suspended"
}
<xml>
<token>abcdefghijklmnqrstuvwxyz</token>
<db_id>1</db_id>
<resource_id>29</resource_id>
<channel>email</channel>
<email>example@example.com</email>
<priority>10</priority>
<profile_id>abcdefghijklmnqrstuvwxyz</profile_id>
<status>suspended</status>
</xml>
Response example
- JSON
- XML
{
"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"
}
<xml>
<data>
<action>subscribed</action>
<is_new_channel>false</is_new_channel>
<is_new_contact>false</is_new_contact>
<is_new_subscription>true</is_new_subscription>
<is_restored>false</is_restored>
<is_safe>true</is_safe>
</data>
<error>0</error>
<error_text>Successful operation</error_text>
</xml>
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
Parameter | Type | Description |
---|---|---|
error | int | Error code |
error_text | string | Error text |
action | string | Subscription update result |
is_safe | bool | Safe and successful operation (no hard bounces etc) |
is_new_subscription | bool | New for this resource |
is_new_channel | bool | New for this channel of an existing resource |
is_new_contact | bool | New subscription for an existing channel |
is_restored | bool | A previously deleted subscription restored |
*The Meta organization, which owns Instagram, Facebook and WhatsApp products, has been declared as extremist and banned in Russia.