Create Webhook
Programatically create a Helius webhook.
Last updated
Was this helpful?
Programatically create a Helius webhook.
Last updated
Was this helpful?
Creates a webhook with specified account addresses, transaction types, and a webhook URL. Optionally, you can include an authorization header to verify that the webhook originated from Helius. For a full list of supported transaction types, please see Transaction Types
You can add up to 100,000 addresses via the API.
{
"webhookURL": "https://TestServer.test.repl.co/webhooks",
"transactionTypes": ["NFT_SALE"],
// Use ["ACCOUNT_ADDRESS", "ACCOUNT_ADDRESS"] for multiple accountAddresses.
"accountAddresses": ["ACCOUNT_ADDRESS"],
"webhookType": "enhanced", // "enhancedDevnet"
"authHeader": "<Optional_AuthHeader>"
}
{
"webhookURL": "https://TestServer.test.repl.co/webhooks",
"transactionTypes": ["Any"],
// Use ["ACCOUNT_ADDRESS", "ACCOUNT_ADDRESS"] for multiple accountAddresses.
"accountAddresses": ["ACCOUNT_ADDRESS"],
"webhookType": "raw", // "rawDevnet"
"txnStatus": "all", // success/failed
"authHeader": "<Optional_AuthHeader>"
}
{
"webhookURL": "https://discord.com/api/webhooks/<WebhookID>/<TokenID>",
"transactionTypes": ["NFT_SALE"],
// Use ["ACCOUNT_ADDRESS", "ACCOUNT_ADDRESS"] for multiple accountAddresses.
"accountAddresses": ["ACCOUNT_ADDRESS"],
"webhookType": "discord" // "discordDevnet"
}
const createWebhook = async () => {
try {
const response = await fetch(
"https://api.helius.xyz/v0/webhooks?api-key=<PASTE YOUR API KEY HERE>",
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"webhookURL": "https://TestServer.test.repl.co/webhooks",
"transactionTypes": ["Any"],
"accountAddresses": ["2PP32Vmuzgo1UC847Yzdd9CkowXWhMLrJ47Gfr4KDAyN"],
"webhookType": "raw", // "rawDevnet"
"txnStatus": "all", // success/failed
}),
}
);
const data = await response.json();
console.log({ data });
} catch (e) {
console.error("error", e);
}
};
createWebhook();
Here are some testing environments that are quick to set up for posting webhook events:
The api key.
POST /v0/webhooks HTTP/1.1
Host: api.helius.xyz
Authorization: Basic username:password
Content-Type: application/json
Accept: */*
Content-Length: 139
{
"webhookURL": "text",
"transactionTypes": [
"UNKNOWN"
],
"accountAddresses": [
"text"
],
"webhookType": "text",
"txnStatus": "all",
"authHeader": "text"
}
The created webhook.
{
"webhookID": "text",
"wallet": "text",
"webhookURL": "text",
"transactionTypes": [
"UNKNOWN"
],
"accountAddresses": [
"text"
],
"webhookType": "text",
"txnStatus": "all",
"authHeader": "text"
}