Getting Started with Xident

Xident is a backend-first integration: your server creates a verification session, sends the user to the Xident widget, and reads the result back — all with your secret key. No frontend SDK required.

How it works

  1. Your backend calls POST /verify/v1/init and gets a verify_url that works for 10 minutes.
  2. You redirect the user to that verify_url (the Xident widget).
  3. The user verifies (liveness, age check, and/or document capture).
  4. Xident redirects back to your callback_url with a result token.
  5. Your backend calls GET /verify/v1/result/{token} to read the outcome.

Prerequisites

  • A Xident account (sign up here)
  • A project with a secret API key (sk_live_…)
  • A callback URL on your domain (HTTPS required in production; http://localhost allowed in development)

Step 1: Get your secret key

  1. Log in to dashboard.xident.io
  2. Click "New Website", enter your domain, choose the content category of your site, then click "Create Website". The category turns on Auto Mode: Xident uses the minimum age of the local rules in each visitor's country.
  3. Copy your secret key (sk_live_…) and store it as a server-side environment variable — never expose it in client-side code

One key for the whole flow

The secret key (sk_live_) authenticates both POST /verify/v1/init and GET /verify/v1/result/{token} via the X-API-Key header. Your project also has a public key (pk_live_). Only the Xident widget uses it: it cannot start a verification and cannot read a result. See Core Concepts.

Step 2: Create a verification session (backend)

When the user starts verification, your backend calls POST /verify/v1/init and redirects them to the returned verify_url. Every setting of the verification comes from this call: the browser cannot change it. user_id is required. In Auto Mode, leave min_age out: Xident uses the minimum age of the local rule. Without a content category, send min_age, an age from 12 to 25. If you send it in Auto Mode, it can only raise the local rule's age. See Minimum age and Auto Mode and Init options.

Node.js

// Backend route: create a verification session with your SECRET key,
// then send the user to the returned verify_url.
app.get('/start-verification', async (req, res) => {
  const response = await fetch('https://api.xident.io/verify/v1/init', {
    method: 'POST',
    headers: {
      'X-API-Key': process.env.XIDENT_SECRET_KEY, // sk_live_...
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      callback_url: 'https://yoursite.com/verified',
      user_id: String(req.user.id), // required: your own id for this person, from your login session
      // No min_age: in Auto Mode (a content category) Xident uses the local
      // rule's minimum age. Without a content category, add min_age: 12 to 25.
    }),
  });

  const { data, error } = await response.json();
  if (!response.ok) {
    // For example 400 INVALID_MIN_AGE: see the Integration Guide for every code.
    return res.status(502).send('Could not start the verification: ' + error?.code);
  }
  // data.verify_url = https://verify.xident.io?t=xit_...
  res.redirect(data.verify_url);
});

Python

# Backend route: create a verification session with your SECRET key,
# then send the user to the returned verify_url.
@app.route('/start-verification')
def start_verification():
    response = requests.post(
        'https://api.xident.io/verify/v1/init',
        headers={'X-API-Key': os.environ['XIDENT_SECRET_KEY']},  # sk_live_...
        json={
            'callback_url': 'https://yoursite.com/verified',
            'user_id': str(current_user.id),  # required: your own id for this person, from your login session
            # No min_age: in Auto Mode (a content category) Xident uses the local
            # rule's minimum age. Without a content category, add 'min_age': 12 to 25.
        },
    )
    body = response.json()
    if not response.ok:
        # For example 400 INVALID_MIN_AGE: see the Integration Guide for every code.
        return f"Could not start the verification: {body['error']['code']}", 502
    # body['data']['verify_url'] = https://verify.xident.io?t=xit_...
    return redirect(body['data']['verify_url'])

curl

curl https://api.xident.io/verify/v1/init \
  -X POST \
  -H "X-API-Key: sk_live_your_secret_key" \
  -H "Content-Type: application/json" \
  -d '{"callback_url": "https://yoursite.com/verified", "user_id": "user-123"}'

The response contains the init token and the URL to send the user to:

{
  "success": true,
  "data": {
    "token": "xit_9f8e7d6c5b4a39281706f5e4d3c2b1a0",
    "verify_url": "https://verify.xident.io?t=xit_9f8e7d6c5b4a39281706f5e4d3c2b1a0"
  }
}

Step 3: The user verifies

After you redirect the user to verify_url, they complete verification on verify.xident.io. You don't build any UI — the widget handles liveness, age estimation, and document capture as required.

Step 4: Handle the callback

When verification finishes, Xident redirects the user back to your callback_url with query parameters:

https://yoursite.com/verified?token=xtk_abc123&status=success

The token here is the result token (xtk_…), which is different from the init token (xit_…) carried in the verification URL as ?t=. Pass this xtk_ token to the result endpoint in Step 5.

Callback parameters

ParameterDescription
tokenResult token (xtk_…) — pass to GET /verify/v1/result/{token}
statussuccess, failed, or canceled
user_idThe user_id you sent to init

The callback only ever reports a terminal verdict (one of the three values above) — the API result's status field has a wider set covering the whole session lifecycle; see Core Concepts → Result Status Values.

Step 5: Fetch the result (backend)

Always read the result server-side with your secret key — never trust the callback status alone.

Compare checks.age.gate with a constant on your server: the lowest age your website accepts in any country. Your key can read the result token of any website of your account, and the result does not say which website it came from. If your website has its own minimum age, send it as min_age at init, or save it on the website, and compare gate with it. Do not require checks.age.passed: it is false when a returning person's Xident account proved the age.

Node.js

// The lowest minimum age your website accepts in any country.
const LOWEST_AGE = 18;

app.get('/verified', async (req, res) => {
  // token is the RESULT token (xtk_...) returned on the callback.
  const { token, status } = req.query;

  if (status === 'canceled') return res.redirect('/verification-canceled');
  if (status !== 'success') return res.redirect('/verification-failed'); // status === 'failed'

  try {
    const response = await fetch(
      'https://api.xident.io/verify/v1/result/' + token,
      { headers: { 'X-API-Key': process.env.XIDENT_SECRET_KEY } } // sk_live_...
    );

    const { success, data } = await response.json();

    // data.verified is the verdict, computed server-side from data.status;
    // never trust the callback's status query param alone. The result must
    // also be live (not test) and belong to the signed-in user.
    // Auto Mode can raise the age per country, and gate is the age that was
    // checked. A result token of any website of your account can be read with
    // this key, so always compare gate with your own lowest age.
    const gate = data?.checks?.age?.gate;
    if (success && data.verified && data.test !== true
        && data.external_user_id === String(req.user.id)
        && Number.isInteger(gate) && gate >= LOWEST_AGE) {
      req.session.ageVerified = true;
      return res.redirect('/content');
    }
  } catch (error) {
    console.error('Verification error:', error);
  }

  return res.redirect('/verification-failed');
});

Python

# The lowest minimum age your website accepts in any country.
LOWEST_AGE = 18

@app.route('/verified')
def handle_verification():
    token = request.args.get('token')   # RESULT token (xtk_...) from the callback
    status = request.args.get('status')

    if status == 'canceled':
        return redirect('/verification-canceled')
    if status != 'success':  # status == 'failed'
        return redirect('/verification-failed')

    response = requests.get(
        f'https://api.xident.io/verify/v1/result/{token}',
        headers={'X-API-Key': os.environ['XIDENT_SECRET_KEY']},  # sk_live_...
    )

    body = response.json()

    # data['verified'] is the verdict, computed server-side from
    # data['status']; never trust the callback's status query param alone.
    # The result must also be live (not test) and belong to the signed-in user.
    # Auto Mode can raise the age per country, and gate is the age that was
    # checked. A result token of any website of your account can be read with
    # this key, so always compare gate with your own lowest age.
    data = body.get('data') or {}
    gate = (data.get('checks') or {}).get('age', {}).get('gate')
    if (body.get('success') and data.get('verified') and data.get('test') is not True
            and data.get('external_user_id') == str(current_user.id)
            and isinstance(gate, int) and gate >= LOWEST_AGE):
        session['age_verified'] = True
        return redirect('/content')

    return redirect('/verification-failed')

Verification response

The result endpoint returns the Xident API envelope:

{
  "success": true,
  "data": {
    "token": "xtk_golden0001",
    "status": "success",
    "verified": true,
    "verification_type": "full",
    "ip_country": "DE",
    "external_user_id": "cust-4711",
    "checks": {
      "liveness": { "performed": true, "passed": true },
      "age": { "performed": true, "passed": true, "gate": 21 },
      "document": { "performed": true, "passed": true, "document_type": "passport", "country": "DE" },
      "face_match": { "performed": true, "passed": true },
      "eu_wallet": { "performed": false, "passed": false },
      "aml": { "performed": false, "passed": false }
    },
    "risk": { "band": "low" },
    "created_at": "2026-08-03T10:00:00Z",
    "completed_at": "2026-08-03T10:02:30Z",
    "expires_at": "2026-08-03T10:15:00Z"
  },
  "meta": {
    "request_id": "req_xyz789",
    "timestamp": "2026-08-03T10:02:31Z"
  }
}

data.status is a verdict, not a lifecycle marker, but data.verified is the one field to branch on for access control (a boolean, derived server-side from status). Right after a callback fires you will normally see status as success, failed, or canceled, but the field has a wider set of values covering the whole session lifecycle: see Core Concepts → Result Status Values for the full list. The checks object carries the detail of each method, each with performed and passed booleans: liveness, age, document and face_match. checks.age.gate is the minimum age the session checked, exact (19 stays 19); it is absent for an ID verification, which checks no age. This same object is delivered byte for byte in the session.success webhook (see Core Concepts) and in every backend SDK's result object. See the API Reference for the full schema.

Testing

Create a second project with Test mode key switched on in the dashboard. Its secret key starts with sk_test_ and works like a live key for starting verifications and reading results, with one difference: a test session gets its result as soon as the widget opens the link, with no camera step, and is never billed.

  • A test session passes. To force a failure, end the user_id with +fail (for example user-123+fail). It then fails with reason test_mode.
  • A test result carries test: true. Never grant access on it.
  • http://localhost:* callback URLs are accepted (no HTTPS required)
  • Use a second project to keep staging traffic and webhooks separate from production

On the Free plan, live keys spend a one-time credit rather than a card, against the same API. See Core Concepts → Environments for the full testing matrix.

Next Steps