Test mode: paid plans aren't on sale yet, so nothing is charged. Every plan's limits apply.

← Docs

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

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"}'

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"]}

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}

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.

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/organizationbilling: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/checkoutbilling:manage{plan, price?, success_url, cancel_url} → {url, …}, as the management API's checkout
POST $ISSUER/billing/organization/portalbilling:manage{return_url} → {url}

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.

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).