Skip to main content

Server SDK

Didit PHP SDK for identity verification

Create sessions, read decisions and verify webhooks from your PHP server. One Composer package and one key.

$composer require didit-protocol/sdk-php guzzlehttp/guzzle

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 named arguments only to override it. Keep the key on your server.

composer require didit-protocol/sdk-php guzzlehttp/guzzle# 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.

<?phprequire 'vendor/autoload.php';use Didit\DiditClient;$didit = new DiditClient();$session = $didit->sessions->create([    'workflow_id' => '11111111-2222-3333-4444-555555555555',    'vendor_data' => 'user-123',    'callback' => 'https://example.com/verification/done',]);echo $session->url, "\n";

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 the request headers.
On failureverify throws WebhookVerificationException for anything that is not a valid, fresh delivery.
Laravel and SymfonyPass $request->getContent() and $request->headers->all().
Plain PHPPass file_get_contents('php://input') and getallheaders().
PSR-7Pass the request itself as the headers.
Secret rotationWhile you rotate the secret, pass both. [$newSecret, $oldSecret]
Verify
<?phprequire 'vendor/autoload.php';use Didit\DiditClient;use Didit\Exception\WebhookVerificationException;use Didit\Webhooks\Events\StatusUpdatedEvent;use Psr\Http\Message\MessageInterface;$didit = new DiditClient();function handleWebhook(    DiditClient $didit,    string $rawBody,    array|MessageInterface $headers,    string $secret): int{    try {        $event = $didit->webhooks->verify($rawBody, $headers, $secret);    } catch (WebhookVerificationException $e) {        error_log('rejected: ' . $e->reason);        return 400;    }    if ($event instanceof StatusUpdatedEvent) {        error_log($event->sessionId . ' ' . $event->status);    }    return 200;}

Requirements

What you need

Six facts about the SDK.

PHP 8.1 and laterThe package is didit-protocol/sdk-php on Packagist.
Any PSR-18 clientPSR-18 is the PHP standard for HTTP clients. Guzzle is the usual choice.
Arrays in, objects outRequests are one array with the field names the API uses. Responses are read-only objects with toArray().
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 in$didit->webhooks->verify checks the signature and the age of each event.
Release 2.13.2The two Google Wallet endpoints are not in this release yet.

Questions

Questions about the PHP SDK

Which PHP version does the SDK need?
PHP 8.1 or later. It works with any PSR-18 HTTP client, and Guzzle is the usual choice.
Does the PHP SDK work with Laravel?
Yes. To verify a webhook in Laravel or Symfony, pass $request->getContent() and $request->headers->all() to verify. The docs webhooks page also has a Laravel sample.
Where does my API key go?
In the DIDIT_API_KEY environment variable on your server. new DiditClient() reads it. Never put the key in a browser or an app.
How do I install the Didit PHP SDK?
Run composer require didit-protocol/sdk-php guzzlehttp/guzzle. The package is didit-protocol/sdk-php on Packagist, and the source and changelog are in didit-protocol/sdk-php on GitHub. Verifying Authentication tokens also needs the openssl extension. Any PSR-18 HTTP client works, Guzzle is the usual choice.
What do requests and responses look like in the PHP SDK?
Request fields are one array with the Didit API's own field names, such as workflow_id and vendor_data. Responses are read-only objects with camelCase properties, for example sessionId, and a toArray() method. List methods page through every result for you, and uploads take File::fromPath, File::fromBytes or File::fromStream.
How do I handle API errors in PHP?
Catch NotFoundException for a missing resource and ApiStatusException for any other non-2xx response, which carries the status and the requestId. Every Didit exception derives from DiditException, and there are subclasses for 400, 401, 403, 404, 409, 422, 429 and 5xx responses.
Does the PHP 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. Pass timeout and maxRetries to new DiditClient(), or per call with new RequestOptions().
How do I rotate the webhook secret in PHP?
While you rotate it, pass an array with the new secret and the old secret to verify, so deliveries signed with either one are accepted. Pass the raw body exactly as received. With a PSR-7 request, you can pass the request itself as the headers. A rejected delivery throws WebhookVerificationException with a reason.
Can the PHP SDK verify Didit Authentication tokens?
Yes. Authentication::fromPublishableKey() with your publishable key builds a verifier, and verifyAccessToken() checks an access token in your backend without calling Didit for each request. Pass a PSR-16 cache so the issuer's keys are fetched once, not on every request. It throws TokenVerificationException when a token is not valid.
How are the Didit PHP SDK versions numbered?
The PHP 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.