-
Notifications
You must be signed in to change notification settings - Fork 422
WebHooks
Goal: Have a way to notify clients when "something" happens.
- In-app notifications: I'm a client and I need to know when new data has been added to the collection
- Service integration: I'm a service and I want to know when new data has been added to the collection
In both cases, the client/service registers on the Kinto server.
If a recipient wants to be notified, it registers its webpush URL
on a /notifications/webpush
endpoint.
The /notifications
prefix is useful in order to have multiple
notification systems (webpush is one but there could be others i.e emails or webhooks).
This information expires after a duration defined on the server (1 day for webpush, never for webhooks).
webhooks and webpush notification can only be put on users, for anonymous user a basicauth random token can be used.
Depending its need, the client asks to be notified when some modification occurs. In order to do so, it can ask to be notified on different endpoints (buckets, collections, records) and for different operations ("read", "write")
The notification endpoint is global for a user and all her notification rules are available here.
GET /notifications/webpush
< Request <
> Response >
{
data: [{
"subscription": {"endpoint":"https://updates.push.services.mozilla.com/push/v1/gAAAAABXhkuIG...DnyV8iUiX3lVm","keys":{"auth":"by64sz1qJT...xl_g","p256dh":"BGRz...AX6EiUPuDefoC4"}}
"triggers": {
"/buckets/blocklists/collections/*/records": ["write"],
}
}]
}
POST /notifications/webpush
< Request <
{
"push": {"endpoint":"https://updates.push.services.mozilla.com/push/v1/gAAAAABXhkuIG...DnyV8iUiX3lVm","keys":{"auth":"by64sz1qJT...xl_g","p256dh":"BGRz...AX6EiUPuDefoC4"}}
"triggers": {
"/buckets/blocklists/collections/*/records": ["write"],
}
}
> Response >
{
data: {
"id": "a7546569-7583-4939-b9c9-71acb9321f82",
"last_modified": 1469023718589,
"push": {"endpoint":"https://updates.push.services.mozilla.com/push/v1/gAAAAABXhkuIG...DnyV8iUiX3lVm","keys":{"auth":"by64sz1qJT...xl_g","p256dh":"BGRz...AX6EiUPuDefoC4"}}
"triggers": {
"/buckets/blocklists/collections/*/records": ["write"],
}
}
}
DELETE /notifications/webpush/a7546569-7583-4939-b9c9-71acb9321f82
< Request <
> Response >
{
data: {
"deleted": true,
"id": "a7546569-7583-4939-b9c9-71acb9321f82",
"last_modified": 1469023786584
}
}
Join us on irc.freenode.net #kinto or on our Slack Workspace for more info.