Getting Started
Prerequisites
Before integrating the CDK, you'll need:
- k-ID Compliance Studio Account - As part of onboarding you should be given an account to sign in at https://portal.k-id.com.
- Configured Product - Create and configure a product in the Compliance Studio. For more info, check the Compliance Studio product guide.
- API Key - Obtain your product's API key for the appropriate environment (Test/Live)
Basic Integration Steps
-
Configure Your Product
- Set up permissions, data notices, and branding in the Developer Portal
- Configure verification methods and trusted adult preferences
- Push configuration to Test environment for development
-
Generate Widget URLs
- Make API calls to generate widget URLs for your specific flow
- Embed the returned URLs in iframes within your application
-
Handle JavaScript Events or Webhook Events
- Listen for events in the frontend from the embedded widgets
- Process results and update your application state accordingly
- Alternatively, events can also be received through webhook calls. For more information see Webhooks
Quick Start Example - Access Age Verification
Step 1: Generate Widget URL (Backend)
# Python/Flask example - Call from your backend only
import requests
import os
@app.route('/api/generate-age-verification')
def generate_age_verification():
api_key = os.environ.get('KID_API_KEY') # Store securely in environment/secrets manager
response = requests.post( # For product test mode, ensure you are calling the test endpoint with the test API key
'https://game-api.k-id.com/age-verification/perform-access-age-verification',
headers={
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
},
json={
'jurisdiction': 'GB',
'criteria': {
'ageCategory': 'ADULT'
}
}
)
return response.json()
Step 2: Embed Widget (Frontend)
<!-- HTML - Embed the widget with required permissions -->
<div id="verification-container">
<iframe
id="verification-widget"
src="VERIFICATION_URL_FROM_BACKEND"
width="100%"
height="600"
frameborder="0"
allow="camera;autoplay;payment;publickey-credentials-get;publickey-credentials-create">
</iframe>
</div>
Step 3: Listen for Events (Frontend)
// JavaScript - Handle verification events
window.addEventListener('message', (event) => {
// Validate origin for security
if (event.origin !== 'https://family.k-id.com') {
return;
}
console.log('Verification event:', event.data);
// Handle verification results
if (event.data.eventType === 'Verification.Result') {
const result = event.data.data;
if (result.status === 'PASS') {
// Age verification successful
console.log('Age verified:', result.ageCategory);
console.log('Method used:', result.method);
// Grant access to age-restricted content
} else if (result.status === 'FAIL') {
console.log('Verification failed:', result.failureReason);
// Handle verification failure
}
}
});