Platform Webhooks
Why Use Avalanche Platform Webhooks?
Avalanche Platform Webhooks enable developers to monitor activities on the P and X chains with the following advantages:
- Real-time notifications: Receive updates as events occur.
- Reduced overhead: Eliminate the need for constant blockchain polling.
- Customizable monitoring: Subscribe to specific events and apply filters tailored to your needs.
- Support for multiple sub-events: Track related activities within a single webhook subscription.
These features make webhooks ideal for building responsive applications, such as wallet trackers, staking monitors, or validator management tools.
Understanding webhook event types
Avalanche Platform Webhooks support two main event types, each with specific sub-events you can subscribe to:
- Address activity: Tracks balance-related changes and reward distributions for P/X chain addresses.
- Validator activity: Monitors validator registration, balance updates, and reward distributions.
Setting Up a Webhook
To get started, you’ll use the Data API to create your webhook. Authentication is required, so you’ll need an API key.
Create Your Request
Here’s how to set up a webhook using curl:
Creating a Webhook: Examples
Example 1: Tracking Address Activity
This webhook monitors balance changes, thresholds, and rewards for a specific address on the P-Chain.
Key Fields Explained
url
: Where notifications will be sent.chainId
: The chain to monitor (“p-chain” or “x-chain”).eventType
: Set to “platform_address_activity”.network
: “fuji” (testnet) or “mainnet”.metadata.keys
: The address(es) you’re tracking.metadata.subEvents
: The sub-events you want to monitor.metadata.balanceThresholdFilter
: Triggers BALANCE_THRESHOLD_PLATFORM if the “unlockedUnstaked” balance falls below 5.5 AVAX (5,500,000,000 nAVAX).
Example 2: Tracking Validator Activity
This webhook monitors a validator’s NodeID for various events.
Key Fields Explained
metadata.keyType
: Set tonodeId
orsubnetId
.metadata.keys
: TheNodeID
to track (only one key allowed).metadata.subnetIds
: Filters events to a specific subnet (optional).metadata.l1ValidatorFeeBalanceThreshold
: Triggers if the L1 validator’s balance drops below 5 AVAX.
Example 3: Monitor all the validators in the primary network
To monitor all validators on the Primary Network:
Was this page helpful?