Skip to main content

Didit Organization Roles: Read org and organizations From the Token

The org claim in the access token holds only the earliest membership. Call GET /session/ for every membership with the organization id, role and custom role, then check permissions on your server.

Didit Organization Roles: Read org and organizations From the Token

Contents

In this guide

Jump to the part you need.

This page is for teams building a B2B app on Didit Authentication who need the signed-in person's organization id and role. Authentication is priced per active user: the first 50,000 active users each month are free, then $0.02 per active user per month at list price. The caveat is the token. Its org claim carries one membership only, so any app where a person belongs to more than one organization must read GET /session/.

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

Where each value lives

Organization data in a Didit Authentication token and session
What you needRead it fromWhat you get
One organization id and role without a network callThe org claim in the access token and the ID token{"id","role"} of the earliest membership, or null
Every organization the person belongs toGET /session/One entry per membership with organization_id, organization__name, role and custom_role
Custom role key and permissionscustom_role in GET /session/A key and permission keys such as payouts.approve, or null
JavaScript SDK equivalentsession.organizationsThe same memberships
React SDK equivalentuser.organizationsThe same memberships
Built-in rolesBoth sourcesadmin, member, billing
MFA for organization adminsGET /session/Enforced by the organization_admins policy

Start free in the sandbox at business.didit.me, with no sales call. If you build with a coding agent, connect Didit to an AI assistant through our MCP server. Organizations are part of Didit Authentication, the product line for hosted sign-in, sessions and company SSO, documented at Authentication organizations. Current plan prices and included credit are on the pricing page.

The outcome and the method we recommend

The outcome is simple: your backend knows which organization the request is acting for and what that person may do there, before it touches money, data or another person's account.

We recommend a three-step read before every role-sensitive or sensitive action, because the documentation requires the live session check before sensitive actions. Verify the access token against your issuer's JWKS, call GET /session/ for the live list of memberships, then evaluate the role and the custom role permissions in your own code. The token gives you a fast identity. The session gives you the current answer. Your code gives you the decision.

Two things are not optional. Hiding a button in the browser is not authorization, and the org claim alone cannot describe a person who works across several organizations. Do both reads server-side. The full architecture is in the integration guide.

The organization here is one of your customers inside your application. It is separate from your Didit organization, which holds your own team in the Business Console.

Prerequisites

  • A Didit application with Authentication turned on. Every Sandbox application has it from the start. A Live application turns it on from the Products page of the console.
  • Organizations turned on under Authentication > Organizations > Settings, with a default role for new members (member unless you change it).
  • Redirect URLs and allowed origins registered under Authentication > Security and sessions.
  • At least two organizations in the console, and one person with a membership in each, so you can see the difference between the token and the session.
  • The Scale or Enterprise plan, or a Sandbox application, if you want to define custom roles.

Step by step

  1. Turn organizations on. In the console, open Authentication > Organizations and use the Settings card. Turn on Organizations, choose the default role for new members, and keep Require MFA for organization admins on. That is the organization_admins policy.
  2. Create the organizations and the memberships. Choose New organization, give it a name and a slug unique in the application, and upload a logo if you want one. Your team creates organizations in the console; people cannot create their own organizations from your app. Then use Invite member on each organization, entering up to 20 email addresses and the role each person gets.
  3. Sign a person in and keep the access token on your server. The code exchange returns an access token (about five minutes), an ID token, a refresh token and a session_id. Never send your verification API key or a console token to these endpoints.
  4. Verify the token. Use verifyToken from @didit-protocol/auth/server, or any JWT library, and check the ES256 signature against the issuer's JWKS plus iss, aud, exp and typ: at+jwt. Reject a token whose act is not null unless the route accepts AI agents.
  5. Read the org claim. The access token and the ID token both carry org as {"id","role"} for the earliest membership, or null when the person has no membership. Use it for display and for a first guess, never as the only check.
  6. Call GET /session/ before any decision that depends on role. Send the same access token as a Bearer credential to your issuer. The response lists every membership with organization_id, organization__name, role and custom_role.
  7. Evaluate the role and the permissions in your code. Built-in roles are admin, member and billing. A custom role sits on top of the role and carries permission keys your app checks, for example payouts.approve.
Use Didit with MCP, the walkthrough that connects Didit to an AI assistant
Building the check with a coding agent? The MCP server exposes the same Didit products while you scaffold the flow.

This is the whole check on one route, using the documentation's example permission key payouts.approve. It reads the claim, confirms the live session and evaluates a custom role permission.

import { verifyToken } from "@didit-protocol/auth/server";

const ISSUER = process.env.DIDIT_AUTH_ISSUER;

export async function canApprove(request) {
  const header = request.headers.get("authorization") ?? "";
  const token = header.startsWith("Bearer ") ? header.slice(7) : "";

  let claims;
  try {
    claims = await verifyToken(token, {
      publishableKey: process.env.DIDIT_PUBLISHABLE_KEY,
    });
  } catch {
    return false; // bad signature, wrong iss or aud, expired, or an agent token
  }

  const res = await fetch(`${ISSUER}/session/`, {
    headers: { Authorization: `Bearer ${token}` },
  });
  if (!res.ok) return false; // revoked, idle, expired, blocked, or MFA policy unmet

  const session = await res.json();
  const orgId = claims.org ? claims.org.id : null;
  if (!orgId) return false; // the person had no membership when the token was issued

  const membership = session.organizations.find(
    (o) => o.organization_id === orgId
  );
  if (!membership) return false;

  // Your application defines what each role may do. Only an explicit permission allows it.
  const permissions = membership.custom_role
    ? membership.custom_role.permissions
    : [];
  return permissions.includes("payouts.approve");
}

Expected output

For a person who belongs to two organizations, with a finance custom role in the first one, GET /session/ answers with every membership:

{
  "organizations": [
    {
      "organization_id": "6f1c0e2a-0000-0000-0000-000000000000",
      "organization__name": "Northwind Labs",
      "role": "member",
      "custom_role": {
        "key": "finance",
        "permissions": ["payouts.view", "payouts.approve"]
      }
    },
    {
      "organization_id": "b83d57f4-0000-0000-0000-000000000000",
      "organization__name": "Northwind GmbH",
      "role": "admin",
      "custom_role": null
    }
  ]
}

The matching token claim is smaller, because it names one membership only:

{ "org": { "id": "6f1c0e2a-0000-0000-0000-000000000000", "role": "member" } }

So canApprove returns true for that person through the finance custom role, and false for a person who is only a member in the same organization.

Inputs and outputs

Inputs you send and outputs you read
ItemWhere it comes fromType
Authorization: Bearer <access token>The code exchange at {issuer}/token/Request header, about five minutes of life
DIDIT_AUTH_ISSUERYour application's sign-in origin, no trailing slashServer environment variable
DIDIT_PUBLISHABLE_KEYAuthentication > Developers in the consolePublic key, safe in a client
org.id, org.roleThe access token and ID token claimsString, or null
organizations[]GET /session/Array of memberships
roleEach membershipadmin, member or billing
custom_roleEach membershipObject with key and permissions, or null
401GET /session/The session is no longer usable

Failure cases and recovery

  • org is null. The person has no membership in any organization of your application. Send them to an invitation, and have your team create organizations in the Didit console. Do not fall back to a default organization.
  • The session lists an organization the claim does not. Expected when a person belongs to several organizations. The claim names the earliest membership, so select the organization from the session and store the choice on your side.
  • GET /session/ answers 401. The session was revoked, went idle or expired, the person was blocked, or the session no longer meets your MFA policy. Send the person back through sign-in. When a person becomes an organization admin, they must enrol a second factor, and the session stops being accepted until it meets the organization_admins policy.
  • custom_role is null everywhere. Custom roles exist on the Scale and Enterprise plans and in every Sandbox application. On other plans a membership carries the built-in role only.
  • The old token fails after a refresh. After a refresh, the previous access token stops working at GET /session/ and DELETE /session/. Call the SDK's token getter right before each request instead of keeping a copy.
  • Tokens fail after you activate a custom domain. The custom domain becomes the issuer, and access tokens issued under the default host fail GET /session/ until they are refreshed, within five minutes. Update your issuer setting or accept both issuers during the change.
  • Offline verification fails right after a key change. When a key is revoked, Didit removes it from the JWKS at once and a new key starts signing. A cached JWKS can accept the revoked key for up to five minutes, so refresh the JWKS when you see an unknown kid, at most once a minute.
  • A member cannot be invited again from an old link. Organization invitations last seven days. Resend or revoke from the organization's Invitations list instead of forwarding the expired email.

SDK shortcuts

The SDKs hand you the same memberships without a manual fetch. In JavaScript with @didit-protocol/auth, read session.organizations from auth.getSession(), and call auth.getSession({ force: true }) when the decision must see a revocation immediately. Use auth.getToken() for the bearer token your backend verifies.

In React with @didit-protocol/auth-react, useUser() returns a user object that holds id, email, vendorData, verifiedIdentity and organizations. Render the organization switch from user.organizations, and still send the token to your backend for the decision. Details are in the JavaScript quickstart and the React quickstart.

Built-in roles and custom roles

Roles on an organization membership
RoleMeant for
adminPeople who manage the organization in your app. The organization_admins MFA policy applies to them.
memberEveryone else. This is the default role for new members.
billingPeople who handle the organization's billing in your app.

A custom role is an extra layer, not a replacement. A member holds one built-in role plus, optionally, one custom role with a key and the permission keys your app checks. You define those keys, so your backend has to know what payouts.approve allows. Didit stores and returns the key and the permissions. It does not enforce what they mean inside your product. The reference for members, roles and invitations is Organizations for B2B apps.

Console roles are a different system

Do not mix the two. The roles on this page belong to your customers' memberships in your app. Your own team in the Didit Business Console uses a separate set of five system roles, Owner, Admin, Compliance Officer, Developer and Reader, with action:resource permissions such as read:sessions. Those are covered in Roles and permissions.

Where memberships come from

Three paths add a person to an organization. An invitation sent from the console, which lasts seven days and opens the hosted /invite page. Auto-join on a verified domain, where a person who signs in with a verified email address at that domain joins automatically with your default role, and a domain can auto-join only one organization. Or company SSO, where people who sign in through the organization's own SAML or OIDC identity provider join with the default role. Setup links for SSO need the Scale or Enterprise plan, and Sandbox applications have them on any plan.

Your team creates the organizations themselves. Open Authentication > Organizations in the console, choose New organization, and invite the people who belong to it. A person who has no membership yet cannot create an organization from your app.

What it costs

Didit bills Authentication on the active-user line. The first 50,000 active users each month are free on every plan. After that the list price is $0.02 per active user per month, $0.0192 on Growth and $0.018 on Scale.

Worked example, for an app with 80,000 monthly active users at list price:

  • Free allowance: 50,000 active users, $0.00.
  • Billable users: 80,000 minus 50,000 = 30,000.
  • 30,000 times $0.02 = $600.00 per month.

The same 30,000 active users on the Scale plan: 30,000 times $0.018 = $540.00 per month of usage. Scale costs $299.00 a month and adds $350.00 of credit each month, which covers part of that usage, and unused monthly credit does not roll over. Custom roles require Scale, Enterprise or a Sandbox application, so the plan is the gate and the active-user line is what grows with your user base. Read current numbers on the pricing page or the machine-readable price feed.

How Didit billing works: credits, auto-recharge and volume discounts
Credits, plan discounts and top-ups, explained for the authentication line you run alongside verification.
  • Paid: active users above the 50,000 monthly allowance, at $0.02 per active user per month at list price, $0.0192 on Growth and $0.018 on Scale.
  • Paid: the plan that unlocks custom roles, $299.00 a month on Scale, or an Enterprise contract from $15,000 a year. Sandbox is free and includes custom roles.
  • Your review boundary: what each permission key means. Didit stores and returns keys such as payouts.approve, and your application decides what that key allows under its own policy.
  • Didit's review boundary: signature verification inputs, key rotation, session validity and the organization_admins MFA policy, all enforced at GET /session/.

Sources

Open the sandbox next. Create two organizations in the console, invite one person into both with different roles, and run the check above against GET /session/ before you wire it into a payout or an admin screen. Start at business.didit.me, no sales call needed.

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

Where do I get a user's organization id and role from the Didit access token?

Read the org claim. In both the access token and the ID token it holds {"id","role"} for the earliest membership of that person, or null when they belong to none. It is enough for display and for a first check, but it names one organization only.

How do I get all of a user's organizations and roles?

Call GET /session/ with the access token as a Bearer credential. The response lists every membership with organization_id, organization__name, role and custom_role. That is the only complete answer when a person works across several organizations.

Can one person belong to several organizations with different roles?

Yes. A person can belong to several organizations of your application with one role in each, and the org claim names only the earliest membership. Read GET /session/ for the full list. Which organization a person is acting for is application state you keep on your side, and you must check that selection against the live membership list from GET /session/ on each sensitive request.

What is the difference between a role and a custom role?

role is the built-in role on the membership, one of admin, member or billing. custom_role is an optional extra layer holding a key and the permission keys your app checks, such as payouts.approve, and it is null when none is assigned.

Which plans support custom roles in Didit Authentication?

Custom roles are available on the Scale and Enterprise plans and in every Sandbox application. On other plans a membership carries only the built-in role, and custom_role comes back null.

Does GET /session/ enforce MFA for organization admins?

Yes. The default MFA policy organization_admins requires a second factor from anyone holding the admin role in any organization of your application. A person who becomes an admin must enrol a factor, and GET /session/ stops accepting their session until it meets the policy.

Can I skip the session call and trust the org claim?

Only for low-risk display. An access token stays valid until it expires, within five minutes, while GET /session/ fails at once when the session was revoked, went idle or expired, the person was blocked, or the MFA policy is no longer met. Check the session before a sensitive action.

How do I check a permission like payouts.approve on my server?

Verify the access token, call GET /session/, find the membership whose organization_id matches the org.id claim, then look for the permission key your own policy requires inside custom_role.permissions. Whether an admin may approve payouts is a decision your application defines and checks, not something the role name grants. Never authorize from the browser.

What do the JavaScript and React SDKs return for organizations?

JavaScript: session.organizations from auth.getSession(), with auth.getSession({ force: true }) to bypass the 30 second cache. React: user.organizations from useUser(). Both give the same memberships as the raw session call.

What happens if the person belongs to no organization?

The org claim is null and the session lists no memberships. Send them to an invitation, and have your team create organizations in the Didit console, because people cannot create their own organizations from your app yet.

Is an organization in Didit Authentication the same as my Didit organization?

No. An organization in Authentication is one of your customers inside your application, with its own members, roles, verified domains and SSO. Your Didit organization is your own team in the Business Console, and it uses a different role system.

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.