Skip to main content

Group

Guide: Groups.

const { Group } = sdk.asAdmin().Customers()

Group.create(data, options?)​

POST /api/v2/entity/group

Different signature

data is the first argument itself, not { data } as with OU.create and Person.create.

dataDescription
nameRequired, unique
groupTypemanual (default) or filter
labelsstring[]

data is validated against the full Group schema by default (name is the only required field either way). Options: members (array of humanIds), return, schema ('minimal' validates against just name), strict (rejects any field in data not in the schema being validated against).

Errors: entity/group-already-exists, validation { errors }.

Group.update(humanId, body)​

PUT /api/v2/entity/group/{humanId}. Body: data (merged by default), overwrite (replace entirely instead of merging), strict (reject unknown fields in data), return. The server also accepts config and features, used by the Customers app for filter groups.

Errors: entity/data-missing, entity/group-already-exists, group/config-invalid, group/features-invalid.

Group.delete(humanId)​

DELETE /api/v2/entity/group/{humanId}. Status 200, { result: 'deleted', humanId }.

Group.upsertMember(groupId, targetId, body?)​

POST /api/v2/entity/group/{group}/members/{target}. Adds a company or person. Result { result: 'OK', humanId }.

Group.removeMember(groupId, targetId)​

DELETE /api/v2/entity/group/{group}/members/{target}. Status 200, { result: 'deleted', humanId }.

Known issues​

  • Group.create(data, { members: [...] }) sends members as a list of humanId strings, but the server maps each entry as { humanId }. Until this is aligned, add members with upsertMember.