Skip to main content

Server SDK

Didit .NET SDK for identity verification

Create sessions, read decisions and verify webhooks from your C# server. One NuGet package, with async calls and dependency injection.

$dotnet add package Didit

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 DiditClient() reads DIDIT_API_KEY on its own. Pass DiditClientOptions only to override it. Create one client and reuse it. Keep the key on your server.

dotnet add package Didit# 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="..."# ASP.NET Core dependency injectiondotnet add package Didit.Extensions.DependencyInjection

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.

using System;using Didit;using var client = new DiditClient();var session = await client.Sessions.CreateAsync(new SessionsCreateParams{    WorkflowId = "11111111-2222-3333-4444-555555555555",    VendorData = "user-123",    Callback = "https://example.com/verification/done",});Console.WriteLine(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, exactly as received, and a way to read the request headers.
On failureDiditWebhooks.Verify throws WebhookVerificationException for anything that is not a valid, fresh delivery.
On successA typed event, such as SessionStatusUpdatedEvent.
ASP.NET CoreRead the body with a StreamReader and pass name => request.Headers[name].FirstOrDefault().
Secret rotationWhile you rotate the secret, pass both. new[] { newSecret, oldSecret }
Verify
using System;using Didit;var secret = Environment.GetEnvironmentVariable("DIDIT_WEBHOOK_SECRET") ?? "";int HandleWebhook(string rawBody, Func<string, string?> header){    try    {        var evt = DiditWebhooks.Verify(rawBody, header, secret);        if (evt is SessionStatusUpdatedEvent updated)        {            Console.WriteLine($"{updated.SessionId} {updated.Status}");        }        return 200;    }    catch (WebhookVerificationException error)    {        Console.WriteLine($"rejected: {error.Reason}");        return 400;    }}

Requirements

What you need

Six facts about the SDK.

.NET 8 or .NET Standard 2.0The package is Didit on NuGet. On .NET Framework, use C# 11 or later.
Async callsEvery API method is async.
Dependency injectionAdd Didit.Extensions.DependencyInjection and register the client with services.AddDidit().
Checked when you compileRequired request properties are required, so a missing one fails to compile. Optional ones you leave unset are not sent.
Webhook checks built inDiditWebhooks.Verify checks the signature and the age of each event.
Release 1.25.1The two Google Wallet endpoints are not in this release yet.

Questions

Questions about the .NET SDK

Which .NET versions does the SDK support?
.NET 8 and .NET Standard 2.0. On .NET Framework, use C# 11 or later. Every API method is async.
Does the .NET SDK support dependency injection?
Yes. Add the Didit.Extensions.DependencyInjection package and register the client with services.AddDidit().
How do I verify a webhook in C#?
Call DiditWebhooks.Verify with the raw body, a way to read the request headers and your webhook secret. It throws WebhookVerificationException when the event is not valid or not fresh.
How do I install the Didit .NET SDK?
Run dotnet add package Didit. The package is Didit on NuGet, and the source and changelog are in didit-protocol/sdk-dotnet on GitHub. For ASP.NET Core dependency injection, also add Didit.Extensions.DependencyInjection. new DiditClient() reads DIDIT_API_KEY from the environment, and you should create one client and reuse it.
Does the .NET 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 and MaxRetries in DiditClientOptions, or per call with RequestOptions.
How do I handle API errors in C#?
Catch the typed exceptions. NotFoundException means the resource does not exist, and ApiStatusException covers any other non-2xx response with its StatusCode and RequestId. Every Didit exception derives from DiditException, and there are subclasses for 400, 401, 403, 404, 409, 422, 429 and 5xx responses, so you can catch as narrowly as you need.
What happens if I leave out a required request field in C#?
Your code does not compile. Required request properties in the Didit .NET SDK are marked required, so a missing one fails at build time instead of at runtime. Optional properties you leave unset are not sent to the API at all.
How do I verify a webhook in ASP.NET Core?
In a minimal API, read the raw body with a StreamReader and pass it to DiditWebhooks.Verify with name => request.Headers[name].FirstOrDefault() and your secret. Do not parse the JSON first. While you rotate the secret, pass both: new[] { newSecret, oldSecret }, so deliveries signed with either one are accepted.
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 set OrganizationId and ApplicationId in DiditClientOptions. 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 .NET SDK versions numbered?
The .NET SDK follows semantic versioning and is on 1.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 add the package.

Create accountRead the docs

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