Organisational Unit (OU) operations.
Methods
# static create(body, optionsopt) → {Promise.<ServiceResponse>}
Creates a new Organisational Unit.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
body |
Object
|
||
data |
Object
|
OU field values. |
|
parent |
string
|
<optional> |
|
groups |
Array.<string>
|
<optional> |
Group names to add the OU to immediately. Names are resolved to humanIds automatically. |
employees |
Array.<{humanId: string, roles: Array.<{role: string, status: ('active'|'paused'|'separated'|'retired'|'inactive')}>}>
|
<optional> |
Persons to add as employees. Each entry must include |
options |
Object
|
<optional> |
|
return |
boolean
|
<optional> |
When |
Promise.<ServiceResponse>
Example
const { result } = await customers.OU.create(
{
data: { name: 'Engineering', costCenter: 'CC-42' },
parent: 'ou-root',
groups: ['group-admins'],
employees: [{ humanId: 'person-ada', roles: [{ role: 'Engineer', status: 'active' }] }]
},
{ return: true }
)
# static delete(humanId) → {Promise.<ServiceResponse>}
Deletes an Organisational Unit.
Parameters:
| Name | Type | Description |
|---|---|---|
humanId |
string
|
The OU's human-readable identifier. |
Promise.<ServiceResponse>
# static move(humanId, targetHumanIdopt) → {Promise.<ServiceResponse>}
Moves an OU to a new parent, or removes its parent entirely.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
humanId |
string
|
The OU to move. |
|
targetHumanId |
string
|
<optional> |
The new parent OU's |
Promise.<ServiceResponse>
Example
await customers.OU.move('ou-engineering', 'ou-product') // reparent
await customers.OU.move('ou-engineering') // remove parent
# static removeEmployee(ouHumanId, personHumanId) → {Promise.<ServiceResponse>}
Removes a person from an OU's employee list.
Parameters:
| Name | Type | Description |
|---|---|---|
ouHumanId |
string
|
The OU's human-readable identifier. |
personHumanId |
string
|
The person's human-readable identifier. |
Promise.<ServiceResponse>
# static update(humanId, body) → {Promise.<ServiceResponse>}
Updates an existing Organisational Unit.
Parameters:
| Name | Type | Description |
|---|---|---|
humanId |
string
|
The OU's human-readable identifier. |
body |
Object
|
Update payload (e.g. |
Promise.<ServiceResponse>
# static upsertEmployee(ouHumanId, personHumanId, roles, optionsopt) → {Promise.<ServiceResponse>}
Adds or updates a person's employment in an OU.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ouHumanId |
string
|
The OU's human-readable identifier. |
|
personHumanId |
string
|
The person's human-readable identifier. |
|
roles |
Array.<{role: string, status: ('active'|'paused'|'separated'|'retired'|'inactive')}>
|
Required. Each entry needs |
|
options |
Object
|
<optional> |
|
return |
boolean
|
<optional> |
When |
Promise.<ServiceResponse>
Example
await customers.OU.upsertEmployee('ou-engineering', 'person-ada', [
{ role: 'Engineer', status: 'active' }
])