Webhooks
Configure webhook URLs to have thirdweb notify your backend when successful or failed events occur.
Use cases
- Update your database when a buyer purchases an NFT.
- Send an email to a buyer after their purchase succeeds.
- Inform your team in Slack/Discord when a payment or purchase failed.
Events
The following webhook events are supported.
Request format
thirdweb will call your backend with an HTTPS POST
request:
Headers
Request body
Usage
Provide a webhook handler URL
Webhooks are configured separately for testnet and production checkout on the dashboard. Webhook URLs must be publicly accessible https
endpoints.
Do not provide a localhost
URL to test your local server. We recommend testing your development server with a service like ngrok to serve a temporary public URL.
Please return a 2xx
response for unexpected or unused event types to prevent unnecessary retries.
Verify the signature header
To ensure the request came from thirdweb, each webhook request signs the payload and provides this signature in the x-thirdweb-signature
header.
To verify this signature, create a SHA-256 HMAC hash with your thirdweb payments secret key that can be found in the thirdweb dashboard payments settings and the body payload as the message (as a JSON-encoded string).
Example implementation
Here's a simplified HTTP handler in Next.js:
Test the webhook response
Use the Test webhook button to send a dummy payload to your webhook URL and see response status/body.
View recent webhook events
Select the List events button to view the recent webhook events, including the request body and response status/body from your backend. This view is useful to debug misconfigured webhook handlers.
FAQ
Why do I need to verify the signature header?
If your server is public, a bad actor can spoof a webhook request. Verifying the signature ensures the payload has not been changed. If a bad actor changes the webhook request body, the signature would not match the signed payload.
Why is my signature header mismatched?
Here are common reasons the signature header may be mismatched.
- Check if the header is set lower-cased. Some server frameworks (e.g. Next.js) use lowercase request header names since they are case-insensitive (RFC 2616).
- Make sure you're passing the entire body as the message in the HMAC signature. Some frameworks require you to configure the HTTP handler to not parse the request body (e.g. Next.js).
- Make sure your API key is valid.
What IP address will webhook requests come from?
Webhooks will be sent from the IP address 44.225.232.73
.
How often will webhook requests be retried?
Webhooks are retried every five minutes for up to one hour until a 2xx
response is returned.
Can I filter which webhook events are sent?
Currently there is no way to filter which events are sent to your webhook URLs. thirdweb may add new webhook event types without notice. Please ignore events that you don't need by returning a 2xx
response.