Skip to content

Organizations

Serve your business customers from one realm: each organization has members with roles of their own, email invitations, proven domains, sign-in providers and branding, and is named in the tokens.

An organization is one of your customers — a company that buys your product — living inside a realm. Its people are ordinary users of the realm; the organization says whose people they are, which providers they sign in through, which branding they see and, through org_id in the token, which customer a request belongs to.

You do not need a realm per customer. One realm, one set of clients, and an organization for each company you serve.

What an organization holds

PartWhat it does
HandleThe alias your application sends to ask for this customer’s sign-in, such as globex. 2 to 64 lowercase letters, digits and hyphens, starting and ending with a letter or digit; unique in the realm and fixed once created.
MembersThe users of the realm who belong to it. Each membership can grant roles that hold only in tokens issued for this organization; see Roles per organization.
InvitationsEmail invitations, roles included, that bring a person into the organization when they sign in to your application with the invited address; see Invitations.
DomainsEmail domains the customer proved it controls, by DNS.
Found by email domainOff by default. In the clients with Organization sign-in, an address typed at its proven domains is led to its provider, which tells whoever types it that the company is your customer. In the other clients it does nothing: keep sending the handle.
Sign-in providersExternal identity providers of the realm offered to this customer, such as their own Microsoft Entra directory.
SSO requiredOff by default. Everybody of the realm with an address at a proven domain signs in only through the active providers offered to it. See Require the organization’s providers.
Members onlyOff by default. An authorization request that names the organization refuses anybody who is not a member, with access_denied.
BrandingLogo, primary colour and background colour, applied over the client’s sign-in screen. Anything left empty keeps the client’s.
StatusA suspended organization admits nobody, is ignored at sign-in and is no longer named in tokens. Its members, domains and providers are kept.
A person joins an organization in one of three ways: added from the console or the API, by invitation, or through automatic membership by domain. The membership’s roles hold only when they sign in to this organization; their direct and group roles keep holding everywhere.

Set up an organization

  1. Create it

    Open Organizations, choose New organization, pick the realm and give it a display name and a handle. The handle is suggested from the name; check it now, because it cannot change later.

  2. Prove a domain

    In the Sign-in section of the organization’s page, choose Claim a domain and type it, such as globex.com. Publish the TXT record shown on that domain, then choose Verify:

    DNS TXT record on globex.comPlain text
    authio-domain-verification=<value shown in the console>

    The domain moves from Awaiting proof to Proven. Verification is not retried on its own: publish the record first, then verify. A domain can belong to only one organization.

  3. Offer its sign-in providers

    Still on Sign-in, choose Offer a provider and pick among the identity providers registered in the realm. See Social and enterprise sign-in to register one.

    Then turn on Organization sign-in in the configuration of each client that should accept this customer: the client accepts the providers offered to the organization without offering them itself. Do not offer the customer’s provider in the client’s Sign-in options as well, where every visitor of the client would see it.

  4. Add members

    In the People section, choose Add member and pick users of the realm, send an invitation to somebody who is not a member yet, or let a proven domain admit them, as below. Then choose Roles on a member to give them this organization’s roles.

    Or let the customer’s directory keep them: with a connection in SCIM provisioning, also under People, every person Microsoft Entra ID or Okta provisions becomes a member, and whoever it deactivates leaves the organization. See SCIM provisioning.

  5. Brand it

    On the organization’s page, in the Profile section, set the logo URL and the colours its people see at sign-in.

Automatic membership by domain

Turn on Admit arrivals automatically and anyone who finishes signing in with a confirmed address at one of the organization’s proven domains becomes a member, with no invitation.

  • Two proofs are required: the domain verified by DNS and the person’s address confirmed — by Authio, or asserted as verified by a trusted external provider. A local sign-up on an unconfirmed someone@globex.com does not get in.
  • The switch is set after the organization exists and does nothing until a domain is proven.
  • When the application names an organization at sign-in, only that one can admit the person.
  • A failure to admit never fails the sign-in: the person signs in without the organization.
  • The membership created this way grants no role at all. That is what keeps the automatic entry safe: being admitted by domain changes which organization the token names, not what the person may do. Give the roles afterwards, on the member, or invite the person with them.

Sign people in to an organization

Add organization, with the handle, to the authorization request. Your application decides which customer is signing in — usually from the subdomain or a path segment it was opened on — and passes it through.

The Authio libraries take it as an option: organization in createAuthorizationUrl of @hyper.authio/client, Organization in the AuthioAuthorizationRequest of Authio.Client, and the third argument of signIn with @hyper.authio/provider-nextauth. Behind a BFF, send the person to /bff/login?organization=globex, in @hyper.authio/bff and Authio.AspNetCore.Bff alike.

Node.jsTypeScript
import { createAuthioClient } from '@hyper.authio/client'

const authio = createAuthioClient({
  issuer: 'https://authio.api.hyperio.tech/realms/acme',
  clientId: 'acme-web',
  clientSecret: process.env.AUTHIO_CLIENT_SECRET,
  checks: ['pkce', 'state', 'nonce'],
  redirectUri: 'https://app.acme.com/callback',
})

export async function signInToOrganization(handle: string) {
  // Keep the transaction until the callback, and send the person to url.
  const { url, transaction } = await authio.createAuthorizationUrl({
    scopes: ['openid', 'profile', 'email'],
    organization: handle,
  })

  return { url, transaction }
}

With a handle, the hosted login draws the organization’s branding and offers the active providers offered to the organization in place of the client’s. In a client without Organization sign-in, only the providers the client also offers are shown, and the others are refused. A handle that names no active organization is ignored, and the sign-in goes on as an ordinary one.

Naming an organization does not restrict who signs in

Unless Members only is on, a person who is not a member signs in normally and receives tokens without org_id. With Members only on, an authorization that names the organization, or was led to it by the email, refuses them with access_denied on the redirect_uri, once automatic admission was tried. Either way, check org_id or org_alias in your application before serving a customer’s data.

Let the email find the organization

Your application does not have to know the customer. In a client with Organization sign-in, while the realm has an active organization found by email domain, with a proven domain and an active provider offered, the password step asks for the email first:

  • An address at a proven domain of such an organization is sent to its provider: straight to it when the organization offers one, to its screen when it offers several. The request gains organization=<handle>, and the typed address goes to the provider as login_hint when the request carried none.
  • Any other address goes on to the password, as before. The step looks no account up, so it answers the same for an address with an account and one without.
  • The code-by-email step finds the organization the same way before it sends a code.
  • Only organizations with Found by email domain on are found, and finding one tells whoever typed the address that the company is your customer.

Require the organization’s providers

With SSO required on, every account of the realm whose email is at a proven domain of the organization, member or not, signs in only through the active providers offered to it, in every client.

  • A password, a code by email, a passkey as first factor, any other provider and a single sign-on session opened another way are refused once the credential is proven; a wrong password still gets the usual answer. The hosted screen shows its own message and a button to the organization’s provider.
  • The token endpoint answers the password grant with invalid_grant and the code OrganizationSsoRequired, and the access log records Organization SSO required.
  • Self sign-up with an address at that domain is refused before anything is created.
  • Turning it on requires Found by email domain and an active provider offered (OrganizationSsoRequiresDiscovery, OrganizationSsoRequiresProvider); withdrawing the last active provider is refused (OrganizationSsoLastProvider).
  • Clients without Organization sign-in that do not offer the provider stay closed to these people. The rule holds only the accounts of this realm: the team that administers the console signs in through another realm.

Organizations in tokens

When a sign-in belongs to an organization, both the access token and the ID token name it:

Access token payloadJSON
{
  "iss": "https://authio.api.hyperio.tech/realms/acme",
  "sub": "6f1c2e7a-4b8d-4f0e-9a51-3c2d7e8b9f10",
  "azp": "acme-web",
  "scope": "openid profile email",
  "org_id": "b3e1d7c4-2f6a-4e9b-8d1c-7a5f0e2b4c96",
  "org_alias": "globex",
  "exp": 1791372600
}

Authio decides the organization when the sign-in completes, in this order:

  1. If the request named an organization, that one — provided the person is a member, or was just admitted by domain, and the organization is active. Otherwise the token names none, or, with Members only on, the authorization is refused.
  2. If the request named none, the organization of the invitation the person just accepted or, with no invitation, the one they were just admitted to by a proven domain.
  3. Otherwise, the person’s organization when they belong to exactly one active organization.
  4. Otherwise, none: org_id and org_alias are left out.

Use org_id as the key for the customer in your own data. Token introspection returns both claims as well.

  • A refresh keeps the organization the sign-in was issued under, and checks again that the person still belongs to it and that it is active. Removed from it, the person’s next token no longer names it.
  • A delegation can be confined to an organization the person belongs to, with organizationId; see Delegation.
  • The roles the membership grants arrive in org_roles, only in the access token and only with the roles scope; see Roles per organization. The person’s other roles stay in the usual role claims, and org_id decides whose data they reach.

Check the organization in your API

Scope every query by org_id and refuse a token without it on routes that serve a customer’s data. The SDKs have a guard for it, which takes the handle or the ID, or nothing to accept any organization:

ExpressTypeScript
import { requireOrganization } from '@hyper.authio/express'

app.get('/api/projects', requireOrganization(), async (req, res) => {
  const organizationId = req.authio!.user.organizationId!
  res.json(await projects.listFor(organizationId))
})

app.get('/api/globex/reports', requireOrganization('globex'), listGlobexReports)

Roles per organization

A membership can grant roles of its own. The same person can be admin at Globex and only viewer at Initech without a role leaking into the other organization: the membership’s roles hold only in the access token issued for that organization. Their direct, group, client and realm roles keep holding everywhere, as always.

In the People section of the organization’s page, choose Roles on a member, pick the roles in the panel and save the Members group of the pending bar. It needs realm:update. The picker offers only what the person may receive: global roles, the realm’s, those of any client of the realm and their own exclusive ones. A system role, one of another account, or one exclusive to another person, a group or another realm is refused with NotAssignable.

  • Up to 20 roles per membership; a role named twice counts once. Going past that is refused with OrganizationMemberRoleLimitExceeded.
  • Saving replaces the whole set: a role left out stops holding. The change reaches the next token, on a refresh or a new sign-in, like any role change.
  • Taking the person out of the organization takes the membership’s roles with it; if they come back, they come back with none. Deleting a role takes it out of every membership.
  • Automatic membership by domain creates the membership with no role at all. An invitation carries the roles chosen when inviting.

The org_roles claim

When the access token is issued with org_id and with the roles scope, it carries org_roles: the list of the names of the roles the membership grants in that organization, without repeats and sorted by name.

Access token payloadJSON
{
  "iss": "https://authio.api.hyperio.tech/realms/acme",
  "sub": "6f1c2e7a-4b8d-4f0e-9a51-3c2d7e8b9f10",
  "azp": "acme-web",
  "scope": "openid profile roles",
  "org_id": "b3e1d7c4-2f6a-4e9b-8d1c-7a5f0e2b4c96",
  "org_alias": "globex",
  "org_roles": ["admin"],
  "exp": 1791372600
}
  • Only in the access token and only with the roles scope, like the other role claims. The ID token and UserInfo never carry it.
  • The lightweight access token leaves it out too; its introspection returns the complete token, with org_roles.
  • Inactive roles, roles exclusive to a client other than the one that issued the token, and roles withheld by a suspension in force are left out. With no role left to stamp, the claim does not appear.
  • No org_id, no org_roles: a token that names no organization carries no organization’s roles, and the roles the person holds in another organization never get in.
  • A refresh recomputes the claim from the membership as it stands: a role taken away is gone from the next token, and somebody who left the organization gets their next token without org_id and without org_roles.
  • Under a delegation, the exchanged token keeps org_roles, because the claim describes the person’s access, not that of the application acting for them.
  • The name is reserved to the platform: no claim mapper, person’s claim, role’s claim or credential may write org_roles.

The claim carries names only, without the role’s permissions. You do not have to read it yourself: the SDKs expose it as user.organizationRoles in @hyper.authio/server and @hyper.authio/express (0.12.0), OrganizationRoles and GetAuthioOrganizationRoles() in Authio.AspNetCore (0.11.0), and session.authio.organizationRoles in @hyper.authio/provider-nextauth (6.1.0).

They hold in that organization alone

The roles held in the organization are kept apart from the person’s other roles: they are in neither roles nor permissions, and requireRole, hasRole, checkAccess, [AuthioRole] and HasAuthioRole never read them. Check them by name, together with the organization the token names, and scope the data by that same org_id.
ExpressTypeScript
import { requireOrganization } from '@hyper.authio/express'
import type { RequestHandler } from 'express'

const requireOrganizationRole =
  (role: string): RequestHandler =>
  (req, res, next) => {
    if (req.authio?.user.organizationRoles.includes(role)) return next()
    res.status(403).end()
  }

app.delete(
  '/api/projects/:id',
  requireOrganization(),
  requireOrganizationRole('admin'),
  deleteProject,
)

Invitations

Invite a person by email address, with the roles they will have. They get the message, accept it on an Authio page and sign in to your application, with the account they already have or one they create on the spot. The membership is born when they finish signing in with the invited address, and the access token of that sign-in already carries org_id and, with the roles scope, the invitation’s roles in org_roles.

Send an invitation

In the People section of the organization’s page, choose Invite under Invitations. It needs realm:write.

FieldWhat it is
AddressRequired, up to 256 characters, kept in lowercase. The account that accepts the invitation has to use this address.
ApplicationRequired: the client of the realm the person will sign in through. It needs at least one http or https return address, because accepting sends the person to one of the application’s sites; a client with native-app schemes only is refused with OrganizationInvitationClientCannotSignIn.
RolesOptional, up to 20: those a person of the realm without an account yet may receive. A role exclusive to a person or a group is refused with NotAssignable.
Continuation addressOptional: where the person goes after accepting, such as the application page that opens the sign-in. It has to be at the origin of one of the client’s return addresses, or the invitation is refused with OrganizationInvitationContinueUrlNotAllowed; empty, the origin of the first http or https return address is used.
Message languagePortuguese (pt-BR) or English (en). With none chosen, the inviter’s language is used.
  • The invitation holds for 7 days.
  • An address that already belongs to a member is refused with OrganizationMemberAlreadyExists, and one that already has an invitation pending and within its time, with OrganizationInvitationAlreadyPending.
  • An organization holds at most 500 invitations pending and within their time (OrganizationInvitationLimitReached), and a suspended organization does not invite (OrganizationInactive).
  • The link exists only in the message: neither the console nor the API shows it. If the message did not go out, the invitation is created anyway, with no send date, and can be sent again at once.

The message goes out with the client’s brand and sender and states the organization, the application, the deadline and a button to the invitation page. To use your own words, edit Organization invitation in the E-mails section of the client’s page, like the sign-in e-mails: the {organization} placeholder, with the organization’s name, exists only in that message.

From the email to the token

  1. The person opens the link in the message. The invitation page, with the client’s and the organization’s brand, shows the organization, the application, the invited address and the deadline. Opening the link changes nothing, so an email link scanner does not accept the invitation.
  2. They choose Accept invitation. The browser keeps the invitation for up to 24 hours, never past its deadline, and goes to the continuation address, with no token in it.
  3. They sign in to your application, which asks for the sign-in as always. Without an account, they create one with the invited address, accepted even with the client’s sign-up on Nobody or Listed domains only; the form comes with the address filled in. The human check and the address confirmation still apply.
  4. When Authio issues the authorization code for the invitation’s client and the account’s address is the invited one, the person becomes a member with the invitation’s roles, the invitation turns Accepted and the token names the organization, unless the request named another one.

Your application changes nothing: there is no new parameter on the authorization request, and somebody who already has a session in the realm gets in without seeing the sign-in screen.

  • The account’s address has to be the invited one, case aside. Somebody who signs in with another account signs in normally, without the organization, and the invitation stays pending.
  • The invitation holds in the browser it was accepted in and through the invitation’s client: signing in through another application of the realm, or in another browser, does not accept it.
  • Somebody who was already a member keeps the roles they had and gains the invitation’s, up to 20. A role that can no longer be given to the person since the invitation is left out, without failing the acceptance.
  • An invitation that does not apply never fails the sign-in: the person signs in as they would without it.
  • A link that expired, was revoked, was already used or belongs to a suspended organization always gives the same page, which asks for a new invitation from whoever invited them, without saying why.

Resend or revoke

The Invitations section lists each invitation, newest first, as Pending, Expired (pending past its deadline), Accepted, with who accepted and when, or Revoked. The menu of a pending or expired invitation has:

  • Resend, with realm:write: issues a new link, which voids the previous one, counts 7 more days from now and sends the message again. An invitation is sent again only 5 minutes after its last message (OrganizationInvitationResendTooSoon); one that never went out can be sent again at once.
  • Revoke, with realm:delete: the link stops working at once.

An accepted or revoked invitation takes neither (OrganizationInvitationNotPending). Revoking never removes a member: whoever already accepted stays in the organization until they are removed from Members.

Suspend or delete

  • Suspending keeps the organization whole — members and their roles, invitations, domains, providers — and stops it from admitting anyone, inviting, shaping the sign-in or being named in new tokens. While it is suspended, none of its invitations can be accepted.
  • Deleting removes its domains, the providers offered to it, its invitations and every membership, with their roles. The users stay in the realm.

Each organization can also decide which external accounts its people may connect on its behalf; see Connected accounts.

Manage organizations through the admin API

Onboard a customer from your own back office: every path starts with /api/v1/admin/realms/{realm}/organizations. See Admin API for authentication.

CallWhat it doesPermission
GET / · GET /{organizationId}Lists the realm’s organizations, or reads one.realm:read
POST /Creates an organization from alias, name and description. It starts active; every other field is ignored on creation and set afterwards, with PUT.realm:write
PUT /{organizationId}Replaces name, description, isActive, logoUrl, primaryColor, backgroundColor, discoverableByDomain and autoJoinOnVerifiedDomain, and sets enforceSso and requireMembership. The body must carry the alias, which does not change. A field left out returns to its default — isActive true, the others empty or off — except enforceSso and requireMembership, which keep their value.realm:update
DELETE /{organizationId}Deletes it.realm:delete
GET /{organizationId}/members · POST …/members · DELETE …/members/{userId}Lists, adds ({ "userId": "…" }) or removes a member. Each member of the list carries roles, the membership’s roles.realm:read · realm:write · realm:delete
GET …/members/{userId}/roles · PUT …/members/{userId}/rolesReads the roles of a member’s membership, or replaces the whole set ({ "roleIds": ["…"] }). An empty list takes them all away.realm:read · realm:update
GET …/invitations · POST …/invitationsLists the 200 most recent invitations, newest first, with the status Pending, Expired, Accepted or Revoked; or invites, with email, clientId, roleIds and, optionally, continueUrl and locale, answering 201. clientId is the ID of the client’s record, not the protocol client_id.realm:read · realm:write
POST …/invitations/{invitationId}/resend · DELETE …/invitations/{invitationId}Sends the invitation again with a new link and deadline, or revokes it. Both answer with the invitation. No answer carries the link.realm:write · realm:delete
POST …/domains · POST …/domains/{domainId}/verify · DELETE …/domains/{domainId}Claims a domain ({ "domain": "globex.com" }), verifies its TXT record, or removes it.realm:write · realm:update · realm:delete
POST …/identity-providers · DELETE …/identity-providers/{identityProviderId}Offers a provider of the realm ({ "identityProviderId": "…" }), or stops offering it. The last active provider of an organization with SSO required cannot be withdrawn (OrganizationSsoLastProvider).realm:write · realm:delete
GET /api/v1/admin/realms/{realm}/users/{userId}/organizationsThe organizations one person belongs to.user:read

On Node.js, @hyper.authio/admin covers every call above: admin.organization (getAll, getById, create, update, delete, getMembers, addMember, removeMember, getMemberRoles, replaceMemberRoles, claimDomain, verifyDomain, removeDomain, addIdentityProvider, removeIdentityProvider), admin.organizationInvitation (getAll, create, resend, revoke) and admin.userOrganization.getAll, with admin the client of The Admin API from the libraries. On .NET, IAuthioAdminClient has no method for organizations: call them with an `HttpClient` that carries `AddAuthioAccountCredential()`.

Node.jsTypeScript
const organization = await admin.organization.create({
  realm: 'acme',
  body: { alias: 'globex', name: 'Globex Corporation' },
})
const organizationId = organization.id!

await admin.organization.update({
  realm: 'acme',
  organizationId,
  body: { alias: 'globex', name: 'Globex Corporation', primaryColor: '#0b5fff', autoJoinOnVerifiedDomain: true },
})

await admin.organization.addMember({
  realm: 'acme',
  organizationId,
  body: { userId: '6f1c2e7a-4b8d-4f0e-9a51-3c2d7e8b9f10' },
})

await admin.organization.replaceMemberRoles({
  realm: 'acme',
  organizationId,
  userId: '6f1c2e7a-4b8d-4f0e-9a51-3c2d7e8b9f10',
  body: { roleIds: ['9c2e5a1f-7d3b-4f6e-8a0c-2b4d6f8e1a37'] },
})

await admin.organizationInvitation.create({
  realm: 'acme',
  organizationId,
  body: {
    email: 'ana@globex.com',
    clientId: '4a7d1c9e-2b3f-4e8a-9c6d-1f0b5e7a3d28',
    roleIds: ['9c2e5a1f-7d3b-4f6e-8a0c-2b4d6f8e1a37'],
    continueUrl: 'https://app.acme.com/globex',
    locale: 'en',
  },
})

Next steps