PDX Notifications

Introduction 🔗︎ click to copy

Mydex has introduced PDX Notifications Services to the Personal Data eXchange (PDX) which enables subscribers to receive notifications when new records or updates to specific records within datasets contained within their Dedicated Connection are made by other subscribers or individuals themselves.

If your Dedicated Connection has PDX Notification Services enabled it will make use of the Callback URL you provided to send notifications.

Any time a PDS dataset that is part of the Dedicated Connection record changes for a member and has been enabled for PDX Notification Services you will receive a POST request to the Callback URL endpoint you specified for your Dedicated Connection.

Please note: This is the same Callback URL endpoint we use for First Time Connection (FTC) requests, which sends the initial payload when a member completes the FTC process. This means you will have to handle the PDX Notifications as a different scenario within your application.

How to use the PDX Notifications Service 🔗︎ click to copy

With PDX Notification Services enabled against your Callback URL endpoint you should add a condition within your code to handle the callback notification request distinct from the FTC response.

You should check the JSON payload contains the value 'type'. If 'type' exists within the payload then you should read the value. If the value says 'notification' then you can handle it accordingly - this could be stored in your application to be actioned later or the trigger for another action, such as reading the dataset record from the member's PDS.

The PDX Notification Service payload 🔗︎ click to copy

A typical notification will look like this:

{
  "type": "notification",
  "uid": "4020",
  "message": "Data for member 4020 has changed",
  "dataset": "ds_events",
  "connection_id": "4020-40000",
  "action": "create",
  "updated_id": "1"
}

You can now, for example, use this data to construct a request to see what has changed (assuming your connection has read permission). Construct a request to read data by using the updated ID. In this case it would look like this:

https://sbx-api.mydex.org/api/pds/transaction/345.json
   ?key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   &con_id=345-xxxxx
   &source_type=connection
   &instance=0
   &dataset=ds_events
   &filters[id][operator]=
   &filters[id][value]=1 // eg.the ID of the record that has changed

Distinguishing FTC payloads from Notifications 🔗︎ click to copy

When a FTC request comes in the ‘type’ attribute is not set. You MUST first check it is set before reading the value. If it is not set then you can treat this request as the initial FTC and handle it as per the guidance in our documentation here.