Tenants

Lists tenants the current user is a member of; create tenants, invite users, assign roles. Tenant context is not required for tenants; use setTenant for work orders, assets, and other tenant-scoped resources.

List tenants

List all tenants the authenticated user is a member of (from v_tenants).

client.tenants.list()

const tenants = await client.tenants.list()
// Returns TenantRow[]

Get by ID

Fetch a single tenant by ID.

client.tenants.getById(id)

const tenant = await client.tenants.getById('uuid-of-tenant')
// Returns TenantRow | null

Create tenant

Create a new tenant. The authenticated user becomes a member and is assigned the admin role. Returns the new tenant UUID.

client.tenants.create(params)

const tenantId = await client.tenants.create({
  name: 'Acme Corp',
  slug: 'acme-corp',
})
// Returns string (UUID)
  • Name
    name
    Description

    Required. Tenant display name.

  • Name
    slug
    Description

    Required. Unique slug.

Invite user

Invite a user to a tenant with a role (e.g. admin, member). The invitee receives an invite; they must accept to join.

client.tenants.inviteUser(params)

await client.tenants.inviteUser({
  tenantId: 'uuid-of-tenant',
  inviteeEmail: 'newuser@example.com',
  roleKey: 'member',
})
  • Name
    tenantId
    Description

    Required. Tenant UUID.

  • Name
    inviteeEmail
    Description

    Required. Invitee email.

  • Name
    roleKey
    Description

    Required. Role key (e.g. admin, member).

Assign role

Assign a role to an existing user in a tenant.

client.tenants.assignRole(params)

await client.tenants.assignRole({
  tenantId: 'uuid-of-tenant',
  userId: 'uuid-of-user',
  roleKey: 'member',
})
  • Name
    tenantId
    Description

    Required. Tenant UUID.

  • Name
    userId
    Description

    Required. User UUID (Supabase Auth).

  • Name
    roleKey
    Description

    Required. Role key.

Was this page helpful?