updateWebhook - SDK

Update a NftActivityWebhook’s active status or NFT filters.

Update a NftActivityWebhook's active status or NFT filters.

Don’t have an API key?

Start using this method in your app today. Get started for free

Description

Update a NftActivityWebhook's active status or NFT filters.

Parameters

NameTypeDescription
nftWebhookstringThe NFT activity webhook to update, i.e., NFT_ACTIVITY = NFT_ACTIVITY.
updateobjectObject containing the update. Parameters include: 1. limit - number Number of addresses to fetch. 2. pageKey - string Page cursor for the next page.

update parameters

Include only one of these update objects as the second parameter.

NameTypeDescription
WebhookStatusUpdateobjectParams object when calling updateWebhook to add and remove NFT filters for a NFT_ACTIVITY. Parameters here include: 1. isActive - boolean Whether the webhook is active.
WebhookAddressUpdateobjectParams object when calling updateWebhook to add and remove NFT filters for a NFT_ACTIVITY. Parameters here include: 1. addAddresses - array of strings The addresses to additionally track. 2. removeAddresses - array of strings Existing addresses to remove.
WebhookAddressOverrideobjectParams object when calling updateWebhook to add and remove NFT filters for a NFT_ACTIVITY. Parameters here include: 1. newAddresses - array of strings The new addresses to track. Existing addresses will be removed.
WebhookNftFilterUpdateobjectParams object when calling updateWebhook to add and remove NFT filters for a NFT_ACTIVITY. Parameters here include: 1. addFilters - array of strings The filters to additionally track. 2. removeFilters - array of strings Existing filters to remove.
CustomGraphqlWebhookUpdateobjectParams object when calling updateWebhook to update the status for GRAPHQL. Parameters here include: 1. isActive - boolean Whether the webhook is active.

Response

PropertyTypeDescription
Promise<void>voidReturns undefined.

Example Request and Response

Prerequisite: You will need to install the Alchemy SDK before making requests with it.

The commands for installing it using npm or yarn are given below:

$npm install alchemy-sdk@latest

Request

index.js
1// Setup: npm install alchemy-sdk
2// Github: https://github.com/alchemyplatform/alchemy-sdk-js
3const { Alchemy, Network } = require("alchemy-sdk");
4
5// authToken is required to use Notify APIs. Found on the top right corner of
6// https://dashboard.alchemy.com/notify.
7const settings = {
8 authToken: "your-auth-token",
9 network: Network.ETH_MAINNET, // Replace with your network.
10};
11
12// Creates an Alchemy object instance with the config to use for making requests
13const alchemy = new Alchemy(settings);
14
15const main = async () => {
16 const updateWebhookById = await alchemy.notify.updateWebhook("wh_qv16bt12wbj9kax4", { isActive: false });
17
18 //// Updating Address Activity Webhook: add/remove addresses
19 const updateAddresses =
20await alchemy.notify.updateWebhook("wh_qv16bt12wbj9kax4", {
21 addAddresses: [
22 "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96010",
23 "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96011",
24 ],
25 removeAddresses: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96043"],
26});
27
28 // Updating Address Activity Webhook: replace all addresses
29 const replaceAddresses =
30await alchemy.notify.updateWebhook("wh_qv16bt12wbj9kax4", {
31 newAddresses: ["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96010"],
32});
33
34 // Updating NFT Filter Webhook: add/remove filters
35 const updateNftFilterWebhook =
36await alchemy.notify.updateWebhook("wh_zyhqo5im08n6ougk", {
37 addFilters: [
38 {
39 contractAddress: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
40 tokenId: "101",
41 },
42 ],
43 removeFilters: [
44 {
45 contractAddress: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
46 tokenId: "24",
47 },
48 ],
49});
50
51 //Logging the response to the console
52 console.log(updateWebhookByIdById, updateAddresses, updateNftFilterWebhook, replaceAddresses)
53}
54
55main();

Response

json
1undefined

Use Cases

Here are some potential use cases for the updateWebhook method:

  • Changing the endpoint URL: If you need to update the endpoint URL for an existing webhook, you can use the updateWebhook method to change it.

  • Updating the authentication credentials: If you need to update the authentication credentials for an existing webhook, you can use the updateWebhook method to provide new credentials.

  • Modifying the notification format: If you need to modify the format of the notifications that are sent to the webhook, you can use the updateWebhook method to update the payload format.

  • Adding or removing headers: If you need to add or remove headers to the requests that are sent to the webhook, you can use the updateWebhook method to modify the headers.

Related Methods

  • createWebhook - Create a new Webhook to track transactions sent by the app associated with the app id.