Update subscriptions

Learn how to create and update subscriptions for your users

Description

This route facilitates the management of subscriptions, enabling users to create, update, and delete subscriptions effectively.

Users are allowed only one subscription per metric, ensuring simplicity and clarity in tracking metrics. When adjusting thresholds on existing subscriptions, the new parameters overwrite the previous settings, ensuring seamless customization.

Setting a threshold of 0 for a subscription promptly deletes it.

Endpoint

POST https://sentry.aleno.ai/subscriptions

Query parameters

No query parameters.

Payload

Name
Required
Type
Description

subscriptions

required

List of SubscriptionCreateData

List that contains data related to subscriptions you want to create. Data description can be found bellow

SubscriptionCreateData description

SubscriptionCreateData is an object that describes a subscription you want to create.

Name
Required
Type
Description

userId

required

string

The ID of the user for this subscription.

metricKey

required

string

The key of the metric for this subscription.

threshold

required

number

The value of the threshold for alert triggering. Threshold unit is % (threshold 50 means 50%) of variation of the metric on which on alert should be triggered.

Must be in range: 0 U [0.0001, 10000].

Using a threshold of 0 will dekete the subscription.

CURL example

curl -X POST \
  https://sentry.aleno.ai/subscriptions \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY' \
  -d '{
    "subscriptions": [
        {
            "userId": "3627716d-2b62-4cbd-802e-ed19d91400fe",
            "metricKey": "eth_token_total_tvl_0x3175df0976dfa876431c2e9ee6bc45b65d3473cc",
            "threshold": 0.3
        }
    ]
}'

Result

The result of this operation is an object that includes a list of Subscription objects, representing the updated subscriptions. Additionally, it provides the count of deleted subscriptions.

Name
Type
Description

upsertedSubscriptions

The list of subscrptions that have either been created or updated during the update.

numberDeletedSubscriptions

number

The number of subscriptions that have been deleted during the update

{
   "data":{
      "upsertedSubscriptions":[
         {
            "userId": "a2fbb127-3cdf-4871-9b8d-f73c7b260154",
            "metricKey": "eth_token_total_tvl_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "threshold": 0.0001,
            "startWindowTimestamp": "1715083130",
            "id": "97d0d9ed-02fe-457a-9f94-e1d0b1aebf28",
            "createdAt": "2024-05-07T11:58:51.630Z",
            "updatedAt": "2024-05-07T11:58:51.630Z"
         }
      ],
      "numberDeletedSubscriptions":0
   }
}

Last updated