Skip to content

LM-02Organizations

Sell to companies. Each one gets its own members, roles and directory.

An organization is a tenant: a customer's people, the teams they sit in, what each of them may do, and the identity provider that says who still works there. This chapter follows one, Okapi Health, through all of it.

Title
Organizations
Doc. no.
LM-02
Rev.
04
Issued
Nov 2026
Sheet
2 of 4

1.0Structure

An organization is a tree you can rearrange.

One organization per customer, teams inside it, members inside those. The figure is the admin screen your customers get; the listing beside it is what your API returns for the same state.

Organization3 teams7 members
Okapi Healthorg_okapi_health
  • 3 members
    • Marta LindqvistOwner
    • Sun-hee ParkClinician
    • Jonas WeberSuspended
  • 2 members
    • Deji OkonkwoAdmin
    • Tomás RiveraClinician
  • 2 members
    • Leon FischerBilling
    • Priya RamanAuditor
GET /v1/organizations/org_okapi_health
{  "id": "org_okapi_health",  "name": "Okapi Health",  "members_count": 7,  "teams": [    {      "id": "team_clinical",      "name": "Clinical",      "members": [        "usr_marta",        "usr_sun",        "usr_jonas"      ]    },    {      "id": "team_engineering",      "name": "Engineering",      "members": [        "usr_deji",        "usr_tomas"      ]    },    {      "id": "team_finance",      "name": "Finance",      "members": [        "usr_leon",        "usr_priya"      ]    }  ]}
As provisioned.
Fig. 1.1Okapi Health as a tree. Rename a team, move a member, add or remove a branch: the response on the right follows.

2.0Roles

Roles are data. Your customers edit them, your code only asks.

Five roles ship by default and each organization can add its own. A permission is a plain string; a check is one call that reads the session token and answers in microseconds.

app.acme.dev/okapi/settings/roles
Which role holds which permission in Okapi Health
PermissionOwnerorg-wideAdminorg-wideClinicianown teamBillingorg-wideAuditororg-wide
Members
Invite membersmembers:invite
Remove membersmembers:remove
Edit rolesroles:edit
Patient records
Read recordsrecords:read
Write recordsrecords:write
Export recordsrecords:export
Billing
See invoicesbilling:read
Change plan and cardsbilling:manage
Security
Read the audit logaudit:read
Create API keysapikeys:create
Configure SSO and SCIMsso:configure

Owners always hold every permission.

Fig. 2.1The roles matrix of Okapi Health. Tick a box or add a role; every check below re-runs against it.

2.2Check a permission

Input

Rules, in order

  1. 1Tenant boundaryThe resource is in Okapi Health.Next
  2. 2Active memberSun-hee is an active member.Next
  3. 3OwnerClinician is not Owner.Next
  4. 4Role grantClinician holds records:write.Next
  5. 5Team scopeClinician is team-scoped and Sun-hee is in Clinical, not the team that owns this.deny

Result

await latch.can({
  user: "usr_sun",
  action: "records:write",
  resource: "engineering",
})

→ denyDecided by rule 5: team scope.

0 network callsRead from the session token.

3.0Joining

Two ways in: an invitation, or the right email domain.

Invitations are for the first few people. After that, a verified domain does the work: anyone who signs up with a company address lands in the company's organization, with the role its admin chose.

Invitations2 pending

  • amara@okapi.health

    Clinician · 2 days ago · by Marta Lindqvist

  • ext.audit@northwind.example

    Auditor · 6 days ago · by Deji Okonkwo

Link lifetime
7 days
Resend limit
3 per day
Accepts with
Any sign-in method
Fig. 3.1Invitations for Okapi Health. Send one, then resend, revoke or accept it.
Verified domainsVerified

okapi.health

TXT _latch.okapi.health "latch-verify=9c41e07b2a6d"
New sign-ups with this domain become members.
Given to members who auto-join.
Try

ResultJoins Okapi Health as Clinician.

No invitation needed. The sign-up finishes inside the organization, and an audit event records it.

Fig. 3.2Domain capture. Type an address to see where a new sign-up with it would land.

4.0Directory sync

Their directory is the source of truth. Sync is a diff.

With SCIM 2.0 the customer's identity provider pushes changes as they happen: joiners, movers, leavers. Latch applies each one and answers. Nobody files a ticket to remove a login.

Protocol
SCIM 2.0
Providers
Okta, Entra ID, JumpCloud
Median apply time
1.8 s
Leaver to signed out
≤ 60 s
Plan
Business
Caution
Do not map a directory group to the Owner role. One mistaken group membership in the identity provider would hand a stranger the whole organization.

Okta · Okapi Health directory

Pushed 18 Nov 2026, 14:02:11 UTC

  1. POST /scim/v2/UsersAmara Nwosu joins, group clinical-leadsQueued
  2. POST /scim/v2/UsersKarim Haddad joins, group clinical-leadsQueued
  3. PATCH /scim/v2/Users/usr_tomasTomás Rivera: department Engineering → ClinicalQueued
  4. PATCH /scim/v2/Groups/finance-adminsPriya Raman added: role Auditor → BillingQueued
  5. PATCH /scim/v2/Users/usr_jonasJonas Weber: active → falseQueued
  6. DELETE /scim/v2/Users/usr_leonLeon Fischer removed from the directoryQueued

Okapi Health in Latch

7 active0 sessions revoked

  • Marta LindqvistClinicalOwner
  • Deji OkonkwoEngineeringAdmin
  • Sun-hee ParkClinicalClinician
  • Tomás RiveraEngineeringClinician
  • Priya RamanFinanceAuditor
  • Jonas WeberClinicalClinician
  • Leon FischerFinanceBilling

6 changes queued. Nothing applied yet.

Fig. 4.1A change set pushed by Okta for Okapi Health, applied line by line to the member list.

5.0Audit log

Every change above is already in the log.

Who did what, to whom, from where, and whether it was allowed. The log is append-only, searchable for a year on Business, and streams to your SIEM as it is written.

Category
14 of 14 events
Audit events, newest first
TimeActorEventTargetResult
14:02:19SCIM · Oktaleon@okapi.healthallowed
14:02:17SCIM · Oktajonas@okapi.healthallowed
14:02:16SCIM · Oktajonas@okapi.healthallowed
14:02:14SCIM · Oktapriya@okapi.healthallowed
14:02:12SCIM · Oktaamara@okapi.healthallowed
13:47:52Sun-hee Parkrecords:write · rec_8842 (Engineering)denied
13:20:05Deji Okonkworole: auditorallowed
12:58:41Deji Okonkwoconn_okapi_scimallowed
11:31:09Leon Fischermembers:invite · org_okapi_healthdenied
10:44:27Marta Lindqvistamara@okapi.healthallowed
09:41:07Marta Lindqvistsess_m4t8qz2k9wallowed
09:40:58unknownconn_okapi_samldenied
08:15:33Deji Okonkwookapi.healthallowed
08:02:10Priya Raman1–17 Nov 2026 (CSV)allowed
Fig. 5.1Audit log of Okapi Health for 18 Nov 2026. Filter it; select a row for the full event.

6.0Get started

Your first B2B customer can onboard themselves.

Organizations, invitations and the roles matrix are on every plan, free for teams of five. Add SSO and SCIM per customer the day their IT department asks.

npm install @latch/nextjs

Organizations, by plan

Organizations
Unlimited
Members on Free
5 each
Custom roles on Pro
10
SSO connection
$50 / month
SCIM and audit log
Business