-
Notifications
You must be signed in to change notification settings - Fork 621
insight webhooks docs #6574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
insight webhooks docs #6574
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
apps/portal/src/app/insight/webhooks/filtering/page.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| import { createMetadata } from "@doc"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| title: "Insight Webhooks | thirdweb Infrastructure", | ||
| description: "Filtering", | ||
| image: { | ||
| title: "Insight", | ||
| icon: "insight", | ||
| }, | ||
| }); | ||
|
|
||
| # Filtering | ||
|
|
||
| ## Webhook Topics | ||
|
|
||
| ### `v1.events` | ||
|
|
||
| Subscribes to blockchain log events. | ||
|
|
||
| ### `v1.transactions` | ||
|
|
||
| Subscribes to blockchain transactions. | ||
|
|
||
| ## Webhook Filters | ||
|
|
||
| You can filter webhook notifications based on specific criteria. | ||
| Each webhook must have either a events filter or a transcations filter (or both). | ||
iuwqyir marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Event Filters | ||
| ```typescript | ||
| { | ||
| "v1.events": { | ||
| chain_ids: string[], // Filter by specific chains | ||
| addresses: string[], // Filter by contract addresses | ||
| signatures: { // Filter by event signatures | ||
| sig_hash: string, // Event signature hash | ||
| abi?: string, // Optional ABI for data decoding | ||
| params?: Record<string, any> // Filter on decoded parameters | ||
| }[] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Transaction Filters | ||
| ```typescript | ||
| { | ||
| "v1.transactions": { | ||
| chain_ids: string[], // Filter by specific chains | ||
| from_addresses: string[], // Filter by sender addresses | ||
| to_addresses: string[], // Filter by recipient addresses | ||
| signatures: { // Filter by function signatures | ||
| sig_hash: string, // Function signature hash | ||
| abi?: string, // Optional ABI for data decoding | ||
| params?: string[] // Filter on decoded parameters | ||
| }[] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### ABIs | ||
|
|
||
| You can specify partial ABIs to have decoded data sent in the webhook payload. For this you also need to give the `sig_hash` of the event or function call. | ||
|
|
||
| The following example will filter for `Transfer` events on Ethereum for the contract `0x1f9840a85d5af5bf1d1762f925bdaddc4201f984` | ||
| ```typescript | ||
| { | ||
| ... | ||
| filters: { | ||
| "v1.events": { | ||
| chain_ids: ["1"], | ||
| addresses: ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"], | ||
| signatures: [ | ||
| { | ||
| sig_hash: | ||
| "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", | ||
| abi: '{"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"}', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| And this example will filter for `Approve` function calls on Ethereum for the contract `0x1f9840a85d5af5bf1d1762f925bdaddc4201f984` | ||
| ```typescript | ||
| { | ||
| ... | ||
| filters: { | ||
| "v1.transactions": { | ||
| chain_ids: ["1"], | ||
| addresses: ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"], | ||
| signatures: [ | ||
| { | ||
| sig_hash: "0x095ea7b3", | ||
| abi: '{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"rawAmount","type":"uint256"}],"name":"approve","type":"function"}', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ### Params | ||
|
|
||
| `params` on the `signatures` object will allow you to filter based on the decoded data. Only strict equality is supported at the moment. | ||
|
|
||
| ### Notes | ||
| - You can specify ABIs to receive decoded event/transaction data | ||
| - Parameter filtering supports equality matching only | ||
| - At least one filter criteria must be specified | ||
68 changes: 68 additions & 0 deletions
68
apps/portal/src/app/insight/webhooks/managing-webhooks/page.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { createMetadata } from "@doc"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| title: "Insight Webhooks | thirdweb Infrastructure", | ||
| description: "Managing Insight webhooks", | ||
| image: { | ||
| title: "Insight", | ||
| icon: "insight", | ||
| }, | ||
| }); | ||
|
|
||
| # Managing Webhooks | ||
|
|
||
| For most up to date technical spec refer to https://insight-api.thirdweb.com/reference#tag/webhooks. | ||
|
|
||
| ## List Webhooks | ||
| `GET /v1/webhooks` | ||
|
|
||
| Retrieve all webhooks for your project or get details for a specific webhook by ID. | ||
|
|
||
| ## Create Webhook | ||
| `POST /v1/webhooks` | ||
|
|
||
| Creates a new webhook subscription. | ||
| It may take up to a minute to start working. | ||
|
|
||
| ### Verifying the created webhook | ||
| - The webhook starts in a suspended state | ||
| - An OTP (One-Time Password) is sent to your webhook URL for verification | ||
| - You must verify the webhook within 15 minutes using the OTP | ||
| - Once verified, it may take up to a minute for the webhook to become fully active | ||
| - You can request a new OTP if you can't retrieve the initial OTP | ||
|
|
||
| ## Update Webhook | ||
| `PATCH /v1/webhooks/:webhook_id` | ||
|
|
||
| You can modify the URL or filters of a webhook. Additionally you can enable and disable the webhook. | ||
| Changes may take up to a minute to take effect. | ||
|
|
||
| ### Updating webhook URL | ||
| - If you update the webhook URL, you'll need to verify it again with a new OTP | ||
| - Other fields can be updated without requiring re-verification | ||
|
|
||
| ## Delete Webhook | ||
| `DELETE /v1/webhooks/:webhook_id` | ||
|
|
||
| Permanently removes a webhook subscription. This action cannot be undone. | ||
|
|
||
| ## Verify Webhook | ||
| `POST /v1/webhooks/:webhook_id/verify` | ||
|
|
||
| Activates a webhook using the OTP code that was sent to your webhook URL. Required for: | ||
| - New webhook creation | ||
| - After updating a webhook URL | ||
|
|
||
| ## Resend OTP | ||
| `POST /v1/webhooks/:webhook_id/resend-otp` | ||
|
|
||
| Request a new OTP code if the original expires or is lost: | ||
| - Invalidates the previous OTP | ||
| - New OTP expires after 15 minutes | ||
| - Only works for webhooks pending verification | ||
|
|
||
| ## Test Webhook | ||
| `POST /v1/webhooks/test` | ||
|
|
||
| Sends a sample payload signed with a test secret ('test123'). | ||
| Useful for testing your receiver endpoint before creating actual webhooks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { createMetadata } from "@doc"; | ||
|
|
||
| export const metadata = createMetadata({ | ||
| title: "Insight Webhooks | thirdweb Infrastructure", | ||
| description: "Getting started with Insight webhooks", | ||
| image: { | ||
| title: "Insight", | ||
| icon: "insight", | ||
| }, | ||
| }); | ||
|
|
||
| # Webhooks | ||
|
|
||
| Webhooks allow you to receive notifications when specific blockchain events or transactions occur. This enables you to automate workflows and keep your applications in sync with on-chain activity. | ||
|
|
||
| ## About Webhooks | ||
|
|
||
| ### Data Delivery | ||
| Webhook events are collected and delivered in batches for optimal performance and reliability. This makes webhooks ideal for: | ||
| - Tracking when specific blockchain events occur | ||
| - Aggregating on-chain data | ||
| - Building analytics and monitoring systems | ||
| - Triggering downstream processes | ||
|
|
||
| ### Delivery Guarantees | ||
| Events are guaranteed to be delivered *at least once*. | ||
| Your application should implement idempotency and deduplication logic using the unique event ID in the payload. | ||
| Events may occasionally be delivered out of order. | ||
|
|
||
| ### Performance Requirements | ||
| - Your receiving endpoint must respond within 3 seconds | ||
| - If your endpoint consistently fails to respond in time, the webhook will be automatically suspended | ||
| - We recommend implementing a queue system if you need to perform time-consuming operations |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two typos in this sentence:
The corrected sentence should read:
"Each webhook must have either an events filter or a transactions filter (or both)."
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.