Skip to Content
Docs
Guides

Organizations and roles

How Pontive models your customers' organizations, members, roles and permissions, which organization a session acts in, and how your app and API read roles and permissions from the token or ask the authorization API.

The model

Tenancy mode. A project is b2b or b2c, chosen when it is created and fixed. In a b2b project your customers are organizations (org_…) and users act inside them; a b2c project has no organizations and its users act on their own.

Organizations are flat: each sits directly under the instance, and an organization is the tenant boundary. A user can belong to several, with different roles in each.

Roles and permissions. A permission is an action key, such as invoice:approve. A role is a named set of permissions (or a wildcard role with every permission) defined on a resource type, and assigned to a member. Two types are built in:

Type keyWhat it isSeeded roles
rootThe instance itself. Roles here apply instance-wide: your own staff, or end-user tiers in a b2c app.owner, admin
orgOrganizations (b2b only). Roles here apply inside one organization.owner, admin

Every organization always has at least one owner. The instance's owner and admin reach every organization through inheritance. You add your own roles and permissions on either type, and with the Fine-Grained Authorization capability you declare your own resource types (documents, projects…) with roles on individual objects.

Membership binds a user to the instance root or to an organization with a set of role keys.

Which organization a session acts in

A session acts in at most one organization at a time. Users are never asked to pick at sign-in:

  1. the organization the app names (organizationId on the provider, organization_id on /oauth2/authorize, or ?organization_id= on the server SDK's login route);
  2. otherwise the user's only organization;
  3. otherwise none.

A user moves the session to another of their organizations with the <OrganizationSwitcher> component, the server SDK's switch route, or Auth.switchOrganization(id) in the browser. A switch to an organization the user is not a member of is refused and leaves the session as it was.

Roles and permissions in the token

The access token carries the session's organization and what the user holds there:

{
  "sub": "usr_...",
  "org_id": "org_...",
  "roles": ["admin"],
  "permissions": ["invoice:approve", "invoice:read"]
}
  • roles are the user's effective role keys there: held directly plus those conferred by inheritance. There is no single role claim: a member can hold several roles, and none ranks above another, so check for the one you need.
  • With no org_id, roles and permissions are those the user holds on the instance root. A b2c token never has an org_id.
  • They are re-read on every refresh, so a role granted or revoked reaches the next access token. A suspended organization grants nothing, and its claims are not issued.

In a Next.js server component

import { pontive } from "@/lib/pontive"; // see the Next.js quickstart

export default async function Invoices() {
  const session = await pontive().auth();
  const org = session?.organization; // { id, roles, permissions } or null
  if (!org?.permissions.includes("invoice:read")) return <p>Not allowed.</p>;
  return <p>Invoices of {org.id}</p>;
}

To move the session, link to the switch route (server sessions):

import { switchOrganizationPath } from "@pontive/pontkit-nextjs/server";

<a href={switchOrganizationPath("/api/auth", org.id, "/dashboard")}>{org.name}</a>;

In the browser

import { Auth } from "@pontive/oidc-client";

Auth.getOrganization(); // { id, roles, permissions } | null
await Auth.switchOrganization("org_...");

In React, useSession() from @pontive/pontkit-react reports organization-changed with the new organizationId, so you can reload what depends on it.

In your API

@pontive/pontkit-server's resource server gives each verified caller orgId, roles and permissions (Protect an API); any JWT library reads the same claims.

Fine-grained checks

The token is a snapshot of one organization. Ask the authorization API, on your request path, when the question is about a specific object, another organization, or must reflect a change made seconds ago. It speaks OpenID AuthZEN 1.0:

POST https://authz.{region}.pontive.com/access/v1/evaluation
Authorization: Bearer <a token or secret key holding sys:authz:check>

{
  "subject": { "type": "user", "id": "usr_..." },
  "action": { "name": "invoice:approve" },
  "resource": { "type": "org", "id": "org_..." }
}
{ "decision": true, "context": { "roles": ["admin"] } }

POST /access/v1/evaluations checks up to 100 questions at once. With @pontive/pontkit-server:

import { createAuthorizationClient } from "@pontive/pontkit-server/authorization";

const authz = createAuthorizationClient({
  managementUrl: "https://api.us.pontive.com", // the authz host, https://authz.us.pontive.com, is derived from it
  issuer: process.env.PONTIVE_ISSUER!,
  credential: { clientId: "svc_...", clientSecret: process.env.PONTIVE_CLIENT_SECRET! }, // holds sys:authz:check
});

const allowed = await authz.check(principal, "invoice:approve", { type: "org", id: "org_..." });

principal is the caller your resource server verified. For an agent acting for a user, the client checks by token, so Pontive answers for what both the user and the agent may do.

Managing organizations, members and roles

  • From your backend or an AI client: the management API (POST /organizations, POST /organizations/{organization}/members with user_id and roles, POST /authz/resource-types/{resource_type}/roles), or the same operations as tools of the Pontive MCP server.
  • By your customers' own admins, inside your app: the <MemberManagement> component lists members and invitations, changes roles and invites people, within the signed-in user's own roles. It needs the pontive:org:member:read, pontive:org:member:manage and pontive:org:member:invite scopes, allowed on the app and asked for at sign-in, and refresh tokens on.