Skip to main content

Server SDK

Didit Go SDK for identity verification

Create sessions, read decisions and verify webhooks from your Go server. One module that uses only the standard library.

$go get github.com/didit-protocol/sdk-go

Install

Install and set your key

Get the module, 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.

didit.NewClient() reads DIDIT_API_KEY on its own. Pass options only to override it. Any option also works on a single call. Keep the key on your server.

go get github.com/didit-protocol/sdk-go# 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.

client := didit.NewClient()session, err := client.Sessions.Create(	context.Background(),	didit.SessionsCreateParams{		WorkflowID: "11111111-2222-3333-4444-555555555555",		VendorData: didit.String("user-123"),		Callback:   didit.String("https://example.com/verification/done"),	},)if err != nil {	log.Fatal(err)}fmt.Println(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 bytes and the request headers, r.Header.
On failurewebhook.Verify returns a *didit.WebhookVerificationError for anything that is not a valid, fresh delivery.
On successA typed event, such as *webhook.StatusUpdatedEvent.
Packagegithub.com/didit-protocol/sdk-go/webhook
Secret rotationWhile you rotate the secret, add the old one with webhook.WithSecrets.
Verify
secret := os.Getenv("DIDIT_WEBHOOK_SECRET")http.HandleFunc("POST /webhooks/didit",	func(w http.ResponseWriter, r *http.Request) {	body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20))	if err != nil {		http.Error(w, "bad body", http.StatusBadRequest)		return	}	event, err := webhook.Verify(body, r.Header, secret)	var invalid *didit.WebhookVerificationError	if errors.As(err, &invalid) {		http.Error(w, string(invalid.Reason), http.StatusBadRequest)		return	} else if err != nil {		http.Error(w, "error", http.StatusInternalServerError)		return	}	if e, ok := event.(*webhook.StatusUpdatedEvent); ok {		fmt.Println(e.SessionID, e.Status)	}	w.WriteHeader(http.StatusOK)})

Requirements

What you need

Six facts about the SDK.

Go 1.22 and laterThe module is github.com/didit-protocol/sdk-go. The package is named didit.
Standard library onlyThe module has no other 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.
Optional fieldsSet them with didit.String, didit.Int, didit.Bool, didit.Float or didit.Some. Leave them out to send nothing.
Webhook checks built inwebhook.Verify checks the signature and the age of each event.
Release 1.25.0Some endpoints are not in this release yet, most of them Travel Rule endpoints. Travel Rule is the rule to share sender and receiver details on crypto transfers.

Questions

Questions about the Go SDK

Which Go version does the SDK need?
Go 1.22 or later. The module uses only the standard library.
Does the Go SDK cover every endpoint?
Not yet. A few endpoints, most of them Travel Rule endpoints, are not in the Go SDK yet. The Go page in the docs lists each one. Call those over HTTP until a later release adds them.
How do I verify a webhook in Go?
Call webhook.Verify with the raw body bytes, the request headers and your webhook secret. It returns a WebhookVerificationError when the event is not valid or not fresh.
How do I install the Didit Go SDK?
Run go get github.com/didit-protocol/sdk-go. The package is named didit; webhooks live in github.com/didit-protocol/sdk-go/webhook, Authentication in the authentication subpackage and client options in option. didit.NewClient() reads DIDIT_API_KEY from the environment, and the source and changelog are in didit-protocol/sdk-go on GitHub.
Which endpoints are not in the Go SDK yet?
Go 1.0.1 has no method yet for address validation, batch transaction delete, the Travel Rule network and wallet proof endpoints, or one of the digital ID wallets. It also cannot send some newer fields, such as biometric_consent, tags and user_state when it creates a session. Until a later Go release adds them, call these over HTTP as each docs page's cURL request shows.
How do I set optional request fields in Go?
Optional request fields in the Didit Go SDK are didit.Opt values. Set them with didit.String, didit.Int, didit.Bool, didit.Float or didit.Some, and leave a field out to send nothing. For example, VendorData: didit.String("user-123") when you create a session.
Does the Go 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 option.WithTimeout and option.WithMaxRetries on the client, or pass any option on a single call.
How do I handle API errors in Go?
Use errors.As with the pointer types. Every Didit error implements the didit.Error interface, for example *didit.NotFoundError for a missing session, and *didit.APIStatusError for any other non-2xx response with its StatusCode, RequestID and Body. An error that matches neither means no response arrived.
How do I rotate the webhook secret in Go?
While you rotate it, add the old secret with webhook.WithSecrets when you call webhook.Verify, so deliveries signed with either secret are accepted. Pass the raw body bytes, not parsed JSON. A *didit.WebhookVerificationError carries a Reason that says why a delivery was rejected.
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 option.WithOrganizationID and option.WithApplicationID to didit.NewClient. 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.

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.