Skip to main content

Event Notifications

Event Notifications tell connected systems when something changes, such as a consent being revoked or a user account being deleted. Subscribers receive each event at a webhook listener or by polling for it.

This guide continues the CarePulse (Data Fiduciary) story and walks you through two flows:

They use three building blocks:

  • Topic: the kind of change you want to hear about, such as consent.revoke. The accelerator ships system topics for consent and user lifecycle changes.
  • Subscription: a processor signing up for a topic. Each event reaches the processor either at its webhook listener or when it polls for it.
  • Event and delivery history: a record of every event published and every attempt to deliver it, which you can look through in the Consent Portal.

Here are the system topics and what triggers each one:

System topicTriggered when
consent.updateA consent is updated, or an authorizer approves or rejects it
consent.revokeA consent is revoked
consent.expireThe expiry reconciler records a consent as expired
user.data.changeA user's profile claims are updated
user.account.deleteA user account is deleted

For the complete list of endpoints and schemas, see the Event Notification API specification.

Before you begin​

  • Ensure WSO2 Identity Server with the DPDP Accelerator is installed and running.

  • Create these users and assign their roles, as described in Configuring Users and Roles:

    • Priya (Data Principal), username priya@example.com: dpdp-consent-user
    • Anika (Data Fiduciary Administrator): dpdp-consent-admin
  • Create an application for each system below and authorize it for the listed APIs and scopes:

    ApplicationRole in this guideAPIs and scopes
    CarePulseData Fiduciary: creates the test consent and publishes the custom eventConsent Management V2 – Consents (internal_consent_mgt_consent_create), DPDP Event Notification API subscriptions (notifications:subscriptions:write), DPDP Event Notification API events (notifications:events:write)
    CloudEngageData Processor: reports completion of a webhook deliveryDPDP Event Notification API deliveries (notifications:event-deliveries:complete)
    MedExpressData Processor: polls for and acknowledges eventsDPDP Event Notification API poll (notifications:events:poll)

    Giving each application only the scopes it needs keeps the publisher and the receivers separate.

Before running the API examples, set the base URL, the group ID, and the CarePulse application's access token. Obtain a client-credentials token using the CarePulse application's credentials, with the scopes listed above. Each step that needs the CloudEngage or MedExpress token says so.

export BASE_URL="https://localhost:9443"
export API_BASE="${BASE_URL}/api/dpdp/event-notifications/v1"
export GROUP_ID="carbon.super"
export ACCESS_TOKEN="<carepulse-client-credentials-token>"

These values are for the super tenant. For a specific tenant, use https://localhost:9443/t/<tenant-domain> as the base URL and the tenant domain as the group ID, and get every token from that same tenant.

Local testing with a self-signed certificate

Add -k to the curl commands if your local Identity Server uses the default self-signed certificate. On Windows, add -SkipCertificateCheck to Invoke-RestMethod; this needs PowerShell 7 or later, so with Windows PowerShell 5.1, trust the server's certificate instead. Never skip certificate checks in production — configure a trusted CA certificate, or pass it with --cacert.

When a Data Principal revokes their consent, every Data Processor holding their data has to stop using it. In this flow:

  • Priya (Data Principal) revokes a consent in My Consents.
  • Anika (Data Fiduciary Administrator) registers the subscription under Event Notifications → Subscriptions and checks the delivery under Events.
  • CloudEngage (Data Processor) receives the consent.revoke event at its webhook listener, which runs outside the portal.

Step 1: Start the webhook listener​

A webhook listener receives the subscription verification and each event delivery from Identity Server. Its API contract is in webhook-listener.openapi.yaml. For this try-out, use one of the sample listeners below.

Each sample listener is a single file, with nothing to install. It answers the verification challenge, checks every delivery's signature with the shared secret, and prints whatever it receives.

Node.js (webhook-listener.mjs) needs Node.js 18 or later:

node --version

curl -O https://raw.githubusercontent.com/wso2/dpdp-accelerator/main/docs/static/examples/webhook-listener.mjs

export SHARED_SECRET="carepulse-sample-secret-9d3e7b12"
node webhook-listener.mjs

Python (webhook-listener.py) needs Python 3.9 or later:

python3 --version

curl -O https://raw.githubusercontent.com/wso2/dpdp-accelerator/main/docs/static/examples/webhook-listener.py

export SHARED_SECRET="carepulse-sample-secret-9d3e7b12"
python3 webhook-listener.py

Once it's running, the listener prints its local address and confirms that HMAC signature checks are enabled:

=============================================================
DPDP Reference Webhook Listener (Node.js)
Listening on: http://127.0.0.1:8443/dpdp/events
HMAC Verification: ENABLED (shared secret configured)
Press Ctrl+C to stop.
=============================================================

The address shown in the terminal is local to your machine. Identity Server must be able to reach the listener, so the subscription needs a callback URL it can reach. For local testing, see Exposing a listener locally below. Make sure to use a strong shared secret in a production environment.

Understand the two signature checks

Event contents are signed, not encrypted. HTTPS protects the contents in transit. Two separate signatures have different purposes:

  • Event JWT signature: Identity Server signs the event JWT with its tenant private key. A receiver should verify the JWT signature using the matching public key published through Identity Server's JWKS endpoint. This verifies the event's authenticity and integrity.
  • Delivery HMAC (event-signature): webhook deliveries also carry an HMAC of the request body, calculated with the subscription's shared secret. The sample listener checks this HMAC, so someone who finds your callback URL can't send it fake events.

The shared secret is also used for the signed event's payloadHash, and to sign poll requests and completion reports. These checks don't encrypt event data or replace validating the event JWT signature. Avoid putting unnecessary personal data in payloads; use references, such as a consent ID, wherever possible.

Exposing a listener locally

No public server to run the listener on? Try one of these:

  • An ngrok tunnel. Set up ngrok, run ngrok http 8443 in a second terminal, then add /dpdp/events to the https:// forwarding address it prints. That's your callback URL for Step 3. Your test events travel through ngrok, so stick to sample data, and don't use a tunnel for a real receiver.
  • Your machine's network IP, if Identity Server can't reach the internet. Start the listener with HOST set to that IP, and use http://<ip>:8443/dpdp/events as the callback URL. Identity Server turns away private network addresses by default, so also set allow_private_network_callback_targets = true under [dpdp_accelerator.event_notifications.webhook] in deployment.toml and restart it. If you've set allow_http_callback_url = false in the same section, set it back to true for this test, because the callback uses HTTP. Keep allow_private_network_callback_targets set to false in production.

The portal can't create consents, so CarePulse creates one through the API, and Priya revokes it in the portal in Step 4.

  1. Get a purpose ID and an element ID. Sign in to the Consent Portal as Anika, go to Definitions → Purposes, and open the marketing-email purpose. No purpose yet? Create one with an element first, as described in Define a purpose and its data element. Copy the Purpose ID from the purpose page, then open one of its elements and copy its ID as well.

    Purpose details page with the Purpose ID and its Contact email element

  2. Create an active consent for Priya with the CarePulse token you set earlier. The token needs the internal_consent_mgt_consent_create scope. subjectId must belong to a user in the same tenant. On the highlighted line, swap in the <purpose-id> and <element-id> you copied:

    curl -X POST "${BASE_URL}/api/identity/consent-mgt/v2.0/consents" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "Content-Type: application/json" \
    -d '{
    "subjectId": "priya@example.com",
    "serviceId": "CarePulse-client",
    "language": "en",
    "purposes": [
    { "id": "<purpose-id>", "elements": [ { "id": "<element-id>" } ] }
    ]
    }'

    There are no other authorizers, so the consent is ACTIVE straight away. The response includes its id; use your own ID rather than the example IDs shown later.

  1. Sign in to the Consent Portal as Anika.
  2. Open Event Notifications → Subscriptions and select Register Subscription.
  3. Enter a Subscription Name, such as CloudEngage - consent revocations.
  4. Set Topic Category to Consent Topics, and select consent.revoke under Topics.
  5. Set Consent Purpose Filter Mode to Specific Purposes, and select marketing-email under Consent Purposes. The listener then hears only about revocations of consents that include this purpose. To hear about every revocation, choose All Purposes instead.
  6. Set Delivery Mode to Webhook, enter your callback URL from Step 1 as the Webhook Callback URL (for example, https://<your-ngrok-address>/dpdp/events), and enter carepulse-sample-secret-9d3e7b12 as the Shared Secret.
  7. Select Register Subscription.

Register Subscription dialog filled in for consent.revoke with the marketing-email purpose

Right away, Identity Server sends the listener a verification challenge. As soon as the listener answers it, the subscription turns Active:

Subscriptions list with the new consent.revoke subscription in Active status

Over in the listener's terminal, you'll see the challenge it answered:

[INFO] ================ [SUBSCRIPTION VERIFICATION] ================
[INFO] Verification Payload:
{
"type": "subscription.verification",
"subscriptionId": "e4e10144-e76a-4d4b-9e80-70747df4f650",
"topics": [
"consent.revoke"
],
"challenge": "ec09e7a8-fb5b-4eec-9670-c3c1fbe529b9"
}
[INFO] Verified subscription 'e4e10144-e76a-4d4b-9e80-70747df4f650' for topics: ["consent.revoke"]
[INFO] <-- Returned HTTP 200 OK with challenge: 'ec09e7a8-fb5b-4eec-9670-c3c1fbe529b9'

Using the REST API (optional)​

To register the subscription through the API instead, use the CarePulse token. It must include the notifications:subscriptions:write scope.

curl -X POST "${API_BASE}/subscriptions" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "CloudEngage - consent revocations",
"topics": ["consent.revoke"],
"filter": {
"type": "specific",
"purposes": ["marketing-email"]
},
"delivery": {
"mode": "webhook",
"callbackUrl": "https://<your-ngrok-address>/dpdp/events",
"sharedSecret": "carepulse-sample-secret-9d3e7b12"
}
}'

The subscription name must be unique in the tenant, so use a different name if you already registered one in the portal.

  1. Sign in to the Consent Portal as Priya.

  2. Open My Consents and select the consent you created. It should show Active.

    Consent details page for an active marketing-email consent with the Revoke button

  3. Select Revoke, then Revoke Consent to confirm.

    Confirm Revocation dialog

The consent now shows Revoked. An application can also revoke a consent on Priya's behalf, using her own user token (not the CarePulse token), through POST /api/users/v1/me/consents/<consent-id>/revoke.

Step 5: Confirm that the processor was notified​

Within a few seconds, the event reaches the listener. The sample checks the delivery HMAC and prints the decoded event, including the consent ID Priya just revoked:

[INFO] ==================== [EVENT DELIVERY] ====================
[INFO] Delivery-Id: 58328a80-4e74-44c8-80cc-927414e4159a
[INFO] Event-Signature: sha256=e8c0443706bca2452875971e20bdc909867a12298bbd99907d36edcbf4092245
[INFO] HMAC-SHA256 signature verified successfully.
[INFO] Decoded Event Payload:
{
"iss": "https://localhost:9443/oauth2/token",
"sub": "carbon.super",
"aud": "dpdp-event-notifications",
...
"payload": {
"deliveryId": "58328a80-4e74-44c8-80cc-927414e4159a",
"eventId": "131b9ab4-c6f2-4652-ae70-023dafc35c8f",
"subscriptionId": "e4e10144-e76a-4d4b-9e80-70747df4f650",
"orgId": "carbon.super",
"groupId": "carbon.super",
"topic": "consent.revoke",
"eventPayload": {
"consentId": "c540bcee-c9d8-4919-8fdc-e2b9723971f5",
"previousStatus": "ACTIVE"
}
}
}
[INFO] <-- Returned HTTP 202 Accepted

You can find the same event in the portal too. As Anika, open Event Notifications → Events, and search for the eventId from the listener output, or look for the newest consent.revoke event:

Events list showing the consent.revoke event for the marketing-email purpose with one subscriber

Open it to see the payload and the delivery to your subscription, marked Delivered:

Event details page with the consent.revoke payload and a Delivered webhook delivery

Notice that the event carries only the consent ID and its previous status, none of Priya's personal data. A real processor would use consentId to find the data it holds under that consent and stop using it.

Expected result: revoking the consent publishes a consent.revoke event, and CloudEngage's listener receives it because the subscription matches both the topic and the marketing-email purpose. Delivered means the listener accepted the notification; CloudEngage is still responsible for acting on it. For more on this, see receiver responsibilities.

Step 6: Report completion (optional)​

You can stop after Step 5 if you only want to verify webhook delivery. Continue here to see how a processor reports that it has acted on an event.

A 2xx response from the listener confirms receipt, not completion. After CloudEngage has updated Priya's marketing preferences, it can submit a signed completion report, so the accelerator records that confirmation alongside the delivery.

Obtain a client-credentials token using the CloudEngage application's credentials, with the notifications:event-deliveries:complete scope. Use the deliveryId from your Step 5 listener output, and the same shared secret you used for the subscription.

The signature is an HMAC-SHA256, made with the shared secret, over v1, completion, the delivery ID, and the exact request body, each on its own line. This binds the report to one delivery. completionEvidence must be an HTTPS URL.

export CLOUDENGAGE_TOKEN="<cloudengage-access-token>"
export SHARED_SECRET="carepulse-sample-secret-9d3e7b12"
DELIVERY_ID="<delivery-id-from-step-5>"
COMPLETION_BODY='{"completionStatus":"completed","completionEvidence":"https://cloudengage.example/evidence/receipt.pdf"}'
COMPLETION_SIGNATURE="sha256=$(printf 'v1\ncompletion\n%s\n%s' "${DELIVERY_ID}" "${COMPLETION_BODY}" \
| openssl dgst -sha256 -hmac "${SHARED_SECRET}" | awk '{print $NF}')"

curl -X POST "${API_BASE}/deliveries/${DELIVERY_ID}/completion" \
-H "Authorization: Bearer ${CLOUDENGAGE_TOKEN}" \
-H "group-id: ${GROUP_ID}" \
-H "event-signature: ${COMPLETION_SIGNATURE}" \
-H "Content-Type: application/json" \
-d "${COMPLETION_BODY}"

A successful call returns 204 No Content. Reopen the event in Event Notifications → Events: the delivery still shows Delivered, now with Completion Evidence recorded alongside it. Submitting a second completion for the same delivery returns 409 Conflict (EN-4090). For the other completion statuses and error responses, see Submit webhook delivery completion.

Publish your own event and poll for it​

The accelerator publishes consent and user lifecycle events on its own. Your applications can publish events too, about their own business changes, on topics you define.

Say CarePulse's order system publishes an event whenever a customer updates their delivery preferences. MedExpress, the delivery processor (Data Processor), sits behind a firewall and can't expose a webhook. Instead, it polls for new events and acknowledges each one once it has processed it. In this flow:

  • Anika (Data Fiduciary Administrator) registers the custom topic and the poll subscription in the Consent Portal, and checks the result.
  • CarePulse publishes the event through the REST API, using its own token.
  • MedExpress polls for the event and acknowledges it through the REST API, using its own token.

Obtain a client-credentials token using the MedExpress application's credentials, with the notifications:events:poll scope:

export MEDEXPRESS_TOKEN="<medexpress-access-token>"

Step 1: Register a custom topic​

  1. Sign in to the Consent Portal as Anika.
  2. Open Event Notifications → Topics and select Register Topic.
  3. Enter delivery.preferences.update as the Topic Name, add a Description, and select Register Topic.

Register Topic dialog for delivery.preferences.update

Step 2: Subscribe a poll receiver​

  1. Open Event Notifications → Subscriptions and select Register Subscription.
  2. Enter a Subscription Name, such as MedExpress - delivery preferences.
  3. Set Topic Category to Custom Topics, and select delivery.preferences.update under Topics.
  4. Keep Consent Purpose Filter Mode as All Purposes.
  5. Set Delivery Mode to Poll.
  6. Enter medexpress-sample-secret-4f8a2c91 as the Shared Secret. MedExpress signs its poll requests with it. We use a sample value so the commands below work as they are. For a real receiver, select the generate icon at the end of the field instead, and keep the secret somewhere safe.
  7. Select Register Subscription.

Register Subscription dialog for a poll subscription with the sample shared secret

Poll subscriptions don't need verification, so this one is Active straight away. Copy its Subscription ID with the copy icon in the list:

Subscriptions list with the active poll subscription

export SUBSCRIPTION_ID="<subscription-id>"
export SHARED_SECRET="medexpress-sample-secret-4f8a2c91"

Step 3: Publish an event​

Now play CarePulse's order system and publish the change with the CarePulse token. It must include the notifications:events:write scope. The group-id header has to match the subscription's group, which is the tenant domain (carbon.super for the super tenant). An event with any other group ID is stored, but reaches no subscriber.

curl -X POST "${API_BASE}/events" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "group-id: ${GROUP_ID}" \
-H "Content-Type: application/json" \
-d '{
"topic": "delivery.preferences.update",
"payload": {
"customerReference": "cust-0001",
"change": "DELIVERY_WINDOW_UPDATED"
}
}'

You'll get back the stored event and its eventId:

{
"eventId": "f0b66a0d-edcb-4d94-94ee-70ce33b34f20",
"orgId": "carbon.super",
"groupId": "carbon.super",
"topicId": "3064830b-7249-4fa6-9b83-59d7215af1c2",
"payload": "{\"customerReference\":\"cust-0001\",\"change\":\"DELIVERY_WINDOW_UPDATED\"}",
"occurredAt": 1791199075832,
"createdAt": 1791199075832
}

Try to keep personal data out of the payload. Send a reference the receiver can look up instead, the way customerReference does here.

Step 4: Poll for the event​

Next, switch to MedExpress and poll with the MedExpress token. The first poll can have an empty body:

POLL_BODY=''
POLL_SIGNATURE="sha256=$(printf %s "${POLL_BODY}" | openssl dgst -sha256 -hmac "${SHARED_SECRET}" | awk '{print $NF}')"

curl -X POST "${API_BASE}/events/poll" \
-H "Authorization: Bearer ${MEDEXPRESS_TOKEN}" \
-H "Content-Type: application/json" \
-H "group-id: ${GROUP_ID}" \
-H "subscription-id: ${SUBSCRIPTION_ID}" \
-H "event-signature: ${POLL_SIGNATURE}" \
-d "${POLL_BODY}"

event-signature is an HMAC-SHA256 of the exact request body, made with the subscription's shared secret. For an empty body, it's calculated over zero bytes. The server only checks it when request_hmac_validation_enabled = true under [dpdp_accelerator.event_notifications.polling], and that's off by default. Sign every request anyway, so your receiver keeps working when someone turns the check on.

The response holds pending deliveries in the sets object. Each key is a delivery ID, and its value is a signed event (a compact JWS) carrying the same contents as a webhook delivery. Save the delivery ID, because you'll need it in Step 5 to acknowledge the event:

{
"moreAvailable": false,
"sets": {
"07f813ee-391a-4cd2-aa70-2ebe420fc0d0": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIs..."
}
}

Before you trust an event, verify its signature against Identity Server's JWKS endpoint. Once it checks out, you'll find your event in the payload claim, under eventPayload:

"eventPayload": {
"change": "DELIVERY_WINDOW_UPDATED",
"customerReference": "cust-0001"
}

Step 5: Acknowledge the event​

Once MedExpress has processed the event, it sends the delivery ID back in the next poll's ack array, signing the new body the same way:

DELIVERY_ID="<delivery-id-from-step-4>"
POLL_BODY="{\"ack\": [\"${DELIVERY_ID}\"], \"maxEvents\": 20}"
POLL_SIGNATURE="sha256=$(printf %s "${POLL_BODY}" | openssl dgst -sha256 -hmac "${SHARED_SECRET}" | awk '{print $NF}')"

curl -X POST "${API_BASE}/events/poll" \
-H "Authorization: Bearer ${MEDEXPRESS_TOKEN}" \
-H "Content-Type: application/json" \
-H "group-id: ${GROUP_ID}" \
-H "subscription-id: ${SUBSCRIPTION_ID}" \
-H "event-signature: ${POLL_SIGNATURE}" \
-d "${POLL_BODY}"

An acknowledged event isn't returned again, so with nothing else pending, the response comes back empty:

{"moreAvailable":false,"sets":{}}

If the receiver couldn't process an event, report it in setErrs instead of ack. A delivery ID goes in one or the other, never both.

Step 6: Check the result in the portal​

Back in the Consent Portal as Anika, open Event Notifications → Events and find the delivery.preferences.update event. Its delivery to the poll subscription now shows Acknowledged:

Event details page with the custom event payload and an Acknowledged poll delivery

When you're done, tidy up by deleting the subscription and deregistering the topic in the portal.

Expected result: the published event is queued for the poll subscription, MedExpress picks it up on its first poll, and once it's acknowledged it no longer shows up in later polls. For the full request options, errors, and HMAC settings, see Register a poll subscription and Poll event deliveries.

Next Steps​