Skip to main content

OAuth 2.0 Client Credentials Flow for Didit API Access in Python

Didit has no OAuth 2.0 client credentials grant. Verification calls send a long-lived API key in the x-api-key header; account calls send a JWT from email login. Python code inside.

OAuth 2.0 Client Credentials Flow for Didit API Access in Python

Contents

In this guide

Jump to the part you need.

This page is for backend developers who need server-to-server access to Didit with no browser in the loop. The short answer: Didit has no OAuth 2.0 client credentials grant. Verification calls at verification.didit.me authenticate with a long-lived API key in the x-api-key header, and account calls at apx.didit.me use a JWT access token from an email and password login. Sandbox testing 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.

At a glance

Didit API authentication in one table
ItemValueDetail
Verification API hosthttps://verification.didit.meSessions, workflows, entities, transactions, standalone APIs, lists, webhooks, billing, every /v3/... route
Verification auth headerx-api-key: <api_key>Long-lived key, server side only. No Bearer token on this host
Account API hosthttps://apx.didit.me/auth/v2Organizations, applications, credentials, programmatic registration
Account auth headerAuthorization: Bearer <access_token>JWT from POST /programmatic/login/
Where the key comes fromPOST /programmatic/verify-email/Also readable from the application record and in the console under Developers, API keys
Key formatNew keys: sk_live_ or sk_test_ plus 43 URL-safe charactersOlder keys may have no prefix and keep working, so never judge a key by its prefix
Python SDKpip install didit-sdkPython 3.10 or newer
SandboxFree and unlimitedEvery check is mocked and never billed, so a sandbox key never creates a billed verification
Full KYC price$0.33 per completed checkID $0.15 + passive liveness $0.10 + face match 1:1 $0.05 + device and IP $0.03

Start free in the sandbox at business.didit.me, with no sales call. Every module price is on didit.me/pricing, and the host and header rules this page follows are in the Didit docs on API authentication. Developers who would rather have an AI assistant write the integration can connect one through the Didit MCP server.

Why there is no client credentials grant on the Didit API

The OAuth 2.0 client credentials grant exists for one job: a machine trades its own client ID and secret for a short-lived token, with no user in the loop. Didit splits that job across two hosts with two schemes, and only one of them is token based.

On the verification host there is no third party to authorize. You call Didit as your own application, so the application's key travels on every request. On the account host you act as a person who manages organizations and applications, so you sign in and carry a JWT. Sending the JWT to the verification host, or the api_key to the auth host, is a credential mismatch and it fails.

Host map: which credential goes where
HostSurfaceAuth header
https://verification.didit.meVerification API: sessions, workflows, entities, transactions, standalone APIs, lists, webhooks, billing (every /v3/... route)x-api-key: <DIDIT_API_KEY>
https://apx.didit.meAccount, organization and application management (/auth/v2/programmatic/..., /auth/v2/organizations/...)Authorization: Bearer <JWT access_token>

The OAuth flow documented in Didit's materials is on the hosted MCP server, which is a different surface from the API in this guide. The last section of this page covers it and states exactly how far that flow reaches.

Prerequisites

  • Python 3.10 or newer if you plan to use didit-sdk.
  • A Didit organization and at least one application. The console creates the first application at sign up; the Auth API creates them without a browser.
  • A real, deliverable email address if you register programmatically. Reserved test domains such as @example.com and @*.test are refused with 400 and "code": "email_undeliverable" before anything is created.
  • The workflow_id of the workflow the session should run.
  • Environment variables: DIDIT_EMAIL, DIDIT_PASSWORD, DIDIT_ORG_ID, DIDIT_APP_ID, and DIDIT_WORKFLOW_ID for the session call.

Step by step in Python

  1. Decide which host each call belongs to. Credential and organization calls go to apx.didit.me/auth/v2. Anything that creates or reads a verification goes to verification.didit.me/v3.
  2. Create the account. Programmatic registration is two calls: POST /programmatic/register/ with an email and a password of at least 8 characters containing an uppercase letter, a lowercase letter, a digit and a special character, then POST /programmatic/verify-email/ with the 6-character code from the email. The code is valid for 10 minutes.
  3. Keep the sandbox key and the live key apart. The verification response carries application (mode live) and sandbox_application (mode sandbox), each with its own api_key and client_id. Persist the sandbox key as DIDIT_API_KEY while you build, because a sandbox key never creates a billed check.
  4. Log in when you need an access token. POST /programmatic/login/ with the same email and password returns a JWT access_token. Use it only on the auth host.
  5. Read the application record to recover the key. GET /organizations/me/{org_id}/applications/{app_id}/ returns client_id, api_key, data_location and the product switches on every call. There is no show once model, so a lost key is a read, not a support ticket.
  6. Call the verification API with the key. Send POST https://verification.didit.me/v3/session/ with x-api-key, a workflow_id, your vendor_data and a callback URL.

First run: create the account with two calls

import os
import requests

AUTH = 'https://apx.didit.me/auth/v2'

# 1) Register. Didit emails a 6-character code, valid for 10 minutes.
requests.post(
    f'{AUTH}/programmatic/register/',
    json={'email': os.environ['DIDIT_EMAIL'], 'password': os.environ['DIDIT_PASSWORD']},
    timeout=30,
).raise_for_status()

# 2) Verify the email. The response carries the organization and both applications.
code = input('6-character code from the email: ')
resp = requests.post(
    f'{AUTH}/programmatic/verify-email/',
    json={'email': os.environ['DIDIT_EMAIL'], 'code': code},
    timeout=30,
)
resp.raise_for_status()
creds = resp.json()
print(creds['sandbox_application']['api_key'])  # free, every check mocked
print(creds['application']['api_key'])          # live, billed from your balance

The full runnable example

Once you have credentials, this is the whole loop: log in, read the application record, create a session.

import os
import requests

AUTH = 'https://apx.didit.me/auth/v2'
API = 'https://verification.didit.me'


def login() -> str:
    '''Exchange email and password for a JWT. Auth host only.'''
    resp = requests.post(
        f'{AUTH}/programmatic/login/',
        json={
            'email': os.environ['DIDIT_EMAIL'],
            'password': os.environ['DIDIT_PASSWORD'],
        },
        timeout=30,
    )
    resp.raise_for_status()
    return resp.json()['access_token']


def read_application(access_token: str) -> dict:
    '''Return the application record, including api_key.'''
    resp = requests.get(
        f"{AUTH}/organizations/me/{os.environ['DIDIT_ORG_ID']}/applications/{os.environ['DIDIT_APP_ID']}/",
        headers={'Authorization': f'Bearer {access_token}'},
        timeout=30,
    )
    resp.raise_for_status()
    return resp.json()


def create_session(api_key: str) -> dict:
    '''Create a verification session on the verification host.'''
    resp = requests.post(
        f'{API}/v3/session/',
        headers={'x-api-key': api_key, 'Content-Type': 'application/json'},
        json={
            'workflow_id': os.environ['DIDIT_WORKFLOW_ID'],
            'vendor_data': 'user-42',
            'callback': 'https://myapp.com/return',
        },
        timeout=30,
    )
    resp.raise_for_status()
    return resp.json()


if __name__ == '__main__':
    token = login()
    app = read_application(token)
    print(app['client_id'], app['data_location'])
    session = create_session(app['api_key'])
    print(session)

Two details matter. The api_key you read belongs to one application and one environment, so read the sandbox application while you test and the live application when you go live. Environment comes from the application, not from the key prefix: new sandbox keys start with sk_test_ and new live keys start with sk_live_, while older keys may have no prefix and still work.

callback is the return URL for the person who finishes the hosted flow. It is not a webhook destination. To receive results on your server you configure a webhook at Developers, Webhooks in the console, or through the webhooks API, as described in the webhook documentation.

A session in the Didit Business Console showing its status and warnings
The session your Python call creates appears in the Business Console with its status, checks and warnings.

Expected output

The login call returns JSON with an access_token. The application record returns the documented application object, trimmed here:

{
  "uuid": "b2c3d4e5-6789-...",
  "name": "My App",
  "client_id": "S9LIYGSoWNuGMLHsvEt9dQ",
  "api_key": "sk_live_example_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "website_url": "https://example.com",
  "data_location": "eu",
  "products": [
    { "product": "identity", "status": "enabled",
      "modules": { "user_verification": true, "business_verification": true, "case_management": true } },
    { "product": "transactions", "status": "disabled",
      "modules": { "travel_rule": true, "case_management": true } },
    { "product": "authentication", "status": "disabled", "modules": {} }
  ]
}

The session call returns the new session as JSON, and that session then appears in the Business Console with its checks and warnings. With a sandbox application the checks are mocked and nothing is charged. Result delivery is a separate setup: a webhook destination you configure yourself, not something the session response does for you. The webhook documentation covers registering that destination for status updates.

Failure cases and recovery

Didit auth failures and what to do about them
StatusWhereMeaningRecovery
401verification.didit.mex-api-key is wrong, malformed, revoked or expiredFix the key first: re-read it from the application record or create a new one under Developers, API keys, then retry
403verification.didit.meNo x-api-key header, a scoped key without access to this resource or action, or a call from an address outside the key's IP listUse a key with that access
403 with application_deletedverification.didit.meThe key's application was deletedDo not retry. Use a key of an application that exists
404session routesThe session is outside the key's workflows or statusesUse a key whose limits include that session
403apx.didit.meThe JWT Authorization header is missing or expiredCall POST /auth/v2/programmatic/login/ again
402verification.didit.meThe check could not be paid for, so it did not runTop up the balance
429verification.didit.meA rate limit was reachedWait for the Retry-After header, then retry
429apx.didit.meA rate limit or quota was reached, for example more than 5 registrations from one IP in an hourRead the wait field in the body, in seconds, wait that long, then retry
400 with email_undeliverableregistrationThe address cannot receive the codeUse a real inbox
409verification.didit.meA reused Idempotency-Key, or a step that already ranRead code and reload the state

A wrong or expired key returns 401, and a missing key returns 403. That pair tells you whether to replace a credential or to send one at all.

Rate limits and retries

Didit answers 429 when a rate limit or a quota is reached, and the field that tells you how long to wait depends on the host you called.

Which wait field a 429 carries, by host
HostContextField to read
verification.didit.meRate limit on the verification APIRetry-After response header
apx.didit.meAuthentication and registration flows, where a limit is documentedwait in the JSON body, in seconds

Wait the stated time before the next attempt, and add backoff on repeated limits instead of retrying immediately. A 401 is not a rate limit: do not retry until you fix the key, then retry. 403 with application_deleted, 404 and 410 need a change to the request, not another call. 500 and 502 are worth retrying with backoff.

Inputs and outputs

Every call in this guide, with its credential and payload
EndpointCredentialInputsOutputs
POST /auth/v2/programmatic/register/Noneemail, passwordConfirmation message; a 6-character code is emailed
POST /auth/v2/programmatic/verify-email/Noneemail, codeaccess_token, refresh_token, organization, application, sandbox_application
POST /auth/v2/programmatic/login/Email and passwordemail, passwordaccess_token (JWT)
GET /auth/v2/organizations/me/{org_id}/applications/{app_id}/Bearer JWTorg_id, app_idclient_id, api_key, data_location, products, redirect_uris
POST /v3/session/x-api-keyworkflow_id, vendor_data, callbackThe created session

The official Python SDK route

If you would rather not write the HTTP layer, install didit-sdk with pip on Python 3.10 or newer. Every SDK reads the same environment variables: DIDIT_API_KEY for API key calls, DIDIT_ORGANIZATION_ID and DIDIT_APPLICATION_ID for the organization scoped routes, and DIDIT_LOG=debug to log method, path, status, duration and request id. The account methods call https://apx.didit.me/auth/v2 and never send your API key: you sign in with account.login and pass the returned token to the client as its account token. Verification calls follow the API's resources, for example sessions.create and sessions.retrieve_decision. Create one client per process and share it; it keeps a connection pool and is safe to use from several threads.

Nothing on the auth host bills. Registration, login, reading an application record and recovering a key are free. Billing happens per completed check on the verification host, from prepaid credit.

  • Sandbox testing is free and unlimited. Every check is mocked, and a sandbox key never creates a billed verification.
  • Live full KYC: $0.33 per completed check (ID $0.15, passive liveness $0.10, face match 1:1 $0.05, device and IP $0.03).
  • AML screening: $0.20 per check. Ongoing AML monitoring: $0.07 per person per year.
  • Wallet screening: $0.15 per screening. Transaction monitoring: $0.001 per transaction beyond the plan's monthly allowance.
  • Reusable KYC, the Workflow Orchestrator and the MCP server carry no separate fee.

Review boundaries are simple here: the calls in this guide never create a check, so nothing in this flow bills and nothing in this flow moves a person through a queue. Billing starts at the first completed check on the verification host.

Didit billing: credits, auto-recharge and volume discounts
Credits, auto-recharge and plan discounts, the side of the account that decides what a verification costs.

Worked cost example

Take a month with 2,000 full KYC checks, 2,000 AML screenings and 500 wallet screenings, all on the Growth plan. The assumptions all come from the published Growth plan: the $99.00 monthly fee, the $115.00 of monthly credit and the 4% discount on every Didit price. Nothing else is assumed.

At list price: 2,000 x $0.33 = $660.00 for KYC. 2,000 x $0.20 = $400.00 for AML screening. 500 x $0.15 = $75.00 for wallet screening. Total $1,135.00.

With the Growth plan assumptions: KYC 2,000 x $0.3168 = $633.60. AML 2,000 x $0.192 = $384.00. Wallet 500 x $0.144 = $72.00. Subtotal $1,089.60. Minus $115.00 of plan credit = $974.60. Plus the $99.00 monthly fee = $1,073.60 for the month.

The authentication work in this guide adds $0.00 to both totals, because no auth call is a billable check.

If an AI agent runs the integration

Didit ships an MCP server at https://mcp.didit.me/mcp that signs in with OAuth 2.1, so an assistant can create workflows, sessions and webhooks on your behalf. Keep tool-call approval on, especially for write and delete actions, because the agent acts with your console role's permissions.

OAuth 2.1 applies to the hosted MCP resource server, where the Business Console is the authorization server. It does not apply to verification API authentication: the verification API does not accept OAuth Bearer tokens, and every call to verification.didit.me/v3/... uses the x-api-key header described on this page.

Connecting the Didit MCP server to an AI assistant
Use Didit with MCP: sign in once, then let the agent call the same endpoints your Python code calls.

Add Didit to Claude · Connect ChatGPT to Didit · MCP setup for every client

Sources

Next step: open business.didit.me and start in the sandbox. No sales call, and sandbox testing is free and unlimited while you wire up the Python code above.

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

Alejandro Rosas

Co-founder and CTO

Alejandro Rosas

Alejandro Rosas

Co-founder and CTO

About Didit

Questions

Frequently asked questions

Does Didit support the OAuth 2.0 client credentials flow?

No. Didit has no token endpoint that trades a client ID and client secret for a bearer token on verification traffic. The verification API at https://verification.didit.me/v3/... authenticates every request with a long-lived API key in the x-api-key header. The account host issues JWT access tokens, but from an email and password login, not from a client credentials grant.

What header does the Didit verification API expect?

x-api-key: <your api_key>. The key belongs to one application and one environment, so a sandbox key never creates a billed verification. New sandbox keys start with sk_test_ and new live keys start with sk_live_, while older keys may have no prefix and still work.

How do I get a Didit API key in Python without the console?

Two calls on the auth host. Post the email and password to POST https://apx.didit.me/auth/v2/programmatic/register/, then post the 6-character code from the email to POST .../programmatic/verify-email/. The response carries application.api_key for live traffic and sandbox_application.api_key for testing.

Do Didit API keys expire?

Didit does not publish a key lifetime. Keys are long-lived and can be revoked, and a revoked, expired, malformed or wrong key returns 401 on verification.didit.me. You can read the current key from the application record at any time, so a rotation never needs a support ticket.

What is the difference between the access token and the API key?

The access token is a JWT for the account host apx.didit.me, sent as Authorization: Bearer. The API key is the credential for the verification host, sent as x-api-key. Sending a JWT to the verification host, or an API key to the auth host, fails with 401 or 403.

Why do I get a 403 from verification.didit.me?

Three usual causes: no x-api-key header at all, a scoped key that has no access to this resource or action, or a request from an address outside the key's IP list. If the body carries "code": "application_deleted", the key's application was deleted and retrying will not help. Use a key from an application that still exists.

How do I recover a lost Didit API key?

Log in to get a JWT, call GET /auth/v2/organizations/me/ to find your organization, then call GET /auth/v2/organizations/me/{org_id}/applications/{app_id}/. The response includes the current api_key, because there is no show once model. The same values sit in the console under Developers, API keys.

Do failed authentication calls cost anything?

No. Registering, logging in, reading an application record, and getting a 401 or 403 are not billable events. Billing is per completed check on the verification host, from prepaid credit, and sandbox checks are never billed at all.

How should I handle 429 responses from the Didit API?

Read the wait instruction for the host you called: verification API rate limits send a Retry-After header, and authentication flows that document a limit return a wait field in the JSON body, in seconds. Wait that long, then retry with backoff. A 401 is not a rate limit, so do not retry until you fix the key, then retry. Codes 403 with application_deleted, 404 and 410 need a change to the request, not another attempt.

Can I use the Didit Python SDK instead of raw HTTP?

Yes. Install didit-sdk with pip on Python 3.10 or newer, set DIDIT_API_KEY, and the client covers sessions, workflows, standalone checks, transactions and the Travel Rule. Account calls still go through the auth host: sign in with account.login and pass that token to the client as its account token.

Is there an OAuth flow anywhere in Didit?

Yes, for AI clients. The hosted MCP server at https://mcp.didit.me/mcp is an OAuth 2.1 resource server with a Log in with Didit step and PKCE, so no API key sits in the client config. That flow authenticates a person acting through an agent, so it does not replace the server-side key your backend uses, and the verification API still takes x-api-key.

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.