Agemin
v5.8.4 SDK with Singleton Pattern

Developer Documentation

Complete integration guide for Agemin age verification. From quick setup to advanced implementations, we've got you covered with code examples, best practices, and interactive testing tools.

5-Minute Setup

Get started with just 3 lines of code

MAE 1.1 Years

Mean Absolute Error as low as 1.1 years

ISO 27000 Certified

Privacy-first architecture

Quick Navigation

Need Help?

Get support from our team

Contact Support

Prerequisites

  1. 1

    Create an Agemin Account

    Sign up at agemin.com to get started

  2. 2

    Add Your Website/App

    Navigate to Dashboard → Websites and register your domain

    You'll receive an Asset ID like: ast_5b08b274353b92f4

  3. 3

    Get Your API Keys

    Go to Dashboard → API Keys

    age_pk_live_xxxPublic key for frontend SDK
    age_sk_live_xxxPrivate key for backend API (keep secret!)

How Agemin Works

Two-Step Verification Process

  1. 1

    Frontend Verification

    User completes age verification through SDK (selfie or email)

    SDK returns a session token upon completion

  2. 2

    Backend Validation

    Your server validates the session token with our API

    Ensures verification is genuine and prevents tampering

Important Security Note

Never trust frontend-only verification. Always validate results server-side to prevent billing fraud and ensure compliance.

Quick Start in 3 Steps

1

Install the SDK

Using NPM

npm install @bynn-intelligence/agemin-sdk

Using CDN

<script src="https://unpkg.com/@bynn-intelligence/agemin-sdk/dist/agemin-sdk.umd.js"></script>
2

Initialize & Verify (Frontend)

import Agemin from '@bynn-intelligence/agemin-sdk';
// Initialize SDK (v5.0.0+ uses singleton pattern)
const agemin = new Agemin({
assetId: 'ast_YOUR_ASSET_ID', // From Dashboard → Websites
referenceId: generateUniqueId(), // Your unique reference
mode: 'modal' // or 'redirect'
});
// Start verification
agemin.verify({
onAgePass: (result) => {
// User passed age verification
console.log('Session token:', result.sessionToken);
// Send token to your backend for validation
sendToBackend(result.sessionToken);
},
onAgeFail: () => {
// User is underage
window.location.href = '/age-restricted';
}
});
3

Validate on Backend (Required)

// Backend validation endpoint
app.post('/verify-age', async (req, res) => {
const { sessionToken } = req.body;
// Validate with Agemin API - check status to prevent injection attacks
const response = await fetch(`https://api.agemin.com/v1/agemin/check/status/${sessionToken}`, {
method: 'GET',
headers: {
'Authorization': 'Bearer age_sk_live_YOUR_PRIVATE_KEY'
}
});
const data = await response.json();
if (data.status === 'ok' && data.result.passed) {
// Grant access
req.session.ageVerified = true;
res.json({ success: true });
} else {
// Deny access
res.status(403).json({ error: 'Age verification failed' });
}
});

Security Best Practices

API Key Management

DO:Use public keys (age_pk_*) in frontend code
DO:Keep private keys (age_sk_*) on your server only
DO:Use environment variables for private keys
DON'T:Expose private keys in client-side code
DON'T:Commit API keys to version control

Verification Flow

Always validate on backend:Frontend results can be manipulated
Use sessionToken for verification:Call GET /v1/agemin/check/status/:sessionToken to prevent injection attacks
Implement session management:Store verification status server-side
Set expiration times:Re-verify after reasonable periods

Testing Mode

Test Credentials

Use test API keys to develop without affecting production data:

Public Test Key: age_pk_test_xxxxxPrivate Test Key: age_sk_test_xxxxx

Test Scenarios

Pass Verification

Upload any adult face photo or use test email:

test-pass@agemin.com

Fail Verification

Upload any child face photo or use test email:

test-fail@agemin.com

Test Mode Limitations

• Test mode always shows a "TEST MODE" banner
• Results are not stored permanently
• Rate limits are lower than production

Common Use Cases

E-commerce Age Gate

Verify age before allowing purchase of restricted items

// Check age before checkout
if (cartHasRestrictedItems()) {
agemin.verify({
onAgePass: () => {
proceedToCheckout();
},
onAgeFail: () => {
showRestrictedItemsMessage();
}
});
}

Gaming Platform

Automatic age verification on app launch

// Auto-verify on game start
window.addEventListener('load', async () => {
const result = await agemin.validateSession({
onAgePass: () => {
loadGame();
},
onAgeFail: () => {
showParentalControls();
}
});
if (result === true) {
// User already verified in previous session
loadGame();
}
});

Streaming Platform

Verify age for mature content

// Check age for mature content
function playVideo(videoId) {
if (isMatcureContent(videoId)) {
agemin.verify({
metadata: { videoId }, // Track what triggered verification
onAgePass: () => {
startStreaming(videoId);
},
onAgeFail: () => {
suggestFamilyContent();
}
});
} else {
startStreaming(videoId);
}
}

Compliance & Legal

Global Compliance

  • GDPR (Europe)
  • COPPA (United States)
  • Age Appropriate Design Code (UK)
  • Privacy Act (Australia)

Data Protection

  • No personal data stored by default
  • Biometric data deleted after verification
  • End-to-end encryption
  • ISO 27001 certified infrastructure

Note: Always consult with your legal team to ensure compliance with local regulations. Agemin provides the tools, but implementation must align with your specific requirements.

Security Best Practices

Follow these guidelines to ensure secure integration.

API Security

  • Never expose private API keys in client-side code
  • Always make API calls from your backend server
  • Use HTTPS for all API communications
  • Rotate API keys regularly

Privacy & Compliance

  • Inform users before age verification
  • No personal data is stored by default
  • Comply with regional age verification laws
  • Provide clear privacy policy
  • Use reference IDs for audit trails

Need help?

Our developer support team is here to help you integrate Agemin successfully.