Events overview
k-ID provides two types of events to help you respond to user actions and system changes in real-time - DOM Events and Webhooks. Both event types allow you to build responsive integrations that react to important changes in the k-ID system.
What are events?
Events are notifications sent by k-ID when specific actions occur in your application. They allow you to:
- React to user actions: Respond immediately when users complete verification, grant consent, or interact with widgets
- Update your application state: Keep your application synchronized with k-ID's state changes
- Handle asynchronous operations: Receive notifications when long-running processes complete
- Build real-time experiences: Create responsive user interfaces that update automatically
DOM events
DOM Events are JavaScript events emitted by k-ID widgets that run in iframes on your website. These events are sent via the browser's postMessage API and can be listened to using standard JavaScript event listeners.
When to use DOM Events
- Responsive UI updates: To update your interface immediately when users interact with widgets
- Client-side interactions: When you need to react to widget interactions in the browser
- Real-time user feedback: To provide immediate visual feedback to users
Key features
- Emitted directly from widgets in iframes
- Received via JavaScript
messageevent listeners - Requires origin validation for security
- Perfect for client-side JavaScript applications and responsive UI
For detailed information, see DOM Events.
Webhooks
Webhooks are HTTP POST requests sent from k-ID's servers to your server endpoints. They provide server-to-server notifications about important events in the k-ID system.
When to use webhooks
- Data integrity: To reliably update your database and maintain data consistency
- Server-side processing: When you need to handle events on your servers
- Reliable delivery: For critical events that must be processed even if users navigate away
- Background processing: To handle events asynchronously without blocking user interactions
- State synchronization: To keep your server state synchronized with k-ID's state
Key features
- Sent as HTTP POST requests to your configured endpoints
- Include cryptographic signatures for security validation
- Configured per Product in Compliance Studio
- Ideal for server-side integrations, data integrity, and reliable state management
For detailed information, see Webhooks.
Choosing between DOM events and webhooks
Both event types serve different purposes and can be used together:
| Use Case | Recommended Approach |
|---|---|
| Real-time UI updates in browser | DOM Events |
| Data integrity and state management | Webhooks or server-side API calls |
| Server-side processing and database updates | Webhooks |
| Responsive user feedback | DOM Events |
| Reliable event processing | Webhooks |
| Widget interactions | DOM Events |
Use DOM Events for responsive UI updates, and use webhooks or server-side API calls (such as /age-verification/get-status or /challenge/get-status) for data integrity and reliable state management. Many applications use both, DOM Events for immediate UI feedback and webhooks for reliable server-side processing and data persistence.
Getting started
- DOM Events - Learn about DOM events emitted by widgets
- Webhooks - Learn about webhook configuration and handling
- Event structures - Explore available event types and payloads
- Webhook event types - Explore available webhook event types