Skip to main content

Server SDK

Didit Node.js SDK for identity verification

Create sessions, read decisions and verify webhooks from your Node.js server. One package, with TypeScript types.

$npm install @didit-protocol/sdk-node

Install

Install and set your key

Install the package, then set one environment variable.

Environment variables

DIDIT_API_KEYNeeded for every call.
DIDIT_ORGANIZATION_IDNeeded for calls scoped to an organization, such as cases, networks and regulatory reports.
DIDIT_APPLICATION_IDNeeded for the same calls, to pick the application.

new Didit() reads DIDIT_API_KEY on Node.js, Bun and Deno. On edge runtimes, pass the key as an option. Keep the key on your server.

npm install @didit-protocol/sdk-node# Every callexport DIDIT_API_KEY="sk_test_..."# Calls scoped to an organization and an application,# such as cases, networks and regulatory reportsexport DIDIT_ORGANIZATION_ID="..."export DIDIT_APPLICATION_ID="..."

Create a session

Create a session

A session is one run of your checks for one person. One call returns the URL to send your user to.

What you send

workflow_idThe workflow to run. A workflow is the set of checks a session runs.
vendor_dataYour own user ID. Didit returns it with every result.
callbackThe page Didit sends the user to after the flow.

What you get back

session.urlhttps://verify.didit.me/session/3FaJ9wLqX2MzSend your user here

Open the URL on the web. The response also carries a session token for the native SDKs.

import Didit from "@didit-protocol/sdk-node";const didit = new Didit();const session = await didit.sessions.create({  workflow_id: "11111111-2222-3333-4444-555555555555",  vendor_data: "user-123",  callback: "https://example.com/verification/done",});console.log(session.url);

Webhook

Verify the webhook

A webhook is a message Didit sends to your server when a result is ready. One call checks that it is real.

InputThe raw body, not parsed JSON, and the request headers.
On failurewebhooks.verify rejects with WebhookVerificationError for anything that is not a valid, fresh delivery.
ExpressRead the body with express.raw({ type: "application/json" }), then call handleWebhook(req.body, req.headers).
HeadersA Node.js or Express req.headers object, a Fetch Headers object or name and value pairs.
Secret rotationWhile you rotate the secret, pass both. [newSecret, oldSecret]
Verify
import {  webhooks,  WebhookVerificationError,  type WebhookHeaders,} from "@didit-protocol/sdk-node";const secret = process.env.DIDIT_WEBHOOK_SECRET ?? "";export async function handleWebhook(  rawBody: Buffer,  headers: WebhookHeaders,): Promise<number> {  try {    const event = await webhooks.verify(rawBody, headers, secret);    if (event.webhook_type === "status.updated") {      console.log(event.session_id, event.status);    }    return 200;  } catch (error) {    if (error instanceof WebhookVerificationError) return 400;    throw error;  }}

Requirements

What you need

Six facts about the SDK.

Node.js 18 and laterThe package is @didit-protocol/sdk-node on npm.
Bun, Deno and edge runtimesAny runtime with fetch. Deno needs --allow-env to read the key.
ESM and CommonJSBoth builds ship in the package. It has no runtime dependencies.
Typed calls to the server APIsSessions, standalone checks, transactions and more. Errors are typed, so your code can tell a missing session from a rate limit.
Webhook checks built inwebhooks.verify checks the signature and the age of each event.
Release 2.22.0The two Google Wallet endpoints are not in this release yet.

Questions

Questions about the Node.js SDK

Which runtimes does the Node.js SDK support?
Node.js 18 and later, Bun, Deno and edge runtimes with fetch. The package ships ES module and CommonJS builds and has no runtime dependencies.
Does the Node.js SDK work with TypeScript?
Yes. It is the official library for Node.js and TypeScript. Requests and responses are typed, and request fields keep the names the API uses.
How do I verify a webhook in Node.js?
Call webhooks.verify with the raw body, the request headers and your webhook secret. It rejects with WebhookVerificationError when the event is not valid or not fresh.
How do I install the Didit Node.js SDK?
Run npm install @didit-protocol/sdk-node. The package is @didit-protocol/sdk-node on npm, with its source and changelog in didit-protocol/sdk-node on GitHub. Import it with import Didit from "@didit-protocol/sdk-node", or with CommonJS use const { Didit } = require("@didit-protocol/sdk-node").
How do I pass the API key on an edge runtime?
Pass it as an option, because edge runtimes have no process environment: new Didit({ apiKey: env.DIDIT_API_KEY }). On Node.js, Bun and Deno (with --allow-env), new Didit() reads DIDIT_API_KEY from the environment by itself. Keep the key on your server, never in a browser or app.
Does the Node.js SDK retry failed requests?
Yes. Every Didit server Software Development Kit (SDK) retries a failed request up to 2 times, with exponential backoff from 0.5 seconds (at most 8 seconds), and honours Retry-After. POST and PATCH are retried only on 429 or when the connection failed before sending, so a retry never creates a second session. The default timeout is 60 seconds. Set timeout (in milliseconds) and maxRetries on the client, or per call with didit.withOptions().
How do I handle API errors in Node.js?
Check the error class. NotFoundError means the resource does not exist, RateLimitError means a 429 and carries the requestId, and APIStatusError covers any other non-2xx response with its status and body. Every Didit error derives from DiditError, and APIConnectionError or APITimeoutError means no response arrived.
How do I rotate the webhook secret in Node.js?
Pass both secrets while you rotate: [newSecret, oldSecret]. webhooks.verify then accepts a delivery signed with either one. With Express, read the body with express.raw({ type: "application/json" }) so you pass the raw body, not parsed JSON, together with req.headers.
Which calls need the organization and application ids?
Application-scoped calls such as regulatory reports need them. Set DIDIT_ORGANIZATION_ID and DIDIT_APPLICATION_ID in the environment, or pass organizationId and applicationId to new Didit(). The Didit SDK fills both path ids for you, so you never pass them per call. Without them those calls fail with a configuration error before any request is sent.
How are the Didit Node.js SDK versions numbered?
The Node.js SDK follows semantic versioning and is on 2.x. A change that mirrors the Didit API ships as a minor release, even when it can break typed code, and the release notes list it under "API changes that can break typed code". A major version is only for a change to the SDK's own design. Each repository's CHANGELOG.md lists every release.

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.

  • Trusted by EU regulators

    After a year of supervised testing, EU financial regulators confirmed that verifying with Didit is safer than checking an ID in person.

  • 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.

Start

Install the SDK

Create an account, get your sandbox key and install the package.

Create accountRead the docs

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