Skip to content

Organizations

Users belong to organizations (orgs) and their teams. Your app can list them, and use an org’s or a team’s ID as the owner of a context or as a grantee.

Orgs are created and managed on Bazaar, not by your app: open the management window when a user needs to.

List the logged-in user’s orgs:

const orgs = await bzr.orgs.list();

An org looks as follows:

type Org = {
id: string;
name: string;
handle: string;
primaryTeam: Team; // every member of the org
active: boolean; // has an active subscription
admins: string[]; // user IDs
};

Get an org by ID or handle. Only its admins see admins:

await bzr.orgs.get({ orgId: "example-org-id" });
await bzr.orgs.get({ handle: "example-org" });

An org that doesn’t exist is an error of type ErrorTypes.OrgDoesNotExist.

List the logged-in user’s teams, optionally of orgs ("org") or their own ("user") only:

const teams = await bzr.orgs.teams.list({ type: "org" });

A team looks as follows:

type Team = {
id: string;
name: string;
ownerType: EntityType; // EntityType.USER or EntityType.ORG
ownerId: string;
primary: boolean;
admins: string[]; // user IDs
members: string[]; // user IDs
};

Open org management in a popup. Both callbacks are optional:

bzr.orgs.openPopup(
(teamId) => {
// The user picked a team
},
() => {
// The popup closed: load orgs again, they may have changed
},
);

Call it from a click: browsers block popups opened otherwise.