Configuring Webhooks

Objective

After completing this lesson, you will be able to configure Webhooks to enable notifications to specific events.

Configuring Webhooks

SAP Customer Data Cloud Webhooks

SAP Customer Data Cloud Webhooks offer a flexible way to extend SAP CDC's functionalities by sending notifications of specific events, including account, group, and organization events directly to your system.

With webhooks, you implement your code and set it to trigger when the relevant event is fired. You may configure the webhook to deliver notifications only for the specific event types you need, giving you precise control over what your system responds to.

When configuring a webhook, select the version you want to use. Note that newer versions may introduce webhook notifications for events you have not previously received, such as notifications for lite account interactions.

You can also use custom HTTP headers, made up of key-value pairs, to add additional details and context to each notification for example, an ID or flag consumed by an external system downstream.

Once active, notifications are sent in near real-time and are delivered at least once. To improve efficiency and bandwidth utilization, they may contain multiple events per notification, up to 100. Events are ordered per UID, meaning that for any given user account, events are always delivered in the order in which they occurred.

If your site belongs to a site group, notifications from any member site are automatically sent to all sites in the site group, including the parent site as long as each site is subscribed to the relevant event type.

Webhooks overview showing notifications, near real-time multievent notifications, version selection, custom HTTP headers, and member sites notifications.

Benefits of Using Webhooks

  • Real-time Updates: Receive notifications as events happen, ensuring your systems are always up-to-date.
  • Reduced Overhead: Eliminate the need for constant polling, reducing server load and bandwidth usage.
  • Improved Efficiency: Batching multiple events into a single notification optimizes bandwidth utilization.
  • Extensibility: Webhooks offer a flexible way to extend SAP CDC's functionalities by triggering custom code when relevant events occur.

To make the most of webhooks, you need to understand what events can trigger them and how to configure them for your business needs.

Webhook Events

SAP Customer Data Cloud webhooks are triggered by specific events in your site. Understanding these events helps you determine which notifications your system needs to receive. These are the current supported events.

The webhook events will be signed with a Json Web Token or JWT and support Global Access. This version can be verified with the accounts.getJWTPublicKey endpoint without having to exchange secrets with the webhook recipient. It adds the API key of the site that initiated the notification to the webhook payload, supporting site group scenarios where an event should be triggered only when a webhook was initiated from a specific site.

See the Supported Events page for a list of account, organization, and group-related events supported by Webhooks.

Diagram showing Event Types: Account Events (Account Created, Account Registered, Site Preferences Reset, Consent Updated), Organization Events (New Organization Request, Organization Entered Draft Stage, Organization is Active), and Group Events (Model Created, Model Updated, Group Created, Member Added).

Configuring Webhooks

Watch the following video that demonstrates webhook setup in SAP CDC using a retail loyalty program example. In this video, you configure a webhook in SAP CDC console to automatically enroll customers upon registration. You then demonstrate it working live by simulating a registration and verifying the webhook delivers the customer's UID in JSON format to the target system. The setup pattern shown is applicable to integrating SAP CDC with CRMs, marketing platforms, and data warehouses.

Common Pitfalls

Before you start implementing webhooks, be aware of these common pitfalls to ensure smooth integration:

  • Passing a new name with an existing URL will return an error. To rename a Webhook, first delete it, then create a new one.
  • Make sure you're using the proper SAP Customer Data Cloud data center associated with the site API key! (us1, au1, eu1, eu2 etc.)
  • Webhooks must be sent over HTTPS.

End-to-End WebHook Implementation: EndPoint Logic

When a subscribed event occurs in your site, SAP Customer Data Cloud delivers a notification to your system as an HTTPS POST request containing a list of events in the body. SAP CDC may include up to 100 multiple events in a single notification.

The HTTPS notification URL is an API endpoint in your system to which webhook notifications will be sent when the subscribed events are fired.

When updating the notification URL for an existing webhook, allow some time for the new URL to update and make sure it is updated in the system before removing the previously used URL.

The notification URL defined when configuring a webhook is a customer-hosted endpoint. SAP Customer Data Cloud's webhooks will send an HTTPS POST to said endpoint containing a payload similar to the image shown.

Side-by-side JSON samples of webhook payloads: one for accountCreated with IDs and accountType, and one for subscriptionUpdated with subscription details and status.

You may subscribe to multiple Notification URLs for any combination of events. This may be useful where you want notifications for the same event sent to multiple systems to be processed independently.

Once a WebHook calls the notification URL with an event, this URL endpoint needs to perform a few steps:

  1. To verify the authenticity of the Webhook notification message:
    • Retrieve the JWT from the request header X-Gigya-Sig-Hmac-Sha1.
    • Validate the JWT.
    • The subject ("sub") of the JWT is a Base64URL encoding of the hash of the Webhook event body. Decode the JWT subject from Base64URLto hex.
    • Apply SHA1 to the Webhook event body (raw content) and compare it to the decoded JWT subject.
  2. Send a Success response back to SAP Customer Data Cloud. SAP Customer Data Cloud considers notifications delivered if a 2xx Success HTTP status code is received (for example: 200OK, 201 Created, 202 Accepted). If SAP CDC receives anything other than a Success response from your system, it will resend the notification at increasing intervals up to one hour. If SAP CDC receives no response, it assumes your notification URL endpoint is offline.
  3. Read the request payload to retrieve the event type, API key and UID, etc.
  4. Perform a REST API call to accounts.getAccountInfo with the UID provided.
  5. Implement your custom business logic
Diagram showing the end-to-end webhook sample architecture flow: a user triggers an account event in SAP Customer Data Cloud, which sends a webhook notification to an endpoint. The endpoint validates the hash, registers the event in an events queue database, and returns a status 200. A logic layer then reads the event, performs a getAccountInfo call to SAP Customer Data Cloud, updates the third-party system, and optionally deletes the event from the queue.

Summary

  • Webhooks in SAP Customer Data Cloud enable real-time notifications for specific events, such as account updates and group changes.
  • Configuring webhooks involves setting up a notification URL and selecting the webhook version and event types to subscribe to.
  • Webhooks provide a flexible way to extend SAP CDC functionality by triggering custom code when relevant events occur, reducing the need for constant polling.