Getting Started with Xident
This guide will walk you through integrating Xident age verification into your website in under 5 minutes.
Prerequisites
Before you begin, you'll need:
- A Xident account (sign up here)
- A project with an API key
- A callback URL on your domain (HTTPS required in production)
Step 1: Create a Project
- Log in to dashboard.xident.io
- Click "Create Project"
- Enter your website domain (e.g.,
example.com) - Copy your Public API Key (starts with
pk_)
Step 2: Add the SDK to Your Website
Add the Xident SDK script tag to your HTML, typically in the <head> or before </body>:
<script
src="https://sdk.xident.io/xident.min.js"
data-api-key="pk_live_your_api_key"
data-callback-url="https://yoursite.com/verified"
></script> Replace:
pk_live_your_api_keywith your actual public API keyhttps://yoursite.com/verifiedwith your callback URL
Step 3: Add a Verification Button
Add a button that triggers the verification flow:
<button onclick="Xident.start()">
Verify Your Age
</button> When clicked, users will be redirected to verify.xident.io to complete verification.
Step 4: Handle the Callback
After verification, users are redirected to your callback URL with query parameters:
https://yoursite.com/verified?token=abc123&status=success Callback Parameters
| Parameter | Description |
|---|---|
token | One-time verification token |
status | success or cancelled |
user_id | Your userId if provided in start() |
Step 5: Verify the Token (Backend)
Important: Always verify tokens server-side. Never trust client-side results.
Node.js Example
app.get('/verified', async (req, res) => {
const { token, status } = req.query;
if (status !== 'success') {
return res.redirect('/verification-cancelled');
}
try {
const response = await fetch('https://api.xident.io/v1/tokens/verify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.XIDENT_SECRET_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ token })
});
const result = await response.json();
if (result.verified && result.age >= 18) {
req.session.ageVerified = true;
return res.redirect('/content');
}
} catch (error) {
console.error('Verification error:', error);
}
return res.redirect('/verification-failed');
}); Python Example
@app.route('/verified')
def handle_verification():
token = request.args.get('token')
status = request.args.get('status')
if status != 'success':
return redirect('/verification-cancelled')
response = requests.post(
'https://api.xident.io/v1/tokens/verify',
headers={
'Authorization': f'Bearer {os.environ["XIDENT_SECRET_KEY"]}',
'Content-Type': 'application/json'
},
json={'token': token}
)
result = response.json()
if result.get('verified') and result.get('age', 0) >= 18:
session['age_verified'] = True
return redirect('/content')
return redirect('/verification-failed') Verification Response
The token verification endpoint returns:
{
"verified": true,
"age": 25,
"country": "US",
"xident_id": "xid_abc123",
"liveness_score": 0.95,
"methods_completed": ["liveness", "age_estimation"],
"metadata": {
"your_custom_field": "value"
}
} Testing
For development, you can use:
pk_test_xxxAPI keys (sandbox mode)http://localhost:*callback URLs (no HTTPS required)
<script
src="https://sdk.xident.io/xident.min.js"
data-api-key="pk_test_your_test_key"
data-callback-url="http://localhost:3000/verified"
></script> Next Steps
- Core Concepts - Learn about Xident ID and verification flows
- Integration Guide - Advanced SDK configuration
- Dashboard Guide - Monitor usage and analytics
- API Reference - Full API documentation