Skip to content

Notification preferences

Which notifications a user receives, and on which channels. These are per user, not per brand: one setting applies wherever you are.

GET /notification-preferences

json
{
  "types": {
    "comments_drafted": {
      "label": "Comment drafts ready",
      "description": "The comment scan drafted comments for you to review.",
      "channels": ["database", "mail"]
    }
  },
  "channels": { "database": "In app", "mail": "Email" },
  "preferences": { "comments_drafted": { "database": true, "mail": false } },
  "preferences_all": { "database": true, "mail": false }
}
FieldMeaning
typesEvery notification type, with the channels it supports
channelsChannel keys and their display labels
preferencesThe resolved setting per type and channel
preferences_allWhether a channel is on for everything

Notifications are opt out. A user with no stored preference receives everything, so a type missing from storage still resolves to true.

PUT /notification-preferences

Send the full preferences map.

bash
curl -X PUT https://api.postlyra.com/notification-preferences \
  -H "Authorization: Bearer $POSTLYRA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"preferences": {"comments_drafted": {"database": true, "mail": false}}}'

Returns the same shape as GET.

Unknown type or channel keys are silently dropped rather than stored, so a stale client cannot write junk. Read the response back if you need to confirm what was actually saved.

Device tokens

Push notifications need a device token registered.

bash
# Register
curl -X POST https://api.postlyra.com/device-tokens \
  -H "Authorization: Bearer $POSTLYRA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"token": "..."}'
# -> {"ok": true}

# Remove
curl -X DELETE https://api.postlyra.com/device-tokens \
  -H "Authorization: Bearer $POSTLYRA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"token": "..."}'
# -> 204, no body

Register on sign-in and on token refresh. Remove on sign-out, otherwise the device keeps receiving notifications for an account nobody is signed into.

Postlyra, by MAVA Design