NewWacht Bench is live — AI-assisted development for Wacht

createOrganizationRole()

Creates an organization role with a name and permissions list.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function createRole(organizationId: string) {  const client = await wachtClient();  return client.organizations.createOrganizationRole(organizationId, {    name: 'support-agent',    permissions: ['organizations.members.read'],  });}

Signature

function createOrganizationRole(  organizationId: string,  request: CreateOrganizationRoleRequest,): Promise<OrganizationRole>

Parameters

organizationId?: string | undefined;
Stable organization id.
request.name?: string | undefined;
Role name.
request.permissions?: string[] | undefined;
Permission identifiers for this role.

Behavior

  • Operates on organization-scoped role definitions.
  • Validate required fields before calling to avoid predictable request failures.

On this page