Skip to content

Groups

Public surface of the Groups service.

Groups are organization-scoped containers of users. Together with users they form the basis of access management: put users in groups, then grant roles to the groups. Membership can be edited from the group side (this service) or from the user side (users.updateById() with groupIdsToAdd / groupIdsToRemove).

Usage

Prerequisites: Initialize the SDK first - see Getting Started

import { Groups } from '@uipath/uipath-typescript/groups';

const groups = new Groups(sdk);
const allGroups = await groups.getAll();

Methods

create()

create(name: string, options?: PlatformGroupCreateOptions): Promise<PlatformGroupGetResponse>

Creates a local group.

Members can be added at creation through memberUserIds, or later — from the group side with updateById(), or from the user side with users.updateById().

Parameters

Parameter Type Description
name string Name of the new group
options? PlatformGroupCreateOptions Initial members

Returns

Promise<PlatformGroupGetResponse>

The created group, as a PlatformGroupGetResponse

Examples

const group = await groups.create('Ticket Admins');
const group = await groups.create('Ticket Admins', {
  memberUserIds: ['<userId>'],
});

deleteById()

deleteById(groupId: string): Promise<void>

Deletes a local group. Built-in groups cannot be deleted.

Parameters

Parameter Type Description
groupId string GUID of the group to delete

Returns

Promise<void>

Resolves when the group has been deleted

Example

await groups.deleteById('<groupId>');

getAll()

getAll(): Promise<PlatformGroupGetResponse[]>

Gets all local and built-in groups of the organization the SDK is configured for.

Returns every group with its type (built-in or custom) and timestamps. Built-in groups (Everyone, Administrators, …) cannot be modified or deleted.

Returns

Promise<PlatformGroupGetResponse[]>

All groups, as PlatformGroupGetResponse items

Example

import { UiPath } from '@uipath/uipath-typescript/core';
import { Groups } from '@uipath/uipath-typescript/groups';

const sdk = new UiPath(config);
await sdk.initialize();

const groups = new Groups(sdk);
const allGroups = await groups.getAll();
const admins = allGroups.find(g => g.name === 'Administrators');

getById()

getById(groupId: string): Promise<PlatformGroupGetResponse>

Gets a group by ID.

Parameters

Parameter Type Description
groupId string GUID of the group

Returns

Promise<PlatformGroupGetResponse>

The group, as a PlatformGroupGetResponse

Example

// Get a group id from the listing first
const allGroups = await groups.getAll();

const group = await groups.getById(allGroups[0].id);

getMembers()

getMembers<T>(groupId: string, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<PlatformGroupMember> : NonPaginatedResponse<PlatformGroupMember>>

Gets the local members of a group, with optional pagination.

Returns member references (id and account type). Fetch full profiles with users.getById() when needed. Note: membership of implicit groups (e.g. Everyone) is not materialized — they report no local members.

Type Parameters

Type Parameter Default type
T extends PaginationOptions PaginationOptions

Parameters

Parameter Type Description
groupId string GUID of the group
options? T Pagination options

Returns

Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<PlatformGroupMember> : NonPaginatedResponse<PlatformGroupMember>>

All members when no pagination options are given, one page otherwise, as PlatformGroupMember items

Examples

const members = await groups.getMembers('<groupId>');
const page1 = await groups.getMembers('<groupId>', { pageSize: 50 });
if (page1.hasNextPage) {
  const page2 = await groups.getMembers('<groupId>', { cursor: page1.nextCursor });
}

updateById()

updateById(groupId: string, update: PlatformGroupUpdateOptions): Promise<PlatformGroupGetResponse>

Updates a local group.

Only the fields present in update are changed — omitted fields keep their current values. Membership is edited incrementally through memberUserIdsToAdd / memberUserIdsToRemove. Built-in groups cannot be updated.

The name must be sent on every write, so a membership-only update first reads the group's current name. A rename that lands between that read and the write is overwritten with the earlier name — pass name explicitly to avoid the read.

Parameters

Parameter Type Description
groupId string GUID of the group to update
update PlatformGroupUpdateOptions The fields to change

Returns

Promise<PlatformGroupGetResponse>

The group as stored after the update, as a PlatformGroupGetResponse

Examples

const updated = await groups.updateById('<groupId>', { name: 'Ticket Managers' });
await groups.updateById('<groupId>', {
  memberUserIdsToAdd: ['<userId>'],
  memberUserIdsToRemove: ['<otherUserId>'],
});