Age Verification
Age verification is becoming increasingly important as new regulations require platforms to verify user ages before providing access to certain features or content. k-ID's Compliance Development Kit makes compliance simple by providing a comprehensive, jurisdiction-aware verification system that adapts to local legal requirements.
This guide will walk you through implementing age verification in just a few steps, allowing you to quickly meet regulatory requirements while providing a smooth user experience.
Prerequisites
Before you begin, you'll need:
- A k-ID Product: Create and configure your product in the k-ID Compliance Studio
- API Key: Generate your API key from the Developer Settings page of your product
- Webhook Endpoint (optional but recommended): Set up a secure HTTPS endpoint to receive verification results. For more detail, see Webhooks.
Step 1: Initiate Age Verification
Call the /age-verification/perform-access-age-verification
API to create a verification request. This returns a unique URL that users will use to complete their age verification.
Use our interactive Swagger documentation with your API key to quickly generate your Age Verification URL.
Important: For your implementation, this should be a server-to-server call to protect your API key from being exposed in client-side code.
Example Request
POST /api/v1/age-verification/perform-access-age-verification
Content-Type: application/json
Authorization: Bearer your-api-key
{
"jurisdiction": "GB",
"criteria": {
"ageCategory": "ADULT"
}
}
Example Response
{
"id": "7854909b-9124-4bed-9282-24b44c4a3c97",
"url": "https://family.k-id.com/verify?token=eyJhbGciOiJFUzM4NCIs..."
}
The jurisdiction
parameter ensures compliance with local regulations (like setting "GB"
for UK requirements), while the ageCategory: "ADULT"
criteria verifies users meet the age criteria requirements defined in that jurisdiction.
Step 2: Display the Verification Interface
Use the returned URL to create an iframe in your website or app. Users will complete their verification through this interface, with available methods automatically adapting to jurisdictional requirements.
HTML Implementation
<div id="verification-container">
<iframe
id="verification-widget"
src="VERIFICATION_URL"
width="100%"
height="600"
frameborder="0"
allow="camera;payment;publickey-credentials-get;publickey-credentials-create">
</iframe>
</div>
The iframe will present users with multiple verification methods such as:
- AgeKey: A reusable and anonymous age-proof generated after an initial verification process.
- Facial Age Estimation: Privacy-preserving age estimation using a device's camera
- ID Document Verification: Government-issued ID verification
The specific methods available depend on the jurisdiction and your product configuration. For more detail, see Verification Methods
Step 3: Handle Verification Results
Once the user has successfully completed the age verification, or the user has retried the maximum number of times and has not succeeded, you can receive verification results in three ways:
Option A: Real-time JavaScript Events (Client-side)
const handleMessage = (event) => {
const message = event.data;
if (message.eventType === "Verification.Result") {
if (message.data.status === "PASS") {
// User passed verification - grant access
console.log("Age verified:", message.data.ageCategory);
grantAccess();
} else if (message.data.status === "FAIL") {
// User failed verification - restrict access
console.log("Verification failed:", message.data.failureReason);
restrictAccess();
}
}
};
window.addEventListener("message", handleMessage);
Option B: Webhook Notifications (Server-side)
Configure your webhook endpoint to receive Verification.Result
events:
{
"eventType": "Verification.Result",
"data": {
"id": "7854909b-9124-4bed-9282-24b44c4a3c97",
"status": "PASS",
"ageCategory": "adult",
"method": "id-document",
"age": {
"low": 25,
"high": 25
}
}
}
Option C: Polling (Alternative Method)
Query the verification status using the verification ID:
GET /api/v1/age-verification/get-status?id=7854909b-9124-4bed-9282-24b44c4a3c97
Response:
{
"id": "7854909b-9124-4bed-9282-24b44c4a3c97",
"status": "PASS",
"ageCategory": "adult",
"method": "id-document"
}
What's Next?
Now that you've implemented basic age verification, explore these resources to enhance your integration:
- API Reference Documentation: Detailed documentation of all age verification APIs
- Verification Methods: Configure specific verification methods and scenarios for your product
- Webhooks Setup: Implement robust webhook handling for production systems
- Best Practices: Implement best practices to ensure security and a reliable user experience
- Pre-launch Checklist: Review requirements before going live (contact k-ID support for the latest checklist)
With k-ID's Age Verification API, you can quickly achieve compliance with age verification regulations while providing users with a smooth, privacy-focused verification experience.