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

SubscriptionCreateData description

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

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.

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