Webhook
Receive real-time notifications when referrals occur
Implementing Referral Webhooks
Referral Webhooks provide a way for campaign owners to receive real-time notifications when new users are added to their referral program or when referrals occur. To integrate the Referral Webhook into your project, follow these steps:
Receive Webhook Notifications
Refir will send a POST request to the specified webhook URL when certain events occur, such as a new user being added or a successful referral. Your server should be prepared to receive these notifications.
Set Up an Endpoint to Receive Webhooks
Create an endpoint or route in your server application to handle incoming Referral Webhook notifications. The endpoint should listen for POST requests and be configured to handle JSON payloads.
Here's an example using Express.js:
Process Webhook Data
Inside the route handler for your webhook endpoint, you can access the data sent by Refir in the req.body
object. The data typically includes information about the new lead, referring user, and a message.
You should implement your custom logic to process this data according to your application's requirements. For example, you can reward the user, update your database to reflect the referral, send email notifications, or trigger other actions.
Respond to the Webhook Request
After processing the webhook data, always respond with an HTTP status code of 200
to acknowledge receipt of the webhook. This ensures that Refir knows the webhook was successfully received.
Configure Your Webhook URL
In your Refir dashboard or settings, you will have the option to specify the webhook URL where Refir should send notifications. Enter the URL of your webhook endpoint (e.g., https://yourwebsite.com/webhook
) in the provided field.
Test the Integration
To ensure that your webhook is working correctly, you can perform tests by adding users to your referral program and checking if your webhook endpoint receives and processes the notifications as expected.
Last updated