Skip to main content

Create Webhook

To create a webhook with the bStamp API, utilize the createWebhook method from the SDK.


Sample Code Snippet

Here is a JavaScript code snippet demonstrating the use of the createWebhook method:

import { Bstamp, Network } from 'edeXa-sdk';

async function createWebhook() {
const bStamp = new Bstamp({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};

const dataToCreate = {
redirectUrl: 'https://example.com',
description: 'Creating webhook for an event, provided by edeXa',
action: ['hash.succeed', 'hash.failed'],
}

const version = {
version: API_VERSION.VERSION_2
}

try {
const webhook = await bstamp.createWebhook(dataToCreate, version);
// Handle success
} catch (error) {
// Handle error
}
}


Key Points to Note

  • Asynchronous Function: The createWebhook function operates as an asynchronous (async) function, leveraging await to hold execution until the bstamp.createWebhook promise completes.
  • Token Replacement: Make sure to replace token used in Authorization with your token, which you will get in response of authentication method

Request Parameters

ParameterRequiredTypeDescription
redirectUrlYesStringEnter the url on which you want to create a webhook
descriptionYesStringThe description of the respective webhook
actionYesArrayEnter the actual events of your webhook
versionYesStringUse a specific available version of bStamp

Response Format

KeyTypeDescription