Webhooks
Esta página aún no está disponible en tu idioma.
Webhooks provide real-time updates about the status of provenance registrations. They allow your application to track the complete lifecycle of a registration from initial submission through blockchain confirmation and NFT creation.
Overview
When registering provenance claims, the process involves several asynchronous steps:
- File download and hash calculation (if a file URL is provided)
- Blockchain transaction submission
- Transaction confirmation
- NFT creation and metadata storage
Webhooks notify your application as each step completes, allowing you to track progress and update your users accordingly.
Event Types
Each registrar receives webhooks for all registrations made through their account, whether via API or manual registration. There are two categories of events:
Standard Events
These events fire for all registrations associated with your registrar:
provenance.registration.complete
- Fired when a registration is confirmed on-chainprovenance.registration.nft_added
- Fired when an NFT is successfully attached to the registration
Extended Events
These additional events fire only for registrations made through the API:
provenance.registration.hashed
- Fired when the file hash has been calculatedprovenance.registration.submitted
- Fired when the transaction is submitted to the blockchain
Event Payloads
provenance.registration.hashed
Fired after downloading and hashing the provided file:
provenance.registration.submitted
Fired when the registration transaction is submitted:
provenance.registration.complete
Fired when the registration is confirmed on-chain:
provenance.registration.nft_added
Fired when an NFT is attached to the registration:
Webhook Delivery
Royal uses Svix 🔗 for reliable webhook delivery. This provides:
- Automatic retries for failed deliveries
- Webhook signature verification
- Delivery logs and debugging tools
For details on implementing webhook consumers, including signature verification and best practices, see the Svix documentation 🔗.
Context Object
When making API calls, you can include a context
object containing arbitrary JSON data. This same object will be included in all webhook events related to that registration. This allows you to correlate webhook events with your application’s data.
For example, you might include your internal user ID or transaction reference:
This context will be included in all webhooks related to this registration.
Best Practices
- Verify Signatures: Always verify webhook signatures using the Svix library to ensure authenticity.
- Handle Duplicates: While rare, webhooks may be delivered multiple times. Design your handlers to be idempotent.
- Store Context: Include meaningful context data when registering claims to help correlate webhooks with your application state.
- Monitor Progress: Use webhooks to provide progress updates to your users as their registration moves through the pipeline.
- Log Events: Store webhook events for debugging and audit purposes.