Skip to main content

Headless Didit Login: Two-Factor Required, SSO and 429 Handling

Didit headless login returns tokens only when the account has no second factor. A two-factor account gets a 2FA flag plus a temp token, an SSO organization gets a 403, a recovered account gets a recovery setup error, and a.

Headless Didit Login: Two-Factor Required, SSO and 429 Handling

Contents

In this guide

Jump to the part you need.

This guide is for developers and AI agents that need Didit account credentials without a browser. POST https://apx.didit.me/auth/v2/programmatic/login/ exchanges a verified email and password for a JWT on our Auth host. Our published billing unit is the completed verification check, not the login call: a full KYC check is $0.33. The main caveat is that a 200 does not always mean tokens. An account with a second factor gets 2fa_required and nothing you can authenticate with.

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

Headless login outcomes at a glance
StatusBodyWhat it meansWhat to do
200access_token, refresh_token, expires_inThe account has no second factorSend the Bearer token to apx.didit.me/auth/v2, then read your api_key
2002fa_required: true, temp_token, has_passkeys, has_authenticatorThe account has an authenticator or a passkeyStop the automated call and let a person finish the factor; do not treat temp_token as an access token
403Code sso_required with organization_name, organization_slug, sso_urlThe organization enforces single sign-onSend the person to sso_url
403Code recovery_setup_requiredThe account was recovered and has no usable passwordSet a password first, then call login again
401Invalid email or password.Wrong credentialsFix the credentials; every failure counts toward lockout
429Too many login attempts. plus waitAccount lockout or per-IP limitHonour the wait value before retrying

Start free in the sandbox at business.didit.me with no sales call: every check in the sandbox application is mocked and never billed. For developers wiring this into an AI assistant, connect Didit through the MCP server documented at didit.me/developers/mcp. The authentication product line, including Biometric Authentication at $0.10 per auth, is at didit.me/authentication, and every published rate is on didit.me/pricing.

What the headless login endpoint does

Two hosts matter and they must not be mixed. apx.didit.me/auth/v2 issues JWT access tokens and manages organizations and applications. verification.didit.me/v3 runs sessions, workflows and AML, and it is authenticated with x-api-key, not with the JWT. The access token never goes to the verification host, and the API key never goes to the auth host.

The login endpoint is account management, not identity verification. Calling it does not run a check and does not bill one. It answers one question: can this email and password open this account, and if so, what does the account own.

Access to the account endpoints depends on the grant you hold. A JWT from the login call covers the account management endpoints on apx.didit.me/auth/v2 for the account that owns it. An MCP token from a Log in with Didit grant needs the didit:management scope, which carries the applications resource; a grant limited to didit:verification is refused with a 403 and no credential is returned. Both behaviours are documented in the Get Credentials reference, and the rest of this paragraph is our reading of it: scope decides reach, so ask for the narrowest grant that finishes the job.

Use Didit with MCP
The MCP server at https://mcp.didit.me/mcp signs in with OAuth and carries the same account calls for an AI assistant. A grant needs the didit:management scope to read application credentials.

Prerequisites

What you need before the first login call
ItemRequirementWhere it comes from
PlanFree works. The Free plan gives $10 of monthly credit to the first organization created with an eligible work email for a company domain, and the sandbox is free on every plan, including Growth at $99 a month and Scale at $299 a month. Our published prices bill completed verification checks, not login calls.didit.me/pricing
ClientAny HTTP client that can POST JSON and read a status code. curl, a script, or an AI assistant connected to the Didit MCP server.This guide, or openapi-auth.json
AccountA verified email and a password on the account. Accounts made with POST /programmatic/register/ work right after email verification. Console email and password accounts also work. OAuth-only console accounts must set a password first.Programmatic Login API
PermissionsOrganization owner or admin to read an application record and its api_key. A plain member gets a 403. An MCP grant needs the didit:management scope, which carries the applications resource.Get Credentials API

Step by step: from a password to an API key

  1. Get an account with a password. Either register one with POST /programmatic/register/ and confirm the 6-character code with POST /programmatic/verify-email/, or use an existing console account. Use the mailbox address without a plus tag: a tagged address is rejected before any lookup.
  2. Call POST /programmatic/login/ with the email and password. There is no authentication header. Email and password are the credential.
  3. Read the status and the branch field before you read the tokens. Only a 200 that contains access_token is a success. A 200 with 2fa_required is a second-factor challenge, and a 403 is a policy answer you cannot retry your way past.
  4. Store both tokens. access_token is an RS256 JWT with an expires_in of 86400 seconds by default. refresh_token is the RS256 JWT for refresh flows.
  5. List your organizations with GET /organizations/me/. Take the org_id of the organization that owns the application.
  6. Read the application record with GET /organizations/me/{org_id}/applications/{app_id}/. The response carries client_id, api_key, data_location and the product switches. Use GET /organizations/me/{org_id}/applications/ first when you do not know the app id.
  7. Build with the sandbox key, then switch. Send the sandbox api_key as x-api-key to https://verification.didit.me/v3/... for every test. Switch to the live application key only when you add credit and go live.
curl -X POST https://apx.didit.me/auth/v2/programmatic/login/ \
  -H "Content-Type: application/json" \
  -d '{"email": "you@yourdomain.com", "password": "MyStr0ng!Pass"}'

A 200 without a second factor looks like this, with the tokens shortened here:

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expires_in": 86400
}

Four more fields can appear in place of those tokens: 2fa_required, temp_token, has_passkeys and has_authenticator. The branch order below follows the documented responses and calls no second-step endpoint, because none is documented for this endpoint.

const res = await fetch("https://apx.didit.me/auth/v2/programmatic/login/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ email, password })
});
const body = await res.json();

if (res.status === 200 && body.access_token) {
  // success: send the Bearer token to apx.didit.me/auth/v2 only
} else if (res.status === 200 && body["2fa_required"]) {
  // stop here: a person finishes the second factor
} else if (res.status === 403 && body.code === "sso_required") {
  // redirect the person to body.sso_url
} else if (res.status === 403 && body.code === "recovery_setup_required") {
  // set a password for the account, then call login once more
} else if (res.status === 429) {
  // honour body.wait seconds before any retry
} else {
  // log res.status and body.detail; do not loop on a 401
}
curl https://apx.didit.me/auth/v2/organizations/me/ \
  -H "Authorization: Bearer <ACCESS_TOKEN>"
curl "https://apx.didit.me/auth/v2/organizations/me/<ORG_ID>/applications/<APP_ID>/" \
  -H "Authorization: Bearer <ACCESS_TOKEN>"
The email code entry screen used to confirm a newly registered Didit account
Registration sends a 6-character code that lasts 10 minutes. Confirm it and the account can log in headlessly right away.

The three responses that are not a token

2fa_required: the account has a passkey or an authenticator

An account with a second factor returns HTTP 200 with a body that has no tokens in it. The response names the factors the account has, so you know what to offer the person.

{
  "2fa_required": true,
  "temp_token": "...",
  "has_passkeys": true,
  "has_authenticator": false
}

Check for 2fa_required before you look for access_token. A client that reads access_token first and throws on a missing key will report an outage when the truth is that a person has a passkey. temp_token is returned with the second-factor response and must not be treated as access_token: no official second-step endpoint for it is documented for this endpoint, so the automated login stops here and a person finishes the factor.

If you need unattended logins, keep the automation account free of a second factor and keep the people accounts protected. A new API account created through POST /programmatic/register/ gets tokens immediately after email verification, which is the shape an agent needs.

Biometric Authentication by Didit
Biometric Authentication is a separate product listed at $0.10 per auth in our public price book.

sso_required: the organization enforces single sign-on

When the organization behind the account forces SSO, the password is refused with HTTP 403 and the code sso_required. The body names organization_name, organization_slug and sso_url. The password is not wrong, so retrying it cannot help.

The right handling is a redirect. Send the person to sso_url, let the identity provider do its work, and skip the password path entirely for that organization. Log the organization_slug so support can tell an SSO org from a credential problem in one look. For an agent, a 403 sso_required is a stop condition: report which organization blocked the login and which URL a human has to open.

recovery_setup_required: the account was recovered and needs a password

An account that went through recovery answers with HTTP 403 and the code recovery_setup_required. That is documented. Our advice follows from it: there is no usable password to check, so the login cannot succeed until one is set. Resolve it by setting a password for that account and calling the endpoint again. OAuth-only console accounts land in the same place for a different reason: they were never given a password, so the password endpoint has nothing to verify against.

When the answer is 429: too many login attempts

Brute-force protection runs on two counters. Per email, the lockout is progressive: 5 consecutive failures lock the account for 15 minutes, 10 failures lock it for 1 hour, and 20 failures lock it for 24 hours. Per IP address, the limits are 20 attempts a minute and 100 attempts an hour. The response is HTTP 429 with a wait field in seconds, and the documented handling is to honour that value before retrying. What follows is our client policy on top of it.

const res = await fetch("https://apx.didit.me/auth/v2/programmatic/login/", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ email, password })
});
if (res.status === 429) {
  const body = await res.json();
  await new Promise(r => setTimeout(r, body.wait * 1000));
}

Two habits keep this from becoming an incident. First, treat a 401 as final for that attempt: do not loop over a list of candidate passwords, because every miss is a strike against the account and the IP. Second, do not fan a retry out across a fleet. Ten machines retrying at once multiply the per-IP counter by ten and turn a 15-minute wait into a longer one.

If a 429 arrives with a wait you cannot absorb, log the value, surface it to whoever owns the account, and stop. A cached refresh_token is a cheaper path than a password retry when a session only needs to continue.

Field mapping for every response

Login response fields and what each one is for
FieldAppears inMeaningWhat you do with it
access_token200, no second factorRS256 JWT, 24 hours by defaultSend as Authorization: Bearer to apx.didit.me/auth/v2 only
refresh_token200, no second factorRS256 JWT for refresh flowsStore it securely; use it before asking for a password again
expires_in200, no second factorSeconds of token life, 86400 by defaultSchedule a refresh or a new login before it lapses
2fa_required200, second factorThe account has a second factorBranch here first, before reading any token
temp_token200, second factorReturned alongside the second-factor flagsDo not treat it as access_token; no second-step endpoint is documented here
has_passkeys200, second factorA passkey is registeredOffer the passkey option
has_authenticator200, second factorAn authenticator app is registeredOffer the authenticator option
organization_name, organization_slug403 sso_requiredWhich organization forced SSOShow it, and log the slug with the error
sso_url403 sso_requiredThe sign-in URL for that organizationRedirect the person there
Code recovery_setup_required403Recovered account, no usable passwordSet a password, then retry once
detail401, 403, 429The human-readable messageLog it; branch on the status and the code, not on the text
wait429Seconds to wait before the next attemptHonour that value before retrying

Test in the sandbox, then go live

The login endpoint has no separate sandbox mode. An account created through the documented programmatic registration flow gets both applications in the verify-email response: a sandbox application and a live application, each with its own api_key. Every check run with the sandbox key is mocked and never billed, and each sandbox application can create 500 test sessions every 24 hours. The live application bills each completed check from the organization balance, which starts at $0. An organization created through the API does not get the $10 monthly credit.

Test cases, expected results and fixes
CaseExpected resultFix
Correct email and password, no second factor200 with access_token, refresh_token, expires_inNothing; move to GET /organizations/me/
Correct password, account has a passkey200 with 2fa_required and has_passkeys: trueComplete the passkey; do not retry the password
Correct password, organization enforces SSO403 sso_required with sso_urlRedirect to sso_url
Recovered account403 recovery_setup_requiredSet a password, then retry once
OAuth-only console accountPassword login refusedSet a password in the console first
Wrong password, first time401 with Invalid email or password.Fix the credential; do not loop
Five wrong passwords in a row429 with a wait of up to 900 secondsHonour the value, then try once
More than 20 attempts a minute from one IP429 from the per-IP counterSlow down, and stop retrying across a fleet
Token used on the verification host401 or 403 from verification.didit.meSend x-api-key there instead, not the Bearer token
Member, not owner or admin, reading an application403 on /organizations/me/{org_id}/applications/{app_id}/Ask an owner or admin for the key, or for a role change

A clean end-to-end test looks like this: log in, read the organization, read the application, take the sandbox key, create one session against https://verification.didit.me/v3/session/, and confirm the decision comes back mocked. Then repeat with the live key on one real check after you add credit.

Disconnect and revoke

The access_token expires within 24 hours by default. Deleting the local api_key ends verification calls from that code path, but the key still exists on the application. Deleting the application ends everything: for a few minutes the API answers with application_deleted, and after that the key is refused like any wrong key.

There is no show-once model on the application record. GET /organizations/me/{org_id}/applications/{app_id}/ returns the current api_key on every call, so an audit is a GET away and a lost key is recoverable with the login flow alone.

What this costs on both ends

Say you run 100,000 full KYC checks in a month and each one starts with a headless login. Our published billing unit is the completed verification check, so the arithmetic below is on checks.

  • Logins: 100,000 calls to POST /programmatic/login/. Our price list has no line for login calls; the billable unit is the completed check.
  • Checks at list price: 100,000 x $0.33 = $33,000.
  • On Growth: 100,000 x $0.3168 = $31,680, plus the $99 monthly fee = $31,779. That is $1,221 less than list price.
  • On Scale: 100,000 x $0.297 = $29,700, plus the $299 monthly fee = $29,999. That is $3,001 less than list price.
  • Biometric Authentication is a separate line at $0.10 per auth: 100,000 x $0.10 = $10,000 on top of the checks above.

On your side the cost is one HTTPS request per login and somewhere safe to keep the refresh token. One POST, one status code, one branch per documented outcome. Plan fees, volume discounts and every module price are on didit.me/pricing.

Sources

Create the account, call the login endpoint and read your sandbox key at business.didit.me. There is no sales call, and the sandbox never bills a check.

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

What does the Didit programmatic login endpoint return?

POST https://apx.didit.me/auth/v2/programmatic/login/ returns access_token, refresh_token and expires_in when the account has no second factor. The access token is an RS256 JWT that lasts 86400 seconds by default and is sent as a Bearer credential to apx.didit.me/auth/v2. It is never sent to the verification host, which uses x-api-key.

Why does Didit return 200 with 2fa_required instead of an access token?

The account has a second factor, so the password alone is not enough to issue a session. The 200 carries 2fa_required: true, a temp_token, and the flags has_passkeys and has_authenticator, with no access_token. Read that key before you read the tokens, because a client that expects a token on every 200 will misreport this as an outage.

Can I use temp_token as an access token?

No. temp_token is returned with the second-factor response, not instead of a session, and no official second-step endpoint for it is documented for this endpoint. Treat it as a separate value rather than a Bearer credential for the account management endpoints. Finish the factor with a person, or use an account without a second factor when the login has to be unattended.

What should I do when Didit returns 403 sso_required?

The organization behind the account enforces single sign-on, so password login is refused. The body names organization_name, organization_slug and sso_url. Send the person to sso_url and stop retrying the password, because it was never the problem.

What does recovery_setup_required mean on a Didit login?

The account went through recovery and has no usable password, so the password check cannot pass. Set a password for the account and call the login endpoint again. OAuth-only console accounts hit a similar wall and also need a password set before the endpoint works for them.

How long should I wait after a Didit 429 too many login attempts?

Honour the number of seconds in the wait field of the 429 body before your next attempt. The lockout is progressive per email: 5 consecutive failures mean 15 minutes, 10 mean 1 hour, and 20 mean 24 hours. Per IP address the limits are 20 attempts a minute and 100 attempts an hour.

How long does a Didit access token last?

86400 seconds, or 24 hours, by default, and the response reports it in expires_in. The token is RS256-signed and needs no browser session. When it lapses, use the refresh_token or repeat the login call.

Can an OAuth-only Didit console account use the login API?

Not until it has a password. An account created through an OAuth provider has no password for the endpoint to check, so a password must be set first. Console accounts that already have an email and password work with no extra step.

How do I get my API key back if I only have an email and password?

Log in with POST /programmatic/login/, then call GET /organizations/me/ to get the organization id, then GET /organizations/me/{org_id}/applications/{app_id}/ to read the api_key. The record returns the current key on every call, so there is no show-once limit. Only organization owners and admins can read it.

Does the Didit login API cost anything?

Our published price list bills completed verification checks, not login calls. A full KYC check is $0.33, checks are paid from prepaid credit, and our documented billing examples charge per completed check. We do not publish a separate per-call price for the login endpoint.

Can I log in to Didit from Claude or ChatGPT?

Yes, through the Didit MCP server at https://mcp.didit.me/mcp, which uses OAuth sign-in and is free on every plan. An MCP grant needs the didit:management scope to reach applications and read credentials; a grant limited to didit:verification is refused with a 403. Setup for each client is at didit.me/developers/mcp.

What is the difference between an access token and an API key in Didit?

The access_token is a short-lived JWT for account management on apx.didit.me/auth/v2. The api_key is a long-lived key for verification traffic on verification.didit.me/v3, sent as x-api-key. Mixing them up is the most common cause of a 401 or 403 right after a successful login.

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.