Use incoming webhooks to get real-time updates
To start activating your webhooks events, users can follow these next steps:
After that, can click on Add webhook endpoint in order to create a new webhook subscription.
Creating a webhook endpoint is no different from creating any other page on your website. It’s an HTTP or HTTPS endpoint on your server with a URL.
Set up an HTTP endpoint on your local machine that can accept unauthenticated webhook requests with a POST method. For example, this route in Flask is a map to a Python webhook function:
ethereum_mainnet_payload = request.json
In this example, the /bloock_ethereum_mainnet route is configured to accept only POST requests and expects data to be delivered in a JSON payload.
The following information must be provided:
- Event Listening: You must select the type of network you want to listen to. For example, if I subscribe to core.ethereum_mainnet webhook, every time a new anchor is confirmed on this network, will fire an event. It's important to differentiate between the core and core-test prefix. The first indicates we are listening a production environment event and the second reference to a test environment event.
Once all the information required is filed in, click on Create button.
It is important that you know the request's structure that we send to your API endpoint. Each event is structured with a webhoook_id, request_id, type, created_at and related Bloock resource nested under data. Your endpoint must parse the payload of each event.
- Header: data (timestamp) and signature (HMAC SHA256).
Your endpoint must quickly return a successful status code (2xx) prior to any complex logic that could cause a timeout. Use webhook signatures to verify that Bloock generated a webhook request and that it didn’t come from a server acting like Bloock.
Once your webhook is created, you should see it in your webhook list. You will see your webhook's details, including: the URL, the event that you’re listening, and its status (either Active or Disabled).
Note: It is important to understand how our system manages events failures. When a webhook is created, its default status is Active. However, this status can be changed to Disabled if we detect a persistent system failure. This happens if a series of failed responses are registered when we communicate with the API endpoint provided from your side.
To check for your webhook information, click the See details button.
In this section, you’ll see the URL, Status and the Signing Secret. The Signing Secret is what will help you validate the HMAC SHA256 signature which is used to verify all the webhook requests provided from BLOOCK.
Every time we send you a new webhook event, Bloock provides you with a webhook attempts logger. With this function, you can check the webhook’s response.
At the top of the logger, you’ll find a Combobox filter where you can check all your webhook responses according to their status: Success or Error.
In detail, for each webhook, you will be provided with:
- Request ID
- Status: the status code response from your API endpoint listener.
- Time: the time when we send the request to your API endpoint.
- Result: the method request (GET, POST ...)
- Endpoint: the API endpoint URL provided when the webhook was created.
- Request body: the request body we send.
- Response body: the response from your body.
To delete or unsubscribe from a webhook event, go back to your webhook list, and choose the Delete button.
Finally, click the Delete button on the popup and the webhook will be erased.