Webhook

Webhook Management

Introduction

A webhook (also called a web callback or HTTP push API) is a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.
For using webhook service clients have to register an API application that will have an API key, api-admin credential, and an encryption file for further authentications. This is taken place for a successful webhook event subscription validation. For implementing the webhook service follow the given steps.
Available webhook event slugs and their provided data are listed at the end of the webhook document.

List Events

get
https://<domain>/<api prefix>/<version>/webhook/list/events/
List Provided Webhook Events

Sample Code

Node
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/webhook/list/events/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access-token>'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/list/events/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access-token>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Subscribe Event

post
https://<domain>/<api prefix>/<version>/webhook/subscribe/
Subscribe an event

Sample Code

Node
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/webhook/subscribe/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access_token>',
},
body: JSON.stringify({"events":["event_slug",..],"url":"<endpoit_url>"})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/subscribe/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>' {
"events": ["<event_slug>",...],
"url": "<endpoint_url>"
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access_token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Error Responses
Status Code
Error Type
Field
Description
400
Validation Error
events
This field is required.
This list may not be empty.
'<event-slug>' this webhook event is already subscribed for this API User.
400
Validation Error
url
This field is required.
This field may not be blank.
Enter a valid URL.
Protocol of recipient URL not allowed (('https://',) only).

Webhook Subscriber Validation

post
https://<domain>/<api prefix>/<version>/webhook/subscribe/validate/<uuid>/
Webhook Validation

Sample Code

Node
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/webhook/subscribe/validate/<uuid>/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access-token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/subscribe/validate/<uuid>/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access-token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Error Responses

Status Code
Error Type
Field
Description
400
Validation Error
uuid
This subscription is blocked due to maximum validation attempt (<maxattemptcount>), Please contact admin for unblocking your subscription.
This subscription is already verified.
404
Not Found
The requested resource not found.

Update Subscription

post
https://<domain>/<api prefix>/<version>/webhook/update/<uuid>/
Update a subscription

Sample Code

Node
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/webhook/update/<uuid>/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access_token>',
},
body: JSON.stringify({"events":["event_slug",..],"url":"<endpoit_url>","is_disabled":<boolean>})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/update/<uuid>/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>' {
"events": ["<event_slug>",...],
"url": "<endpoint_url>",
"is_disabled":<boolean>
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access_token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;p
Note:- Error Responses are the same as an event subscription.

Webhook Info

get
https://<domain>/<api prefix>/<version>/webhook/info/<uuid>/
Webhook Info

Sample Code

Node
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/webhook/info/<uuid>/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access-token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/info/<uuid>/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access-token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Unsubscribe Event

delete
https://<domain>/<api prefix>/<version>/webhook/unsubscribe/<uuid>/
Unsubscribe webhook event

Sample Code

Node
var request = require('request');
var options = {
'method': 'DELETE',
'url': 'https://<domain>/<api prefix>/<version>/webhook/unsubscribe/<uuid>/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/unsubscribe/<uuid>/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access-token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

List Subscriptions

get
https://<domain>/<api prefix>/<version>/webhook/list/
List event subscriptions

Sample Code

Node
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://<domain>/<api prefix>/<version>/webhook/list/',
'headers': {
'apikey': '<apikey>',
'Authorization': 'Bearer <access token>',
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/webhook/list/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>',
'Authorization: Bearer <access token>',
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Provided Webhook Events

These are available webhook events in the system and the data given by the event.
Event Name
Event Slug
Data (JSON)
User Registration
user-registration
{
'email': '<user_email_address>',
'sponsor': '<sponsor_user_name>',
'username': '<username>',
'is_active': <user_status>,
'last_name': '<last_name>',
'unique_id': '<unique_id>',
'user_role':
[
{
'name': '<user_role_name>'
}
],
'first_name': '<first_name>',
'phone_code': <phone_code>,
'phone_number': '<phone_number>'
}
Event Name
Event Slug
Data (JSON)
Order Creation
order-creation
if the order type is Commerce,
{
'uid': '<user_unique_id>',
'status': '<order_status>',
'products': [
{
'bv': <bv>,
'cv': <cv>,
'point': <points>
'total': <product_total_price>,
'quantity': <quantity>,
'product_name': '<product_name>',
'product_base_price': '<product_base_price>',
'product_id': '<product_id>'
},
...
],
'username': '<username>',
'last_name': '<last_name>',
'first_name': '<first_name>',
'order_type': '<order_type>',
'order_total': '<order_total>',
'currency_code': '<currency_code>',
'order_number': '<order_number>'
}
if the order type is Enrollment,
{
'bv': '<bv>',
'cv': '<cv>',
'uid': '<user_unique_id>',
'points': '<points>',
'status': '<order_status>',
'username': '<username>',
'last_name': '<last_name>',
'first_name': '<first_name>',
'order_type': 'ENROLLMENT',
'product_id': '<product_id>',
'amount_paid': '<amount_paid>',
'order_total': '<order_total>',
'product_name': '<product_name>',
'actual_amount': '<actual_amount>',
'currency_code': '<currency_code>',
'payment_status': '<payment_status>',
'product_base_price': '<product_base_price>',
'order_number': '<order_number>'
}
Event Name
Event Slug
Data (JSON)
Block User
block-user
[
{'unique_id': '<blocked_user_unique_id>'},
...
]
Event Name
Event Slug
Data (JSON)
Unblock User
unblock-user
[
{'unique_id': '<blocked_user_unique_id>'},
...
]
Event Name
Event Slug
Data (JSON)
Product Creation
product-creation
{
'bundle_id': '<bundle_id>'
}
Event Name
Event Slug
Data (JSON)
Product Update
product-update
{
'bundle_id': '<bundle_id>'
}
Event Name
Event Slug
Data (JSON)
Product Delete
product-delete
{
'bundle_id': '<bundle_id>'
}
Event Name
Event Slug
Data (JSON)
Profile Update
profile-update
{
'unique_id': '<unique_id>'
}
Last modified 1yr ago