What are Webhooks and how do they work?
Webhooks are a real-time HTTP POST requests sent to the endpoints you provide. In this way, your servers can be informed by Cleeng about events and be notified with new transactions, payment notifications, and more. These are notifications that Cleeng sends to subscribed broadcasters about specific events on their platforms.
The events are sent in the form of a POST request to specified endpoints with a JSON payload as the body. Whenever this trigger event occurs in the source page, it is immediately recognized by the webhook, collects the data and sends it to the URL specified as an HTTP request.
The body of the request consists of the following constant fields:
- broadcasterId – the ID of the broadcaster that the webhooks is sent for,
- topic – the name of the topic that the webhook is sent about,
- data – topic-specific payload about the event.
Once installed, the webhook will be triggered each time one or more subscribed events occurs.
Here’s a list of the requirements to use Webhooks:
When you create an account, you automatically receive a publisher token, which is very necessary to use the API. To find your API key, sign in to Cleeng and go to this link.
At Cleeng, we make sure that our broadcasters are able to use their test environments to avoid having to test their implementations on live environments when setting up an event, and to familiarize themselves with the dashboard before going live. We are proud to introduce our Cleeng Sandbox. To learn more, please visit our FAQ page.
An endpoint. You need to have a script available under a publicly acessible URL so that Cleeng can connect to it and send notifications.
Select your webhooks. The list of available webhooks is available here.
In order to give you a better overview on how webhooks work, here are a few examples:
As a broadcaster, you are definitely excited when a new customer arrives and make a purchase, or an existing customer pays for a next billing period of your subscription. If you want to know about it as soon as it happens, this is the Webhook event for you.
When a new customer purchases content from you, or registers using your embedded checkout, you get a
newCustomer notification to let you know that your user base has grown.
If you've already subscribed to that Webhook event, you can track your viewer's payment transactions. For example, if you want to get a notification whenever a payment authorization should occur for a customer, this is the event you want to subscribe to.
Whenever a payment capture attempt should be made for a customer, if you're subscribed to this webhook event we will let you know as soon as it happens.
If a customer failed to pay for their subscription, or they manually cancelled it, this notification is being sent when the termination of their subscription is about to happen.
For the full list of available Webhook events visit our documentation.
What happens when an endpoint is not available?
Cleeng will just retry to deliver the request.
How many times Cleeng tries to deliver the notification if an endpoint is not available??
As many as required.
How many endpoints are required in order to subscribe?
You can use as many endpoints you want but at least one is required to subscribe to a webhook topic.
How do I test it?
Make sure you have a Cleeng Sandbox account.
Do I need any authentication to receive webhooks?
Is this free of charge?
Yes, and it is available to all broadcasters.