Skip to main content

Didit Node.js SDK on Cloudflare Workers, Deno and Bun

The Didit Node.js SDK runs on Node.js 18, Bun, Deno and edge runtimes with fetch. An edge runtime such as Workers has no process environment, so you pass the API key to the client as an option, while on Bun a client with no.

Didit Node.js SDK on Cloudflare Workers, Deno and Bun

Contents

In this guide

Jump to the part you need.

The Didit Node.js SDK, published as @didit-protocol/sdk-node, runs on Node.js 18, Bun, Deno and edge runtimes that have fetch. It fits teams that keep verification calls next to the app on Cloudflare Workers. The caveat is the environment: an edge runtime such as Workers has no process environment, so you pass the API key to the client as an option instead of relying on DIDIT_API_KEY. The SDK is free, and a full KYC check costs $0.33.

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

Didit Node.js SDK on edge runtimes: the short answers
QuestionAnswer
Package@didit-protocol/sdk-node, installed with npm install @didit-protocol/sdk-node
Supported runtimesNode.js 18, Bun, Deno, and edge runtimes that have fetch
Cloudflare WorkersNo process environment, so the API key is passed to the client as an option
Node.js and BunRead the standard environment variables, so a client with no options is ready to use
Auth on the wirex-api-key header against https://verification.didit.me
SDK priceFree. You pay per completed check, $0.33 for a full KYC
Sandbox priceFree and unlimited on every plan
Cheapest plan to startFree, with $10 of monthly credit for eligible work email sign-ups

Start free in the sandbox at business.didit.me, no sales call. Developers who want an AI assistant to drive the same API can connect Didit through the Didit MCP server, hosted at https://mcp.didit.me/mcp with OAuth sign-in, or hand a coding agent the integration prompt. The per-check prices behind every step below live on didit.me/pricing.

What the Node.js SDK gives you on an edge runtime

The server SDKs are our official libraries for your backend. Each one calls the server endpoints with typed requests and responses, verifies the webhooks Didit sends you, and checks the tokens of Didit Authentication. Use them wherever your code holds a Didit API key: creating verification sessions, reading decisions, calling the standalone APIs, managing users, businesses, workflows and cases, screening transactions and wallets, and the Travel Rule.

The Node.js and TypeScript package is @didit-protocol/sdk-node, on npm with source on GitHub. Its minimum runtime row reads Node.js 18, Bun, Deno, edge runtimes with fetch. That row is why this page exists: making an API call does not need a Node-only module, so the package that runs in a Node process also runs inside a Cloudflare Worker. 4,000+ companies run identity and fraud checks on Didit.

One setting changes. Every SDK reads the same environment variables, so a client created with no options is ready to use. Edge runtimes have no process environment, so there you pass the API key to the Node.js client as an option. Anything you can set through the environment you can also pass to the client, along with the base URL, timeout, retries, default headers and your own HTTP client.

The rest of the integration is unchanged: one call creates the session, one call reads the decision, and one webhook destination delivers status changes back to you. Nothing in that list is Node-specific.

Prerequisites

What you need before the first call
RequirementDetail
RuntimeNode.js 18, Bun, Deno, or an edge runtime with fetch
Package@didit-protocol/sdk-node from npm
PlanFree includes $10 of credit each month for organizations that sign up with a work email. Growth is $99 a month, Scale $299 a month, Enterprise from $15,000 a year. Sandbox testing is free and unlimited on every plan.
Application and keyCreate or copy the key in the Business Console under Developers then API keys. New keys start with sk_live_ or sk_test_ followed by 43 URL-safe characters.
Workflow idThe UUID of the workflow the session runs, from Workflows in the console or POST /v3/workflows/
Key permissionsThe decision endpoint needs read:sessions. A scoped key without access to a resource answers 403.
Organization idsDIDIT_ORGANIZATION_ID and DIDIT_APPLICATION_ID, only for calls under /v3/organization/{organization_id}/application/{application_id}/

Three install routes

  • npm package, the route this page covers. npm install @didit-protocol/sdk-node in a Worker, Deno or Bun project.
  • MCP connector, for AI assistants. The hosted server at https://mcp.didit.me/mcp signs in with OAuth, needs no key in your code, and is free. It is the right route when you want Claude or ChatGPT to call the same API through tools rather than through your source tree.
  • Integration prompt, for coding agents. One prompt that walks an agent from account creation to a working session and webhook.

Set the SDK up in seven steps

  1. Get the API key. Sign in to the Business Console, pick the Application from the dropdown at the top, open Developers then API keys, and copy the Primary key or create a new key for the service. A new key starts with sk_live_ for a live application or sk_test_ for a sandbox application. Keys created before this format have no prefix and keep working, so never validate a key by its prefix.

    The console is optional. Two calls create an organization, a live application and a sandbox application at once:

    curl -X POST https://apx.didit.me/auth/v2/programmatic/register/ \
      -H "Content-Type: application/json" \
      -d '{"email": "you@yourdomain.com", "password": "StrongP@ss1"}'
    
    curl -X POST https://apx.didit.me/auth/v2/programmatic/verify-email/ \
      -H "Content-Type: application/json" \
      -d '{"email": "you@yourdomain.com", "code": "A3K9F2"}'
    # 200 -> { access_token, organization, application: { api_key, mode: "live" },
    #          sandbox_application: { api_key, mode: "sandbox" } }

    Store sandbox_application.api_key as your test key. The register endpoint checks the address first, so reserved test domains come back 400 with email_undeliverable.

  2. Install the package.

    npm install @didit-protocol/sdk-node

    The documented package is @didit-protocol/sdk-node, and Deno and Bun are listed as supported runtimes in the SDK's minimum runtime row, so no build step is specific to this article.

  3. Create the client and pass the key as an option. This is the only line that differs from a Node.js deployment, and it is the one place to follow the Node.js and TypeScript SDK page for the exact constructor and option names. The rule from our docs is short: every SDK reads the same environment variables, so a client created with no options is ready to use on Node.js 18 and Bun, and edge runtimes have no process environment, so there you pass the API key to the client as an option. Deno is listed as a supported runtime. For an edge-style deployment without a process environment, pass the key to the client as an option. The same option route covers the base URL, timeout, retries, default headers and your own HTTP client.

    Keep the key in the runtime's secret store. It is a server-side secret: never place it in a browser bundle or a public repository, and remember that keys you create in the console can be scoped to less than the primary key's full access.

  4. Create a session. sessions.create calls POST https://verification.didit.me/v3/session/. The workflow type decides what kind of session is created, so a KYC workflow creates a user session and a KYB workflow creates a business session. The documented request looks like this:

    curl -X POST https://verification.didit.me/v3/session/ \
      -H "x-api-key: $DIDIT_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"workflow_id": "", "vendor_data": "user-42", "callback": "https://myapp.com/kyc/return"}'

    workflow_id is required. vendor_data is your stable identifier for the person or business and is strongly recommended, because it binds the session to an entity and is used for duplicate detection. callback is where the hosted flow returns: Didit appends ?verificationSessionId=... and status=..., and an http or https callback must sit on one of the application's allowed domains or creation fails with 400.

    The biometric capture step of the hosted verification flow
    The hosted flow the session URL opens: your Worker creates it, Didit renders it.
  5. Read the decision. Path ids are positional arguments, so the client method takes the session id and returns the full decision. The documented API route behind it and the handler pattern both run unchanged on any runtime that has fetch:

    const decision = await (await fetch(url, { headers: { "x-api-key": API_KEY } })).json();
    switch (decision.session_kind) {
    case "user": return handleUserDecision(decision);
    case "business": return handleBusinessDecision(decision);
    }

    Branch on session_kind first, then read status. Feature results are always plural arrays: id_verifications, liveness_checks, face_matches, aml_screenings. A feature that did not run is absent or null, never a placeholder.

    A session overview with its warnings in the Didit Business Console
    The same session in the console: status, warnings and the decision trace behind the API response.
  6. Turn on request logging while you wire it. DIDIT_LOG=debug logs the method, path, status, duration and request id of every request. Bodies and headers are never logged. Where there is no process environment, pass the same setting to the client as an option.

  7. Register the webhook destination and handle the events. One call, then store the secret it returns:

    curl -X POST https://verification.didit.me/v3/webhook/destinations/ \
      -H "x-api-key: $DIDIT_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"label": "Production", "url": "https://app.example.com/didit/webhook",
           "subscribed_events": ["status.updated", "data.updated",
                                 "user.status.updated", "user.data.updated"],
           "webhook_version": "v3"}'

    label and url are required. Save secret_shared_key as DIDIT_WEBHOOK_SECRET and verify the X-Signature-V2 header, which is HMAC-SHA256 of the canonical JSON. De-duplicate on event_id and answer within 5 seconds: a handler that is slower, or that returns 5xx or 404, gets two retries after about 1 and 4 minutes, then the delivery is dropped and can be resent from the destination's delivery log.

Field and event mapping

Configuration: the variable the SDK reads, and what it becomes on an edge runtime
VariableWhat it enablesOn Workers and Deno
DIDIT_API_KEYEvery API key callPass it as a client option using the constructor field documented on the Node.js SDK page, in place of the variable the runtime cannot read.
DIDIT_ORGANIZATION_IDCalls under /v3/organization/{organization_id}/application/{application_id}/: cases, networks, regulatory reports, report templates, and some user and business toolsPass it as a client option; the exact constructor field is documented on the Node.js SDK page. The SDK fills both path ids from the client, so you never pass them per call, and without them those calls fail before any request is sent.
DIDIT_APPLICATION_IDThe same organization routesPass it as a client option, next to the organization id.
DIDIT_LOG=debugMethod, path, status, duration and request id of every request. Bodies and headers are never logged.Pass the same setting to the client where the runtime has no environment.
Base URL, timeout, retries, default headers, your own HTTP clientEverything else the environment can setClient options on every runtime.

On Bun, a client created with no options reads the standard environment variables, so passing the key as an option is optional there.

What you send, what fires, and which field carries the answer
StageField or eventWhat it carries
Create sessionworkflow_idStable workflow UUID. A KYC workflow creates a user session, a KYB workflow creates a business session.
Create sessionvendor_dataYour identifier for the person or business, used for duplicate detection across sessions.
Create sessioncallbackReturn URL for the hosted flow, with the session id and status appended.
Create sessionsandbox_scenarioSandbox applications only. Replays a bundled outcome, and is rejected with 400 on live applications.
Decisionsession_kinduser or business. Always branch on it.
DecisionstatusApproved, Declined, In Review, In Progress, Not Started, Expired, Abandoned, Kyc Expired, Resubmitted, Awaiting User.
Decisionid_verifications, liveness_checks, face_matches, aml_screeningsAlways plural arrays, one item per check that ran.
Webhookstatus.updated, data.updated, user.status.updated, user.data.updatedThe four events a v3 destination subscribes to.
Liveness results for one session in the Didit Business Console
Liveness results for the session your liveness_checks array comes from.

Test with sandbox data, then handle the failures

Use a sandbox application and its sk_test_ key. Sandbox testing is free and unlimited, every check is mocked, and the code does not change: only the key and the secret binding do. To force a specific outcome, read the scenario catalog at GET /v1/sandbox/scenarios/ and pass the slug as sandbox_scenario on create, or arm it afterwards with POST /v3/session/{session_id}/sandbox/arm/ while the session is still Not Started.

Expected success looks like this: sessions.create resolves with session_id, url and session_token; opening url runs the flow; sessions.retrieve_decision returns session_kind plus populated arrays and a status. Then the webhook arrives with the same status, and its X-Signature-V2 header verifies against the destination's shared key.

Edge runtime failures, causes and fixes
SymptomStatus and bodyFix
The key never arrives403, {"detail": "You do not have permission to perform this action."}The option was undefined. Check the secret name the runtime hands to your code: the SDK cannot fall back to a process environment that does not exist.
The key is rejected401, Authentication credentials were not provided or are invalid.Wrong, malformed or revoked key. Copy it again under Developers then API keys.
The key lacks a scope403, This API key has no access to this endpoint.Use a key with that access. Reading a decision needs read:sessions.
Session not found404, Session not found.The session sits outside the key's workflow or status limits, or belongs to another application.
Rate limited429 with a wait field in secondsBack off for that many seconds, then retry.
No credit400 on POST /v3/session/Top up the balance, or finish the build in the sandbox, which is free and unlimited.
Error on our side500, 502 or 503Retry with backoff and read code when present. A 500 may carry no JSON body, so branch on the status.

Disconnect and rotate the key

To rotate, create a new key under Developers then API keys, put it in the runtime's secret store, deploy, then revoke the old key: a revoked key answers 401 like any invalid key. An application you delete answers 403 with application_deleted for a few minutes, and after that its keys are refused like any wrong key, so do not retry that error. If an AI assistant was connected through the MCP connector, remove the connector in that client's settings instead, because it holds an OAuth grant rather than your API key.

What both ends cost

Cost of the Didit side and the runtime side
SideItemPrice
DiditFull ID check: ID document $0.15, passive liveness $0.10, face match 1:1 $0.05, device and IP $0.03$0.33 per completed check
DiditAML screening$0.20 per check
DiditBusiness verification, priced by country and data tierFrom $2.00 per company
DiditNode.js SDK, workflow orchestrator, MCP serverFree
DiditSandbox testingFree and unlimited
Your edge platformRequests, CPU time and egress to verification.didit.meBilled by your platform, not published by Didit

An illustrative example on list prices, with every assumption stated. A team runs 20,000 full KYC checks a month with AML on every check, and onboards 300 businesses with three key people each:

  • KYC: 20,000 x $0.33 = $6,600.00. The unit price is $0.15 + $0.10 + $0.05 + $0.03 = $0.33 per check.
  • AML: 20,000 x $0.20 = $4,000.00.
  • User subtotal: $6,600.00 + $4,000.00 = $10,600.00, which is $0.53 per person.
  • KYB registry, illustrative minimum: 300 x $2.00 = $600.00. This assumes every registry retrieval costs the $2.00 minimum. Business verification is priced by country and data tier, from $2.00 per company, so the real figure is higher wherever a retrieval needs a higher tier.
  • Person AML on 900 people: 900 x $0.20 = $180.00. Linked KYC on the same 900: 900 x $0.33 = $297.00.
  • Business subtotal, illustrative minimum: $600.00 + $180.00 + $297.00 = $1,077.00.
  • Total for the month, illustrative minimum: $10,600.00 + $1,077.00 = $11,677.00.

On Scale every Didit price carries 10% off, so a KYC check is $0.297 and 20,000 checks cost 20,000 x $0.297 = $5,940.00, which is $660.00 less than list on that line alone. The plan fee and the monthly credit that comes with it are listed on the pricing page.

Sources

Start in the sandbox: create an organization at business.didit.me, copy the sk_test_ key, and run your first session from a Worker, a Deno script or a Bun process. No sales call, and the sandbox is free.

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

Does the Didit Node.js SDK run on Cloudflare Workers?

Yes. The minimum runtime for @didit-protocol/sdk-node is Node.js 18, Bun, Deno or an edge runtime with fetch, and Cloudflare Workers provides fetch. The only change is configuration: Workers have no process environment, so the API key goes to the client as an option.

How do I pass the Didit API key on Cloudflare Workers when there is no process.env?

Create the client with the key as an option, taking the value from the Worker's secret store rather than from a process environment. Our docs state the case directly: edge runtimes have no process environment, so the API key is passed to the Node.js client as an option. Keep it server-side, because the primary key has full access to the application while keys you create can be scoped to less.

Does the Didit Node.js SDK work on Deno?

Yes. Deno sits in the SDK's supported runtime row next to Node.js 18, Bun and edge runtimes with fetch. Deno is listed as a supported runtime. For an edge-style deployment without a process environment, pass the key to the client as an option. The calls after that are the same as on Node.js.

Does Bun need the API key passed as an option?

No, although it is allowed. Bun supports the environment variables every SDK reads, so a client created with no options is ready to use there, the same as on Node.js 18. Passing the key as an option also works and keeps one code path across Workers, Deno and Bun.

Which call creates a verification session with the Node.js SDK?

sessions.create, with workflow_id required and vendor_data and callback strongly recommended. It calls POST https://verification.didit.me/v3/session/ and returns session_id, url and session_token. The workflow type decides whether a user or a business session is created, so there is no separate KYB endpoint.

How do I read a decision from the SDK?

sessions.retrieve_decision takes the session id as a positional argument and calls GET /v3/session/{session_id}/decision/. It returns status, session_kind and plural feature arrays such as id_verifications and liveness_checks. Branch on session_kind first, and use a key that holds read:sessions.

Can I use the Didit Node.js SDK in a browser or a mobile app?

No. Server SDKs hold your API key, so they belong on the server. In the browser or a mobile app, use the web and native SDKs instead: they present the verification flow to your user and never hold your API key.

How do I test the integration without spending money?

Use a sandbox application and its sk_test_ key. Sandbox testing is free and unlimited on every plan and every check is mocked, so the same code runs unchanged. Pass sandbox_scenario with a slug from GET /v1/sandbox/scenarios/ to replay a specific outcome, including the failure paths worth testing.

What happens if my webhook handler is slow or returns an error?

If the handler takes longer than 5 seconds, or answers 5xx or 404, Didit retries twice, after about 1 and 4 minutes, then drops the delivery. You can resend it from the destination's delivery log. Verify the X-Signature-V2 header first and de-duplicate on event_id, so a retry does not apply the same decision twice.

What does a full KYC check cost on Didit?

$0.33, made of $0.15 ID document verification, $0.10 passive liveness, $0.05 face match 1:1 and $0.03 device and IP analysis. AML screening is $0.20 on top, so KYC plus AML is $0.53. The Node.js SDK, the workflow orchestrator and the MCP server add nothing to that price.

How do I see what the SDK sends from an edge runtime?

Turn on DIDIT_LOG=debug, or pass the same setting to the client where there is no process environment. The SDK logs the method, path, status, duration and request id of every request, and never logs bodies or headers. That is enough to tell a bad key from a bad workflow id without exposing payloads.

How do I disconnect Didit or rotate the key?

Create a new key under Developers then API keys, deploy it into the runtime's secret store, then revoke the old one: a revoked key answers 401 like any invalid key. If an AI assistant is connected through the MCP connector, remove the connector in that client's settings, since it holds an OAuth grant rather than your API key.

Do I need DIDIT_ORGANIZATION_ID and DIDIT_APPLICATION_ID on Workers?

Only for calls under /v3/organization/{organization_id}/application/{application_id}/, such as cases, networks and regulatory reports. The SDK fills both path ids from the client, so you pass them once as client options rather than on every call. Without them those calls fail before any request is sent.

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.