Skip to main content

Configure and Use Webhooks

Learn how webhooks work, how to configure them, and how to safely consume webhook notifications from Donorfy.

Cristina Gruita avatar
Written by Cristina Gruita
Updated over a month ago

⚠️ Important:
Webhooks are intended for advanced use cases. You may need development skills or support from a Donorfy partner to implement them correctly.

Understand What Webhooks Do

Webhooks allow Donorfy to notify another system when data changes.

  1. Send notifications when data is added, changed, or deleted in Donorfy.

  2. Allow a receiving system to react by calling the Donorfy API for more details.

πŸ“Œ Note:
The receiving system must be capable of listening for HTTP POST requests and handling the payload securely.


Set Up a Webhook

You can configure webhooks directly in Donorfy.

  1. Go to Settings, then click Configuration, then click Webhooks.

  2. Click Add Webhook.

  3. Enter a descriptive name to identify the webhook.

  4. Enter the URL where the receiving system listens for notifications.

  5. Choose whether operations from selected API permissions should be ignored.

  6. Select which events should trigger notifications.

  7. Click Save Changes.

The webhook will then appear in the Existing Webhooks list.


Avoid API Update Loops

Webhooks often work alongside API permissions.

⚠️ Important:
If a webhook reacts to API updates and then calls the API again, this can cause an infinite loop.

To prevent this:

  1. Identify the API permission used by your integration.

  2. Configure the webhook to ignore operations from that API permission.

This prevents Donorfy from sending webhook notifications for changes made by the same API.


Use the Webhook Private Key

Each webhook has a unique private key.

  1. Use the private key to validate incoming webhook messages.

  2. Generate a hashed message authentication code (HMAC) to confirm the message came from Donorfy.


You can regenerate or delete webhooks and private keys at any time if required.


Understand the Webhook Payload

Webhook notifications are sent as HTTP POST requests.

πŸ“Œ Note:
There may be a short delay, typically around one minute, between a change in Donorfy and the webhook being sent.

Each notification includes:

  • MessageId: A unique identifier for the message.

  • MessageType: The event that triggered the notification.

  • RelatedId: The ID of the related entity in Donorfy.

  • MessageToken: An HMAC signature using SHA-256.

  • Data: Optional key-value pairs with additional information.


Validate Webhook Messages

To confirm a webhook message is valid:

  1. Recalculate the HMAC using the MessageId, MessageType, RelatedId, and the webhook Private Key.

  2. Compare your calculated value with the MessageToken received.

  3. You can recalculate the message token and compare it with the value in the message to check the message is valid. For testing an online HMAC tester can be found here

If the values match, the message is authentic.


Recognise Supported Message Types

Message types follow a consistent naming pattern.

  1. The noun represents the entity:

    • Constituent

    • Transaction

    • Activity

    • RecurringPaymentInstruction

    • GiftAid

  2. The verb represents the action:

    • Add

    • Change

    • Delete

For constituents, an additional verb is supported:

  • Merged, sent when two constituents are merged.

πŸ“Œ Note:
For a ConstituentMerged message, use the MergeTarget API endpoint to identify the surviving constituent.


Test Webhooks Safely

You can test webhook behaviour using a temporary listener.

  1. Create a test listener using a webhook testing tool.(e.g. using Beeceptor or Webhook Tester)

  2. Configure your Donorfy webhook to send notifications to the test URL.

  3. Perform actions in Donorfy and inspect the received payloads.

This allows you to validate structure and authentication before using a live system.

⚠️Important:
The Donorfy API is a Professional-only feature. Essential subscribers, please contact us to find out more about upgrading.

Did this answer your question?