Basics

Guides

Quickstart

A first identity verification in test mode — a flow, a session, the hosted page, the webhook and the decision.

You need a test key (dc_test_…) and Node.js 20 or later.

npm install @didconnect/sdk

1. Create a flow

A flow says what to verify: a kind (kyc or kyb), a level, and how the decision is made.

import { DidConnect } from '@didconnect/sdk';

const dc = new DidConnect({ apiKey: process.env.DIDCONNECT_API_KEY! });

const flow = await dc.verify.flows.create({
  name: 'Borrower onboarding',
  kind: 'kyc',
  level: 'l2',
  decision_mode: 'auto_review',
  allowed_countries: ['US'],
  success_url: 'https://app.harborlending.com/verified',
  failure_url: 'https://app.harborlending.com/verify-failed',
});

2. Start a session

const session = await dc.verify.sessions.create({
  flow_id: flow.id,
  subject: { reference: 'cus_10442', display_name: 'Emily Carter', country: 'US' },
});

session.url;          // the hosted page, for the person
session.client_token; // returned once: give it to your web page, never store it

3. Send the person to the page

Redirect the person to session.url. The page is hosted by Connect, works on a phone and a desktop, and returns to success_url or failure_url when the person is done.

The person photographs their document, takes a selfie and submits. The checks run in the background; the session moves to processing, then to a decision.

4. Receive the decision

app.post('/webhooks/didconnect', express.raw({ type: 'application/json' }), (req, res) => {
  const event = dc.webhooks.verify(req.body, req.headers, process.env.DIDCONNECT_WEBHOOK_SECRET!);
  if (event.type === 'verify.session.approved') {
    // event.data.subject_reference === 'cus_10442'
  }
  res.sendStatus(200);
});

A session in the grey zone goes to review and waits for a reviewer in the dashboard, or for dc.verify.sessions.decide(id, { decision, note }).

5. Read the result

const done = await dc.verify.sessions.get(session.id);
done.status; // 'approved'
const checks = await dc.verify.sessions.checks(session.id);

Next: monitor the customer's first transfer with LENS.

On this page