Skip to content
v2.7

Teams

Group users into teams, invite members and grant access by role.

A team brings together users who share access: a customer company, a class, a moderation crew. Each member has roles within the team (free text, such as editor or finance), and permissions can point to the whole team or just to one role.

times.ts
import { ID, Teams } from '@owbase/web';
import { client } from './client';
const teams = new Teams(client);
// Whoever creates the team becomes its owner ("owner" role).
const team = await teams.create({ teamId: ID.unique(), name: 'Moderation' });
// Invites by email; the invitation link leads to this page of your app.
await teams.createMembership({ teamId: team.$id, roles: ['editor'], email: '[email protected]', url: 'https://app.example.com/invite' });
// On the /invite page: the link arrives with ?teamId=…&membershipId=…&userId=…&secret=…
const p = new URLSearchParams(window.location.search);
await teams.updateMembershipStatus({
teamId: p.get('teamId') ?? '',
membershipId: p.get('membershipId') ?? '',
userId: p.get('userId') ?? '',
secret: p.get('secret') ?? '',
});
const { memberships } = await teams.listMemberships({ teamId: team.$id });
console.log(memberships.map((m) => `${m.userName}: ${m.roles.join(', ')}`));
  • createMembership with email creates the membership and sends the invitation right away; it stays pending until the person accepts on the url page, with updateMembershipStatus. If they don’t have an account yet, one is created along with the invitation.
  • From the server (@owbase/node, teams.write scope), createMembership with userId adds the member directly, with no invitation. With email, the server also adds the member directly, without waiting for acceptance.
Permission Who
Permission.read(Role.team('t1')) all members of team t1
Permission.update(Role.team('t1', 'editor')) only members with the editor role

In the console, teams are under Auth → Teams.

Was this page helpful?