Sorry, I should have clarified that my script is TypeScript, which you have to run with Node.js locally on your machine.
To run it you will need to start by installing npm.
Then open your Command Prompt and:
1. Create a project folder and init
mkdir group-assign && cd group-assign
npm init -y
2. Install dependencies
npm install purecloud-platform-client-v2 lodash
3. Save the script as assign-members.ts
4. Set environment variables for an OAuth Client you'd have to create
export GENESYS_REGION=mypurecloud.com
export GENESYSCLOUD_OAUTHCLIENT_ID=your-client-id
export GENESYSCLOUD_OAUTHCLIENT_SECRET=your-client-secret
5. Run it
npx tsx assign-members.ts
------------------------------
Lucas Woodward
Winner of Orchestrator of the Year, Developer (2025)
LinkedIn -
https://www.linkedin.com/in/lucas-woodward-the-devNewsletter -
https://makingchatbots.com------------------------------
Original Message:
Sent: 02-25-2026 17:09
From: Mostafa OUDDERHEM
Subject: Bulk Assignment of Users to a Group
Hi Lucas, many thanks for this code, do you know how I can use it within Genesys ?
------------------------------
Mostafa OUDDERHEM
Ingénieur
------------------------------
Original Message:
Sent: 02-25-2026 16:30
From: Lucas Woodward
Subject: Bulk Assignment of Users to a Group
In the past I used the endpoint POST /api/v2/groups/{groupId}/members, which allows you to add 50 members at a time.
This is the code I wrote:
import * as platformClient from 'purecloud-platform-client-v2';import console from 'console';import { chunk } from 'lodash';const groupId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx';const userIdsAssign = [ // LIST OF USER IDS HERE 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx',];(async () => { const { GENESYS_REGION, GENESYSCLOUD_OAUTHCLIENT_ID, GENESYSCLOUD_OAUTHCLIENT_SECRET } = process.env; if (!GENESYS_REGION || !GENESYSCLOUD_OAUTHCLIENT_ID || !GENESYSCLOUD_OAUTHCLIENT_SECRET) { throw new Error('Environment variable not set'); } const apiClient = platformClient.ApiClient.instance; apiClient.setEnvironment(GENESYS_REGION); await apiClient.loginClientCredentialsGrant( GENESYSCLOUD_OAUTHCLIENT_ID, GENESYSCLOUD_OAUTHCLIENT_SECRET, ); const userIds = chunk(userIdsAssign, 50); const groupsApi = new platformClient.GroupsApi(); for (const chunk of userIds) { const response = await groupsApi.postGroupMembers(groupId, { memberIds: chunk, }); console.log(response); }})().catch((e) => { throw e;});
------------------------------
Lucas Woodward
Winner of Orchestrator of the Year, Developer (2025)
LinkedIn - https://www.linkedin.com/in/lucas-woodward-the-dev
Newsletter - https://makingchatbots.com