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, leveragingawait
to hold execution until thebstamp.createWebhook
promise completes. - Token Replacement: Make sure to replace
token
used inAuthorization
with yourtoken
, which you will get in response of authentication method
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
redirectUrl | Yes | String | Enter the url on which you want to create a webhook |
description | Yes | String | The description of the respective webhook |
action | Yes | Array | Enter the actual events of your webhook |
version | Yes | String | Use a specific available version of bStamp |
Response Format
Key | Type | Description |
---|