Webhooks
Everything you need to know for using WalletCloud's webhooks in your applications. Get notifications for external transfers, internal transfers, and token transfers.
Webhooks are a way for you to subscribe to events that occur on your wallets. This guide will walk through what webhooks are and how you can use them in order to get started with integrating them into your application.
What are Webhooks?
Webhooks are a way for users to receive notifications when an event occurs on your wallet. Rather than continuously polling the server to check if the state has changed, webhooks provide information to you as it becomes available, which is a lot more efficient and beneficial for developers. Webhooks work by registering a URL to send notifications to once certain events occur.
One may think of webhook notifications as SMS notifications. The entity sending the message has your registered phone number and they send a specific message payload to that phone number. You then have the ability to respond confirming you have received it, creating a two-way communication stream.
Types of Webhooks
Wallet Transaction Webhooks
WalletCloud currently offers the Wallet Transaction webhooks (WALLET_TRANSACTION). This webhooks are sent to your url when there is a transaction on your wallet. Furthermore, the transaction property in the webhook payload that will be sent to your url will also contain a type. The supported transaction types include:
RECEIVED_ASSET: This webhook is sent when an address on your wallet receives a transaction such as a token transfer.
SENT_ASSET: This webhook is sent when your wallet sends out tokens to external addresses. This webhooks notifies you of the status of the transaction.
Example payload
How To Set Up Webhooks
Navigate to your wallet dashboard on WalletCloud
.
Click on the settings tab.
Scroll to the webhooks section and add your webhook url.
Click on the "Test Webhook" button to verify that you webhook works correctly. (We will send a demo payload to your webhook url which you can inspect).
Click on save changes to save your webhook.
Webhook Signature and Security
To verify the authenticity of WalletCloud's webhooks, you can verify that they originated from WalletCloud by generating a HMAC SHA-256 hash code using your Wallet API key and request body. Take the following steps to verify a webhook signature:
1. Find your wallet API key on your wallet dashboard
2. Validate the payload signature
Every webhook payload will contain a hashed authentication signature in the header which is computed by generating a hash from concatenating your wallet API key and request body, using the HMAC SHA256 hash algorithm.
In order to verify this signature came from WalletCloud, you simply have to generate the HMAC SHA256 hash and compare it with the signature received.
Example Request Header
Example Signature Validation Function
Last updated