Skip to main content

How to Add Age Verification to a Website: Popup or API

Use a Didit hosted popup for web sign-up or POST a selfie to the Age Estimation API. Age Estimation costs $0.10 per check; full KYC with document proof costs $0.33.

How to Add Age Verification to a Website: Popup or API

Contents

In this guide

Jump to the part you need.

You can add age verification to a website with a popup that runs a hosted Didit session, or with a server-to-server API call that returns an age decision from a selfie. This fits sign-up, checkout, and content gates. Didit Age Estimation costs $0.10 per check, and a full KYC check with document proof costs $0.33. The caveat: a selfie estimate is an age gate, not legal proof of age, so borderline results need a document fallback.

Last updated: November 26, 2026. Prices checked against the live Didit price feed on November 26, 2026.

Age verification methods for a website
MethodHow it worksPublished priceBest for
JavaScript SDK modal or InContext iframe with a hosted sessionLiveness step with age estimation enabled, opened in a modal or iframeAge Estimation $0.10 per checkSign-up and content gates
Standalone Age Estimation APIOne multipart POST with a selfie, returns age and passive liveness$0.10 per completed checkApps that already capture a selfie
Document fallback with full KYCID document, passive liveness, face match, device and IP analysis$0.33 per full KYC checkRegulated goods and borderline ages

Start free in the sandbox at business.didit.me, with no sales call. Developers can connect Didit to an AI assistant through the Didit MCP server. Prices and plan details are on didit.me/pricing.

The gate returns a decision status and warnings. Didit Age Estimation returns Approved only when the warnings array is empty, and any warning returns Declined. Document verification is your implementation choice after a borderline estimate or a decline you do not want to reject outright. The JavaScript SDK modal and the InContext iframe are the documented popup-style options, and we recommend them when the user is already on your site and you want the check inside the same page. The standalone API is the recommended method when your app already captures a selfie or runs on a kiosk. Use full KYC as the fallback when the age is close to your threshold. Whether document proof is required depends on the applicable jurisdiction or product rule.

4,000+ companies use Didit, with public list pricing. The age gate itself is one call or one workflow step. You do not need a sales call to test it.

What the age gate has to decide

An age gate is not a full identity check. It answers one question: is this person above the age you set? Didit Age Estimation returns a model-predicted age, a passive liveness score, and a warnings array. For the standalone API, Approved requires an empty warnings array, while warning responses are Declined. Hosted workflow sessions can also use statuses such as In Review.

Didit publishes a mean absolute error of 1.1 years for ages 16 and 17 and 1.9 years for ages 18 to 20. The model correctly classifies 96% of selfies as under 18 or 18 and over. That error is why a result close to your threshold is the main reason to fall back to a document.

Keep the decision narrow. If the answer is pass, let the user continue. If the answer is decline because the person is below the threshold, stop the flow. If the answer is decline for image quality or liveness, ask for a retake or route to review. If the answer is near the threshold, use an ID document.

Choose a popup, an API, or a document fallback

Popup with a hosted Didit session

The JavaScript SDK modal and the InContext iframe keep the user on your page. In hosted flows, age estimation is embedded inside the Liveness step. There is no separate age_estimation workflow feature. Enable age estimation on the Liveness node and set age_estimation_decline_threshold, which defaults to 18. The result lives at liveness_checks[].age_estimation in the decision, not in a top-level age array.

Standalone Age Estimation API

This is one multipart POST with a selfie. It returns age and passive liveness in one call, with no ID document. Use it when you already have the image and want a server-to-server decision. The standalone API is billed per completed check: each successful 200 response consumes one Age Estimation credit. Read the Age Estimation API docs for the full schema.

Document fallback with full KYC

A full KYC check is $0.33. That is ID document verification at $0.15, passive liveness at $0.10, face match at $0.05, and device and IP analysis at $0.03. Use it for regulated goods, high-value access, or borderline ages where a selfie estimate is not enough.

Prerequisites

  • A Didit organization and an API key. Sandbox testing is free and unlimited on every plan.
  • An HTTPS page with camera permission for the popup, or a selfie capture path for the API.
  • A workflow with the Liveness step and age estimation enabled for the popup route.
  • A server endpoint that holds the API key. Do not put the key in browser code.
  • A threshold decision, default 18, and a fallback rule for borderline ages.
  • A retention decision: store the session for audit, or set save_api_request=false for a one-off decision.

How to add a popup age gate

  1. Create a workflow in the Didit Business Console. Add the Liveness step, enable age estimation, and set age_estimation_decline_threshold to your age limit. The default is 18.
  2. From your server, create a session with POST /v3/session/. Send workflow_id, vendor_data, and callback. The response includes session.url. See the Create Session API.
  3. Load the JavaScript SDK, @didit-protocol/sdk-web, or use the InContext iframe. The web SDK docs list both routes.
  4. Open the SDK in modal mode with the session URL. The user stays on your page.
  5. Read the decision with GET /v3/session/{sessionId}/decision/ or the webhook. The age result lives at liveness_checks[].age_estimation.
  6. Branch on status and warnings. Send AGE_BELOW_MINIMUM to your underage path. Send AGE_NOT_DETECTED or LOW_LIVENESS_SCORE to a retake. Send a borderline pass to full KYC.

The SDK call for step 4 uses the documented pattern below. Replace the example URL with the session.url from your create-session response.

import { DiditSdk } from '@didit-protocol/sdk-web';

DiditSdk.shared.onComplete = (result) => {
  switch (result.type) {
    case 'completed':
      console.log('Session ID:', result.session?.sessionId);
      console.log('Status:', result.session?.status);
      break;
    case 'cancelled':
      console.log('User cancelled verification');
      break;
    case 'failed':
      console.error('Verification failed:', result.error?.message);
      break;
  }
};

DiditSdk.shared.startVerification({
  url: 'https://verify.didit.me/session/3FaJ9wLqX2Mz'
});
Face verification introduction screen with a start button
The face step introduces the selfie capture before age estimation runs.

How to add an API age gate

Use this route when you already capture a selfie. It is one server-to-server call. It does not require a pre-created workflow session. When save_api_request is true, Didit creates a persisted API-type session.

  1. Capture one front-facing selfie. Allowed types are jpg, jpeg, png, tiff, and webp, max 5 MB. PDFs are not accepted. Submit one face.
  2. Send the image to your server. Keep the Didit API key on the server.
  3. Call POST https://verification.didit.me/v3/age-estimation/ with x-api-key, the image, your threshold, and your storage choice.
    curl -X POST 'https://verification.didit.me/v3/age-estimation/' -H 'x-api-key: YOUR_API_KEY' -F 'user_image=@./selfie.jpg' -F 'age_estimation_decline_threshold=18' -F 'save_api_request=true' -F 'vendor_data=user-1234'
  4. Read the response. The decision is in age_estimation.status, the predicted age in age_estimation.age_estimation, the liveness score in age_estimation.score, and risk codes in age_estimation.warnings.
  5. Apply the decision rule: Approved only when warnings are empty; Declined for age below threshold, low liveness, a presentation attack, no face, or no estimable age.
  6. Store only what you need. Set save_api_request=false to avoid persisting the image and session. Keep the request_id for correlation.
  7. Send borderline results to full KYC.

Expected output

The API returns a request id and an age estimation object. The documented shape is below. Values are abbreviated.

{
  "request_id": "uuid",
  "age_estimation": {
    "status": "Approved or Declined",
    "method": "PASSIVE",
    "age_estimation": "float, years",
    "score": "0-100",
    "user_image": { "entities": [] },
    "warnings": []
  }
}

The standalone API is billed per completed check: each successful 200 response consumes one Age Estimation credit. A 403 with the not-enough-credits error happens before any image processing.

Camera view scanning a user face for liveness and age estimation
Passive liveness and age estimation run on the selfie in the same call.

Inputs and outputs

Age Estimation API fields and popup fields
ModeFieldRequiredWhat it does
APIuser_imageYesSelfie to analyze. jpg, jpeg, png, tiff, or webp up to 5 MB. No PDF.
APIage_estimation_decline_thresholdNoAge limit in years. Default 18.
APIface_liveness_score_decline_thresholdNoPassive liveness cutoff. Default 30.
APIsave_api_requestNoDefault true. Set false for a one-off decision with no stored session.
APIvendor_dataNoYour stable user id for correlation.
APIrotate_imageNoSet true when captures may be sideways or upside down.
Popupworkflow_idYesWorkflow with the Liveness step and age estimation enabled.
Popupvendor_dataRecommendedBinds the session to your user entity.
PopupcallbackNoReturn URL after the hosted flow. Must be on an allowed domain.
Outputrequest_idReturnedCorrelation id. A real session id when save_api_request=true.
Outputage_estimation.statusReturnedApproved or Declined for the API response.
Outputage_estimation.age_estimationReturnedPredicted age in years, or null when age is not detected.
Outputage_estimation.scoreReturnedPassive liveness score from 0 to 100.
Outputage_estimation.warningsReturnedRisk codes such as AGE_BELOW_MINIMUM or LOW_LIVENESS_SCORE.
Outputliveness_checks[].age_estimationPopupAge result on the Liveness entry in the session decision.

Failure cases and recovery

Age verification failure cases and recovery
CaseWhat you seeRecovery
400Missing or oversized image, unsupported extensionValidate before send. Max 5 MB. No PDF. Retake.
403Out of creditsTop up or upgrade. The call stops before processing.
DeclinedAGE_BELOW_MINIMUMReject or send to document fallback.
DeclinedLOW_LIVENESS_SCOREScore is at or below threshold, default 30. Retake, then review.
DeclinedLIVENESS_FACE_ATTACKPresentation attack suspected. Reject and log.
DeclinedAGE_NOT_DETECTEDAge is null. Retake in better light.
DeclinedNO_FACE_DETECTEDNo face found. Retake.
DeclinedMULTIPLE_FACES_DETECTEDMore than one face. Retake alone.
429Shared write budget of 300 requests per minute per API keyBack off and retry.
404Session id not found or belongs to another applicationCheck the session id and the application key.
400 callbackCallback is not on an allowed domainAdd the origin to allowed domains.

Privacy and data minimization

Collect the minimum needed for the gate. If a selfie estimate is enough, do not ask for an ID document. Set save_api_request=false when you only need the decision. With false, nothing is stored, request_id is a one-off correlation UUID, and you cannot look it up later.

With the default true, the call creates a persisted API-type session. It appears in the Business Console, the face crop and reference image are stored, the face embedding is added to your application face index, and a status.updated webhook is emitted. Use this when you need an audit trail or duplicate detection. An unsaved request cannot be retrieved later, so store your own decision record if you set save_api_request=false.

Retention follows your plan. Free keeps 1 year of data and a 30-day audit log. Growth keeps 5 years and a 1-year audit log. Scale keeps up to 10 years and a 3-year audit log with export. Enterprise sets custom retention. The Delete Session API removes a session and its data for erasure requests.

Biometric consent needs care. In Auto consent mode, a user_state of Illinois, Texas, or Colorado makes the flow ask for explicit biometric consent before the first face capture. If you already collected consent, pass biometric_consent with given_at and text_version. GDPR applies in the EU. See Regulation (EU) 2016/679.

Audit trail: keep the request_id or session_id, status, warnings, and decision_trace. A reviewer override is recorded in status_override and decision_trace.
Didit Business Console showing liveness results for a session
The console records the liveness and age result for audit.

Worked cost example

Assume 10,000 age gates a month and a 15% fallback to full KYC for borderline ages.

  • 10,000 Age Estimation checks at $0.10 = $1,000.00.
  • 1,500 full KYC checks at $0.33 = $495.00.
  • List price total = $1,495.00.

On Growth, every Didit price is 4% lower. Age Estimation is $0.096 and full KYC is $0.3168.

  • 10,000 x $0.096 = $960.00.
  • 1,500 x $0.3168 = $475.20.
  • Growth total = $1,435.20. The $115 monthly credit pays the first $115, and a top-up pays $1,320.20.

On the Free plan, the $10 monthly credit buys 100 age checks at $0.10 each for eligible organizations. Sandbox testing is free and unlimited on every plan.

Age Estimation is $0.10 per check and full KYC is $0.33 per check. White label is $0.10 per check. Custom questionnaires are $0.10 per check. Age Estimation returns Approved or Declined. A workflow can still route a session to In Review when you configure manual review. A reviewer can override the status, and the decision trace records the automatic status and the actor. For regulated goods, the review boundary is the document fallback: a selfie estimate is not legal proof of age. The docs say the age is model-predicted from the face, not verified against a document.

Sources

Next step: open the sandbox at business.didit.me, create a workflow with Liveness and age estimation, and run your first test session. No sales call is required.

Try it

Try this in the sandbox

Run the check this guide describes, free.

ID Verification

The product this post is about, taken from its topic. Run it free in the sandbox.

$0.15 per checkStart free

Author

Alberto Rosas

Co-founder and CEO

Alberto Rosas

Alberto Rosas

Co-founder and CEO

About Didit

Questions

Frequently asked questions

How do I add age verification to a website with a popup?

Create a Didit workflow with the Liveness step and age estimation enabled, set age_estimation_decline_threshold, then create a session with POST /v3/session/. Open the returned session.url in the Didit JavaScript SDK modal or the InContext iframe. The user stays on your page, and the age result is read from liveness_checks[].age_estimation in the decision or from the webhook.

Can I add age verification with an API instead of a popup?

Yes. Send one selfie to POST https://verification.didit.me/v3/age-estimation/ with your API key in the x-api-key header. The call returns a predicted age, a passive liveness score, and a warnings array. The standalone API is billed per completed check, and a successful 200 response consumes one Age Estimation credit.

How accurate is Didit Age Estimation?

Didit publishes a mean absolute error of 1.1 years for ages 16 and 17, and 1.9 years for ages 18 to 20. The model correctly classifies 96% of selfies as under 18 or 18 and over. Accuracy is why a borderline result should go to document verification.

What happens when a user is close to the age threshold?

The model error grows near the limit, so do not treat a borderline estimate as a final answer. Route that user to full KYC, which adds ID document verification, passive liveness, face match, and device and IP analysis.

Does Didit store the selfie?

It depends on save_api_request. The default is true, which persists the call as a session, stores the face crop and reference image, and adds the face embedding to your application face index. Set it to false for a one-off decision with no storage. The Delete Session API removes a stored session and its data.

How much does age verification cost?

Didit Age Estimation is $0.10 per check and a full KYC check is $0.33. The Free plan includes $10 of monthly credit for eligible organizations, which buys 100 age checks at list price. Growth is $99 a month with $115 of credit and 4% off every price; Scale is $299 a month with $350 of credit and 10% off. The worked example above shows the arithmetic at volume.

Is a selfie age check legal proof of age?

No. Didit documents Age Estimation as model-predicted from the face, not verified against a document, so it fits age gates and low-friction checks, not legal proof. Use ID document verification when the product or jurisdiction requires document proof.

How do I test age verification without spending credits?

Use the Didit sandbox. Sandbox testing is free and unlimited on every plan. Sandbox API keys skip processing and billing after request validation, and return a static Approved mock payload. Malformed input still returns 400.

Which warnings should I handle?

Handle AGE_BELOW_MINIMUM, AGE_NOT_DETECTED, LOW_LIVENESS_SCORE, NO_FACE_DETECTED, LIVENESS_FACE_ATTACK, and MULTIPLE_FACES_DETECTED. Any warning makes the status Declined; Approved only happens when the warnings array is empty.

How do I audit an age check?

Keep the request_id or session_id, the status, the warnings, and the decision_trace. Audit log retention is 30 days on Free, 1 year on Growth, and 3 years on Scale with export. If you set save_api_request=false, the request id cannot be looked up later, so store your own decision record.

Does the popup work on mobile?

Yes. The JavaScript SDK and the InContext iframe work in mobile browsers, and Didit also documents a WebView route for iOS and Android when a native SDK is not available. The flow needs camera permission. Camera permission and the chosen browser or WebView configuration still need to be validated in your target device matrix.

Can I use age verification for gambling, alcohol, or adult content?

You can use it as a first gate, but check the local rule for the product. Where the rule requires document proof, use full KYC instead of a selfie estimate. Didit covers 220+ countries and 14,000+ document types, and a published price does not establish production availability for every method.

Compliance built in

Audited, certified and attested.

We hold the certifications and build each country's rules into your flows, so you can launch anywhere without worrying. Security and Compliance center

  • Regulation encoded into your flows

    Tell us what you do and where. Didit lists the rules that apply to you, with sources, and builds the checks each country needs into one workflow.

  • Ready for AMLR

    Every requirement of the new EU anti-money laundering rules, from checking customers to human review, is already covered by a Didit check.

  • Tested in Spain's Treasury sandbox

    Spain's Treasury published its supervised sandbox report on Didit's NFC plus active liveness onboarding; SEPBLAC took part and valued the added measures positively.

  • Audited, not self-declared

    iBeta Level 1 and Level 2. Liveness tested under ISO/IEC 30107-3.

Compliance assistant

Your obligations · 3 regions

EU · AMLRCustomer due diligence, human reviewCovered
Illinois, Texas, ColoradoExplicit biometric consentCovered
Germany · Youth protectionVerified adults only (JMStV)Covered
Workflow checked. Every obligation is met
  • SOC 2 Type 2
  • ISO 27001
  • iBeta Level 1 and Level 2
  • EU regulator attestation
  • FSM youth protection
  • GDPR
  • EBA remote onboarding
  • MiCA compatible
  • FIDO Alliance member
  • AMLREU AML Regulation ready

Integration · Didit MCP

Run Didit from your own AI agent

Connect Didit to Claude, Cursor, VS Code or ChatGPT and just ask in plain words. Your agent can do anything you can do in the console, with the same permissions you have.

Add to ClaudeChatGPT
Didit Academy · Lesson 04 · Use Didit with MCP
  • Build workflowsDescribe the checks you need. The agent creates and publishes the flow.
  • Run investigationsAsk why a session was declined, review cases, search people and companies.
  • Change rulesCreate payment rules, test them on past data and switch them on.
  • Pull reportsAsk for numbers, exports or the audit log.

Verify your first user today.

Start free

Free sandbox. Credit applies to work-email sign-ups.