The Connector SDK APIs are available through Forge's Early Access Program (EAP).
EAPs are offered to selected users for testing and feedback purposes. APIs and features under EAP are unsupported and subject to change without notice. APIs and features under EAP are not recommended for use in production environments.
To use the Connector SDK, you must be part of the Forge connector EAP. You can express interest in joining this EAP through this form.
The setGroups
method allows you to bulk create or update groups in the Teamwork Graph in a single
API call. This is the recommended approach for bulk group ingestion as it's more efficient than making
individual requests for each group.
1 2setGroups(request: BulkGroupsRequest): Promise<BulkGroupsResponse>
BulkGroupsRequest
1 2// BulkGroupsRequest object: { groups: GroupPayload[]; // groups: Array of groups to ingest (maximum 100 groups per request) }
The GroupPayload
type supports group information with optional members:
1 2type GroupPayload = { externalId: string; // Required: Unique external identifier for the group displayName?: string; // Optional: Display name for the group members?: GroupMember[]; // Optional: Array of group members };
1 2type GroupMember = { externalId: string; // Required: External identifier for the member type: string; // Required: Type of member (e.g., 'USER') updateSequenceNumber?: number; // Optional: Sequence number for tracking updates displayName?: string; // Optional: Display name for the member };
1 2import { graph } from '@forge/teamwork-graph'; const group = { externalId: 'developers', displayName: 'Development Team', members: [ { externalId: 'user-123', type: 'USER' }, { externalId: 'user-456', type: 'USER' } ] }; const request = { groups: [group] }; const response = await graph.setGroups(request);
1 2const groupWithoutMembers = { externalId: 'admins', displayName: 'Administrators' }; const response = await graph.setGroups({ groups: [groupWithoutMembers] });
1 2const groups = [ { externalId: 'developers', displayName: 'Development Team', members: [ { externalId: 'user-1', type: 'USER' }, { externalId: 'user-2', type: 'USER' } ] }, { externalId: 'designers', displayName: 'Design Team', members: [ { externalId: 'user-3', type: 'USER' }, { externalId: 'user-4', type: 'USER' } ] }, { externalId: 'managers', displayName: 'Management Team' } ]; const response = await graph.setGroups({ groups });
1 2const response = await graph.setGroups({ groups }); if (response.success && response.results) { response.results.forEach(result => { if (result.success) { console.log(`Successfully created group: ${result.externalId}`); } else { console.error(`Failed to create group ${result.externalId}: ${result.error}`); } }); }
The method validates the following:
groups
field must be a valid array.groups
array cannot be empty.Error message | Description |
---|---|
groups must be an array | The groups field is not an array. |
groups array cannot be empty | The groups array is empty. |
Bulk group ingestion supports maximum 100 groups. Received X | The number of groups per request has exceeded the maximum limit. |
The method returns a promise that resolves to a BulkGroupsResponse
object.
1 2// BulkGroupsResponse type BulkGroupsResponse = { success: boolean; results?: { success: Array<{ externalId: string; success: true; statusCode: number; // 200-299 }>; failures: Array<{ externalId: string; success: false; statusCode: number; // non 200-299 error: string; }>; }; error?: string; originalError?: unknown; };
The SDK provides type-safe request and response objects that ensure compile-time validation:
1 2import { types } from '@forge/teamwork-graph'; // Type-safe group creation const group: types.GroupPayload = { externalId: 'developers', displayName: 'Development Team', members: [ { externalId: 'user-123', type: 'USER' } as types.GroupMember ] }; // Type-safe request creation const request: types.BulkGroupsRequest = { groups: [group] }; // Type-safe response handling const response = await graph.setGroups(request); if (response.success && response.results) { // TypeScript knows results exists here and provides proper typing response.results.success.forEach(result => { // result is properly typed with externalId, success, and statusCode properties console.log(`Successfully created group: ${result.externalId}`); }); response.results.failures.forEach(result => { // result is properly typed with error information console.error(`Failed to create group: ${result.externalId}, Error: ${result.error}`); }); }
The type system ensures:
group
object has correct GroupPayload
structure with proper member typesrequest.groups
must be an array of GroupPayload
objectsresponse.results
has properly typed success
and failures
arraysRate this page: