Event

How to Enable Webhooks

A webhook event is an object that contains information about a specific action or event that occurs within the Bitpowr platform.

When an event occurs, Bitpowr sends an HTTP POST request to the webhook URL you specified, containing the event object as JSON in the request body.

To start receiving webhook events, you'll first need to specify your webhook URL from the Webhook page on your dashboard.

See the Setup section for more information on how to set up webhooks.

Receiving an Event

To receive a webhook event, you must create an unauthenticated POST endpoint on your application to receive the events.

For example, when an event occurs, we will send the event object as JSON in the request body of the POST request.

Below is an example of how to receive an event using JavaScript:

app.post("/your/webhook/url", function (req, res) {
  // Retrieve the request's body
  const event = req.body;
  // Process the event
  res.sendStatus(200);
});

📘

Webhook URL

You can specify your webhook URL from the Webhook Page on your dashboard where we would send POST requests whenever an event occurs.

A 200 OK should be used to respond to an event. This is considered an acknowledgment of your application. If your application returns a status other than 2xx, we will consider it unacknowledged and will continue to send it every hour for the next 72 hours. You don't need to provide a request body or any other parameters because they will be ignored - we only care about the status code.

Bitpowr may timeout waiting for a response if your application is likely to start a long-running task in response to the event, in which case the event will be considered unacknowledged and queued to be raised later. You can avoid duplication by having your application respond with a 200 right away before continuing with the rest of the task.

Testing Webhooks Locally

During development, you can set your webhook URL on your TEST environment to a local URL (e.g., http://localhost or 127.0.0.1).

To expose your local server to the internet for testing purposes, consider using a tool like ngrok. This allows you to simulate webhook events locally before deploying your application to a live environment.