Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v74
  • v74
  • v73
  • v72
Login
  • User documentation
  • FAQ
  • Altcraft glossary
  • Profiles and databases
  • Communication channels
    • Email channel
    • Push channel
      • Mobile Push
        • Settings & implementation
        • Integrate your app with Altcraft
          • Providers: push message structure
          • Processing and adding a subscription
          • Event registration
      • Web push
    • SMS channel
    • Creating mailing from scratch
    • Communication Channels Workflow
    • Руководство: SMS-рассылка через УТШ
    • Руководство: push-рассылка через сервис от "Согласие"
  • Segmentation
  • Message templates
  • Mailings
  • Campaigns
  • Automation scenarios
  • Market
  • Loyalty programs
  • Reports and analytics
  • Integrations
  • Weblayers
  • Settings
  • API requests: where to start
  • Changelog
  • library
  • Communication channels
  • Push channel
  • Mobile Push
  • Integrate your app with Altcraft
  • Processing and adding a subscription
Documentation for version v74

Processing and adding a subscription

Once the app received a push token, the app must transfer it to Altcraft MP in order to create a subscription. The API request is used for it.

With this request, you can:

  • Add new subscriptions.
  • Change the status of existing subscriptions.

The profile search mode can be set using the matching field in the request (see specification below). If the profile is not found, a new one will be created.

Moreover, if several databases are specified in the resource, then all of them will be processed separately. A request to such a resource will create and update profiles in several databases at once. An example of such a case can be seen below.
If there are no databases in the resource, then an error will be returned.

URL​

Method: POST

https://<cookiesaver_host>/push_subscribe

Request parameters​

ParameterTypeExampleRequiredDescription
idstring"abcdefghijklmnqrstuvwxyz"NoProfile ID
resource_tokenstring"abcdefghijklmnqrstuvwxyz"YesUnique resource ID.
db_ids[ ] int[ 2,3 ]NoResource database filter.
matchingstring"custom"NoProfile search mode.
If the parameter is not passed or is empty, profile search by ID will be used. If ID is also not passed, search by push subscriptions will be used.

For the push_subscribe method, this parameter can only accept the following values:
  • custom
  • profile_id
subscriptionsJSON array
SubscriptionObject
[{
"provider" : "android-firebase",
"subscription_id" : "%subscriptionid%"
}]
YesPush subscriptions that should be added to profile or should be updated.
"subscription_id" is unique for each device, Firebase provides it.

SubscriptionObject​

ParameterTypeExampleRequiredDescription
providerstring"android-firebase"YesAltcraft MP Provider ID.
The available values:
  • android-firebase
  • ios-firebase
  • ios-apns
  • yandex-Appmetrica-device-id-ios
  • yandex-Appmetrica-device-id-android
  • yandex-Appmetrica-ios-ifa
  • yandex-Appmetrica-google-aid
  • yandex-Appmetrica-android-token
  • yandex-Appmetrica-ios-token
  • android-huawei
  • ios-huawei

>Each token type in AppMetrica has its own provider ID.
subscription_idstring"abcdef-ghijklmn-qrstuvwxyz"YesSubscription push token
unsubscribeboolfalseNoUnsubscribe flag. Dismiss subscription if its value — true.

Response parameters​

ParameterTypeDescription
dataJSON array
DataObject
Information about the created subscriptions.

The array can contain several objects in the following cases:
  • Several SubscriptionObject were passed in the request.
  • ID field was not used in the request, and the Altcraft MP resource uses several databases. In this case, a new profile with subscriptions will be added for each database from the resource.
errorintError code
error_textstringError text

DataObject​

ParameterTypeDescription
subscription_idstring"abcdef-ghijklmn-qrstuvwxyz"Subscription push token
unsubscribeboolfalseFlag whether the subscription was added or canceled
profile_idstring"5fb62e815ae47a4aa04dfadd"ID of the profile (transferred or newly created) for which the subscription was added.
providerstring"android-firebase"Altcraft MP Provider ID.
The available values:
  • android-firebase
  • ios-firebase
  • ios-apns
  • yandex-Appmetrica-device-id-ios
  • yandex-Appmetrica-device-id-android
  • yandex-Appmetrica-ios-ifa
  • yandex-Appmetrica-google-aid
  • yandex-Appmetrica-android-token
  • yandex-Appmetrica-ios-token
  • android-huawei
  • ios-huawei

Each token type in AppMetrica has its own provider ID.
db_idint2Altcraft MP Database ID. The profile is stored in this database.
resource_idint1Altcraft MP resource ID.
subscription_hash_idstring"92807e89"Subscription hash
statusstring"error"Operation status
  • ok
  • error
descriptionstring"Duplicate push subscription"Error description

Examples​

Request with matching by system profile ID​

  • Request
  • Response
{
"id": "59db33d269d426509e9c4bf9",
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"data": [
{
"subscription_id": "%subscriptionid%",
"unsubscribe": false,
"profile_id": "59db33d269d426509e9c4bf9",
"provider": "android-firebase",
"db_id": 17,
"resource_id": 5,
"subscription_hash_id": "adsfdfdffdf",
"status": "ok",
"description": ""
}
],
"error": 0,
"error_text": "Successful operation"
}

Request with matching by a custom profile field​

  • Request
  • Response
{
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"matching": "custom",
"field_name": "CustomNumber1",
"field_value": 123,
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"data": [
{
"subscription_id": "%subscriptionid%",
"unsubscribe": false,
"profile_id": "59db33d269d426509e9c4bfс",
"provider": "android-firebase",
"db_id": 17,
"resource_id": 5,
"subscription_hash_id": "adsfdfdffdf",
"status": "ok",
"description": ""
}
],
"error": 0,
"error_text": "Successful operation"
}

Request with matching by push subscriptions​

  • Request
  • Response
{
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"data": [
{
"subscription_id": "%subscriptionid%",
"unsubscribe": false,
"profile_id": "59db33d269d426509e9c4bfa",
"provider": "android-firebase",
"db_id": 17,
"resource_id": 5,
"subscription_hash_id": "adsfdfdffdf",
"status": "ok",
"description": ""
}
],
"error": 0,
"error_text": "Successful operation"
}

Request to a resource with several databases​

  • Request
  • Response
{
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"matching": "custom",
"field_name": "CustomNumber1",
"field_value": 12345,
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"error": 200,
"error_text": "Successful operation",
"data": [
{
"db_id": 34,
"description": "",
"profile_id": "6156ed18eb7fec10a206e916",
"provider": "android-firebase",
"resource_id": 22,
"status": "ok",
"subscription_hash_id": "340ca49c",
"subscription_id": "%subscriptionid%",
"unsubscribe": false
},
{
"db_id": 2,
"description": "matching error: unknown field",
"resource_id": 22,
"status": "error"
}
]
}

Request with matching by a custom profile field in a certain database​

  • Request
  • Response
{
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"db_ids": [1],
"matching": "custom",
"field_name": "CustomNumber1",
"field_value": 123,
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"error": 0,
"error_text": "Successful operation",
"data": [
{
"db_id": 1,
"description": "",
"profile_id": "637f1a284fda7c5c08be62f",
"provider": "android-firebase",
"resource_id": 31,
"status": "ok",
"subscription_hash_id": "f8af057de",
"subscription_id": "%subscriptionid%",
"unsubscribe": false
}
]
}

Request did not update or add any profile subscriptions​

  • Request
  • Response
{
"resource_token": "3LXP2FRcRxJ-7b14db88ec937f14",
"matching": "custom",
"field_name": "CustomNumber1",
"field_value": 12345,
"subscriptions": [
{
"provider": "android-firebase",
"subscription_id": "%subscriptionid%"
}
]
}
{
"error": 200,
"error_text": "Successful operation",
"data": [
{
"db_id": 34,
"description": "",
"profile_id": "6156ed18eb7fec10a206e916",
"resource_id": 22,
"status": "ok"
}
]
}
Last updated on Nov 5, 2024
Previous
Providers: push message structure
Next
Event registration
  • URL
  • Request parameters
    • SubscriptionObject
  • Response parameters
    • DataObject
  • Examples
    • Request with matching by system profile ID
    • Request with matching by a custom profile field
    • Request with matching by push subscriptions
    • Request to a resource with several databases
    • Request with matching by a custom profile field in a certain database
    • Request did not update or add any profile subscriptions
© 2015 - 2025 Altcraft, LLC. All rights reserved.