Organizations
An organization is a customer of yours whose people use your app: Initech, Globex. It groups users of a realm, the way Auth0's Organizations do. Your app says which organization someone is signing in to. Only its members get through, and their tokens say which organization it was, so your app never trusts the browser about it.
Setting one up
nod org create acme initech --name "Initech"
nod org add acme initech alice # by username; `remove` takes them out
nod org list acme
nod org delete acme initech # and every membership in it
Or through the management API with the organizations:read and organizations:write scopes.
Signing in to an organization
Add organization=<id> to the authorization request:
/authorize?…&organization=initech
- An organization that doesn't exist sends the browser back to your app with
error=invalid_request, before anyone signs in. - Someone who isn't a member signs in as usual and then goes back to your app with
error=access_denied. That holds whether they signed in just now or already had a session. - A member's tokens carry
org_id: the ID token, and the access token (for userinfo, or for your API withresource=). **Checkorg_id** in your app or API against the organization you asked for, or the one the data belongs to. - Membership is checked again at every refresh. Someone removed from the organization gets no new tokens for it, and their access tokens expire within minutes. Their refresh token isn't used up by the refusal, so if they're added back it works again.
- **Without
organization,** tokens have noorg_id, whatever organizations the person belongs to.
Deleting a user or an organization removes their memberships.
Apps for organizations only
An app whose every user signs in as one of your customers can require it (Auth0's "business users"):
curl -X PATCH "$ISSUER/api/v1/clients/web" -H "Authorization: Bearer $T" -H 'content-type: application/json' \
-d '{"organization_usage": "require"}'
- The app names one (
organization=): as above. - It doesn't: after signing in, a person in one organization goes straight on with it; one in several chooses (Nod's page, or a frontend's:
/authorizeas JSON answerschoose_organization, a list, andauthorize/completetakes theorganizationchosen); one in none goes back to the app withaccess_denied. - **
prompt=none** can't ask:interaction_requiredwhen the person would have to choose. - **
deny** is the opposite: the app signs people in as themselves only, andorganization=is refused.allow(the default) lets the app decide each time.
From the command line: nod client organizations REALM CLIENT_ID allow|require|deny. It is in configuration files and Terraform too (organization_usage on a client).
Roles in an organization
Someone can manage Initech's orders without managing Globex's. Give a member roles in one organization:
nod org roles acme initech alice --role manager # no --role clears them
# or: PUT $ISSUER/api/v1/organizations/initech/members/<user id>/roles {"roles": ["manager"]}
- They count only in that organization's tokens. A token for an API (
resource=) withorg_id: initechcarries the permissions of the person's realm roles plus their Initech roles. The same person signing in for Globex, or with no organization, doesn't get them. - Roles are the realm's roles, and each must exist. Only members can hold them, and adding someone again keeps their roles.
- Changes count at the next refresh, as for realm roles.
The organization's own sign-in
A customer usually signs in with their own identity provider: Initech's Okta, Globex's Entra ID. Add it as a connection, then name it for the organization:
nod org connections acme initech --connection initech-okta --join
# or: PUT $ISSUER/api/v1/organizations/initech/connections {"connections": ["initech-okta"], "join_on_sign_in": true}
- **With
organization=initech,** the sign-in page offers only the organization's connections, and starting through any other is refused. Passkeys and passwords stay available to people who already have them. With no connections listed, every connection of the realm is offered. - **
--join** (join_on_sign_in) makes whoever signs in through one of those connections, for this organization, a member. The organization's own provider vouches for its people, so they need no invitation. Only a sign-in that went through one of the organization's connections counts, even if the list changed while it was under way. Each join is in the security log asorganization.joined. An LDAP connection on the list works the same way: its people join on their first directory sign-in, whatever app they came from.
Letting the customer set it up (self-service SSO)
Instead of collecting a customer's provider details yourself, send their IT team a link:
curl -X POST "$ISSUER/api/v1/organizations/initech/sso-tickets" -H "Authorization: Bearer $T" \
-H "Content-Type: application/json" -d '{"join_on_sign_in": true}'
# {"organization": "initech", "ticket_url": "https://auth.example.com/acme/sso-setup?ticket=…", "expires_ms": …}
The link opens a page on Nod that shows the redirect URI to register at their provider (Okta, Microsoft Entra ID, Google Workspace, any OpenID Connect provider) and asks for its issuer, client id and secret. Nod reads the provider's discovery, as for any connection, and refuses a wrong issuer without using up the link. A right one makes the connection, adds it to the organization's connections (an organization that listed none so far now has just this one), and, with join_on_sign_in, takes in the people who sign in through it.
- SAML 2.0 too (ADFS, Okta, Entra ID, Shibboleth): they pick SAML on the page, which shows Nod's metadata URL and assertion consumer service, and enter their IdP's entity ID, single sign-on URL and signing certificate. A certificate that doesn't parse is refused without using up the link. See SAML 2.0.
- Their provider verifies no addresses. Whoever holds the link runs the IdP, and could otherwise claim anyone's address (another customer's, say) as verified. People's addresses from it are kept unverified until you list the customer's own email domains on the connection, once you've checked they own them:
nod connection verified-domains acme sso-initech-… --domain initech.example(orPATCH /connections/{id}with"verified_domains"). See connections. - A link works once, for seven days, for that organization in that realm only. Only its hash is stored.
- **Only
organizations:write** makes one. Each setup is in the security log asorganization.sso_configured. - The secret goes straight from their browser to Nod, which seals it at rest like every connection's.
Its own look
With organization=initech, the sign-in page can wear Initech's logo and colours rather than the realm's:
curl -X PUT "$ISSUER/api/v1/organizations/initech/branding" -H "Authorization: Bearer $T" \
-H "Content-Type: application/json" \
-d '{"logo_url": "https://initech.example/logo.png", "accent_color": "#0055aa", "background_color": ""}'
Each field left empty falls back to the realm's branding. They are checked like the realm's: colours as #rrggbb, the logo an https URL, whose origin is then the one image source the page's CSP allows. Both Nod's own page and ui/config (for frontends) apply it, and configuration as code carries it.
Plans and what an organization paid for
If your app sells plans to your customers' organizations, Nod keeps what each organization has paid for and puts it in their tokens, so your app checks a feature the way it checks a role: from the token, with no call. Nod never sees a card; a payments product (Ducat) or your own billing code tells Nod the state.
# Plans of the realm: features (1–64 of a–z 0–9 - _ : .) and the price ids that buy it (a price buys one plan)
curl -X PUT $ISSUER/api/v1/billing/plans/pro -H "Authorization: Bearer $T" -H 'content-type: application/json' \
-d '{"display_name": "Pro", "features": ["sso", "audit_log", "seats:50"], "prices": ["price_123"]}'
# An organization's state; as_of_ms is the time of what it comes from (a Stripe event's `created`, or now)
curl -X PUT $ISSUER/api/v1/organizations/initech/billing -H "Authorization: Bearer $T" -H 'content-type: application/json' \
-d '{"plan": "pro", "status": "active", "period_end_ms": 1798761600000, "customer": "cus_123", "as_of_ms": 1796000000000}'
Both need billing:write (and billing:read to read); organizations:write is not enough. A plan the realm doesn't have is refused. A PUT older than the stored as_of_ms changes nothing and answers the current state with "stale": true, so events that arrive out of order or twice never put an old state back. A deleted plan keeps its id (an organization still on it has no features, and no later plan of that id can give them back).
While the subscription is live (active, trialing, past_due: service goes on while payment retries), tokens for the organization carry its plan and features, in the ID token and the access token:
{ "org_id": "initech", "org_plan": "pro", "org_features": ["sso", "audit_log", "seats:50"] }
With canceled, unpaid, incomplete, no plan or a deleted plan, neither claim is there; treat "no org_plan" as the free tier. A change reaches your app by its next token (tokens are short-lived); to know now, read GET /organizations/{org}/billing, which answers {plan, status, period_end_ms, customer, as_of_ms, live, features}. In React, useBilling() and <Protect feature="sso"> read these claims (and follow each refresh): see @nod/react's README. GET /billing/organizations lists every organization with its state (the realm view's customer list).
A pricing page
GET $ISSUER/billing/pricing is public (no token, any origin), for a pricing page in the browser:
{ "plans": [ { "id": "pro", "display_name": "Pro", "features": ["sso", "seats:50"],
"prices": [ { "id": "price_…", "unit_amount": 4900, "currency": "usd", "interval": "month" } ] } ] }
It shows the prices Nod can sell: the ones Nod made (POST /billing/plans/{plan}/prices {"unit_amount", "currency", "interval"?}) and that are still active in Ducat. A price id put on a plan by hand still sells through checkout but isn't shown, since Ducat shows a price only to whoever made it. Without Ducat (or with Ducat down) each plan says "prices_unavailable": true. Ducat is read at most once a minute (and again right after a new price), and the answer may be cached for a minute.
An organization's own billing page
An organization's own people can see its billing and manage it from your app, without a management token: Nod's billing API, $ISSUER/billing (made when the realm's first plan is), with the scopes billing:view and billing:manage. Who may is a role held in that organization:
nod role create acme billing-admin
nod role grant acme billing-admin $ISSUER/billing --scope billing:view --scope billing:manage
nod org roles acme initech alice --role billing-admin # Initech's billing, not Globex's
The app signs the person in with organization=initech, resource=$ISSUER/billing and the scopes, then calls, with that token:
| Needs | ||
|---|---|---|
GET $ISSUER/billing/organization | billing:view or billing:manage | {organization, plan, plan_name, status, period_end_ms, live, features, has_customer} (never the Ducat customer id) |
POST $ISSUER/billing/organization/checkout | billing:manage | {plan, price?, success_url, cancel_url} → {url, …}, as the management API's checkout |
POST $ISSUER/billing/organization/portal | billing:manage | {return_url} → {url} |
- Always the token's organization, never one named in the request: a token for Globex reaches only Globex.
- The token's scope and the person's roles now must both allow it: taking the role away, or the person leaving the organization, counts at once, not at the next token.
- Return addresses must be on an origin the app redirects to (one of its redirect URIs'), so the endpoints can't send someone elsewhere after paying. Browsers on those origins may call them (CORS).
Checkout and the customer portal (Lunaor's Ducat)
For realms whose money Lunaor takes, Nod also asks Ducat for the payment pages and follows what Stripe says, so nobody sets the state by hand. Your app's backend (a client with billing:write) does this for an organization's admin:
# Where the admin pays for a plan; `price` is one of the plan's (the first when left out)
curl -X POST $ISSUER/api/v1/organizations/initech/billing/checkout -H "Authorization: Bearer $T" -H 'content-type: application/json' \
-d '{"plan": "pro", "price": "price_123", "success_url": "https://app.example/billing/ok", "cancel_url": "https://app.example/billing"}'
# -> {"url": "https://…", "session": "cs_…", "customer": "cus_…", "price": "price_123"} send the admin to url
# Where the admin cancels, changes card or reads invoices
curl -X POST $ISSUER/api/v1/organizations/initech/billing/portal -H "Authorization: Bearer $T" -H 'content-type: application/json' \
-d '{"return_url": "https://app.example/billing"}'
# -> {"url": "https://…"}
The first checkout makes the organization's Ducat customer (kept as customer); a portal before that answers 409. Nothing is live because a checkout was made: the organization's state changes when Stripe reports the subscription (a few seconds later), and its next token carries the plan. Addresses must be https. A server without Ducat answers 503 to both. GET /billing/sync (billing:read) shows whether the sync runs, how far it has read, and the latest problem: {configured, cursor, last_ok_ms, last_error, last_error_ms, behind}. Subscription events Nod cannot place (a price that is in none of the realm's plans, a customer that isn't an organization's) change nothing and show there as last_error; add the price to its plan.
Verified domains
An organization can claim the domains its people use and prove them with a DNS record, as Nod's own accounts do.
curl -X POST $ISSUER/api/v1/organizations/initech/domains -H "Authorization: Bearer $T" \
-H 'content-type: application/json' -d '{"domain": "initech.example"}'
# {"name": "initech.example", "verified": false, "txt_record": "_nod-challenge.initech.example", "txt_value": "nod-verify=…"}
# publish that TXT record, then:
curl -X POST $ISSUER/api/v1/organizations/initech/domains/initech.example/verify -H "Authorization: Bearer $T"
# {"name": "initech.example", "verified": true}
Or nod org domain add|verify|remove REALM ORG DOMAIN. verify answers 409 not_verified until the record is there, and 503 when DNS can't be asked. The organization's JSON lists its domains; txt_record and txt_value show only while a domain is unverified.
- One organization per domain, per realm. Once an organization has verified a domain no other organization of the realm can claim or verify it (409
already_exists), whoever else holds the record. Two organizations may claim a name before either verifies it; the first to verify holds it. The same name in another realm is that realm's own. - Release:
DELETE …/domains/{domain}, or deleting the organization, frees the domain for another. - Directory syncs act only at an organization's verified domains, so a claim that is not verified changes nothing.
- Changes need
organizations:writeand are logged asorganization.domain_verifiedandorganization.domain_removed.
Invitations
curl -X POST $ISSUER/api/v1/organizations/initech/invitations -H "Authorization: Bearer $T" \
-H 'content-type: application/json' -d '{"email": "dana@initech.example"}'
# {"id": "…", "email": "dana@initech.example", "expires_ms": …, "invitation_url": "https://…/acme/invitation?token=…"}
An invitation can carry roles: {"email": "…", "roles": ["billing"]}. The invitee holds them in the organization once they accept, beside any they already had there. Each must be a realm role, and not a SCIM group (whose members come from the directory).
- The link is emailed to the address (when Nod has a mailer, see Sign-in methods) and returned once in
invitation_url, so you can send it yourself. Listings never show it, and only its hash is stored. - Accepting needs the right account: the person signs in, and their account's email must be the invited address, verified. A forwarded or leaked link can't put anyone else in, not even someone who makes an account with the invited address typed in, and someone else trying it doesn't use it up. Someone whose address isn't verified yet is asked to verify it (the account page sends a link) and accept again.
- Joining is an explicit click on Nod's page. Opening the link joins nobody.
- Each link works once, for 7 days.
DELETE …/invitations/{id}withdraws one. Deleting the organization withdraws all of them, so a new organization with the same id never honours old links.