createWorkspaceRole()
Creates a workspace role with name and permissions.
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 createWorkspaceRole(workspaceId: string) { const client = await wachtClient(); return client.workspaces.createWorkspaceRole(workspaceId, { name: 'moderator', permissions: ['workspaces.members.read'], });}Signature
function createWorkspaceRole( workspaceId: string, request: CreateWorkspaceRoleRequest,): Promise<WorkspaceRole>CreateWorkspaceRoleRequest
›workspaceId?: string | undefined;
workspaceId?: string | undefined;Target workspace id.
›name?: string | undefined;
name?: string | undefined;Role display name.
›permissions?: string[] | undefined;
permissions?: string[] | undefined;Permission identifiers for this role.
Return value
›id?: string | undefined;
id?: string | undefined;Created workspace role id.
›name?: string | undefined;
name?: string | undefined;Created role display name.
›permissions?: string[] | undefined;
permissions?: string[] | undefined;Permissions attached to this role.
Behavior
- Operates on workspace-scoped role definitions.
- Validate required fields before calling to avoid predictable request failures.