Subscribe a User to an Alert
You can subscribe a user to an alert through the API. This works the same way as subscribing from Notification Settings in the VMS client.
Note: After you subscribe a user through the API, they have to refresh the page or log in again before notifications show up in the VMS client.
Channels
Channel
channelType
url
In-app (push)
WSOC
"."
EMAIL
Recipient email address
Subscribe
Before you create a new subscription, check whether the user already has an unsubscribed one (see Resubscribe). If they do, reactivate it instead of creating a duplicate.
POST ws/rest/WebhookSubscription
In-app (WSOC)
{
"channelInfo": {
"channelType": "WSOC",
"httpRequestParams": [],
"url": "."
},
"dlpAlertScript": "KSS",
"expression": null,
"isScheduled": false,
"onlyMainObject": false,
"templateMsg": null,
"unsubscribed": false,
"user": { "key": 999999 },
"webhookTemplate": "KSS",
"accessToken": null
}user.key
User
Key of the user to subscribe
webhookTemplate
Webhook Alerts
The alert to subscribe to
dlpAlertScript
Alert Scripts
The alert script used by the alert
Note: The examples reference
webhookTemplateanddlpAlertScriptby code ("KSS"). You can also reference them by key, e.g."webhookTemplate": { "key": 123 }.
Find a subscription
Both unsubscribe and resubscribe need the subscription key. To find it, filter on channel, user and template:
GET ws/rest/WebhookSubscription?filter=channelInfo.channelType.channelTypeCode(EQ){channel}&filter=user.key(EQ){userKey}&filter=webhookTemplate.key(EQ){templateKey}&filter=unsubscriptionDate({NULL|NOTNULL})
unsubscriptionDate(NULL): active subscriptionsunsubscriptionDate(NOTNULL): unsubscribed subscriptions
Unsubscribe
Find the active subscription (unsubscriptionDate(NULL)), then update it:
PUT ws/rest/WebhookSubscription/{key}
Resubscribe
Find the unsubscribed subscription (unsubscriptionDate(NOTNULL)), then update it:
PUT ws/rest/WebhookSubscription/{key}
If no unsubscribed subscription exists, create a new one as described in Subscribe.
Last updated
Was this helpful?