This guide walks the full bootstrap of a new tenant: an owner signs up, creates the tenant, invites members with a role, and reads the member list back. The account that creates a tenant becomes its owner; every member you add lands in the same tenant under whatever role you choose (owner, admin, or member).
-
Construct a
GatekeeperCoreand anAuthService, sign up the owner, and set the returned access token on the core so the next calls are authenticated. -
Create the tenant.
tenants.create(name)returns the new tenant, whoseidyou pass to every member call. -
Add members.
addMember(tenantId, userId, role)defaults the role tomemberwhen omitted. -
List members to confirm the roster.
import { GatekeeperCore, AuthService, TenantsService } from '@orkait/sdk';
const core = new GatekeeperCore({ baseUrl: 'https://gatekeeper-api.example.workers.dev' });
// 1. Sign up the owner and authenticate the core.
const auth = new AuthService(core);
const tokens = await auth.signup({
email: 'owner@acme.com',
password: 'hunter2-strong-pass',
name: 'Acme Owner',
});
core.setToken(tokens.accessToken);
// 2. Create the tenant - the signed-in user becomes its owner.
const tenants = new TenantsService(core);
const tenant = await tenants.create('Acme Inc');
// 3. Add members. The third argument is the role; it defaults to 'member'.
await tenants.addMember(tenant.id, 'user_engineer_1', 'admin');
await tenants.addMember(tenant.id, 'user_engineer_2'); // role -> 'member'
// 4. List the roster.
const members = await tenants.listMembers(tenant.id);
for (const m of members.items) {
console.log(`${m.userId} -> ${m.role}`);
}