Namespace

OU

CustomersService#OU

Organisational Unit (OU) operations.

View Source services/CustomersService.class.js, line 165

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>

humanId of the parent OU.

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 humanId and a non-empty roles array. Each role entry requires role (string) and status (one of 'active', 'paused', 'separated', 'retired', 'inactive').

options Object <optional>
return boolean <optional>

When true, returns the created entity instead of { result: 'OK' }.

View Source services/CustomersService.class.js, line 191

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.

View Source services/CustomersService.class.js, line 217

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 humanId. Omit to detach from the current parent (makes the OU root-level).

View Source services/CustomersService.class.js, line 231

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.

View Source services/CustomersService.class.js, line 265

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. { data: { name: 'New Name' } }).

View Source services/CustomersService.class.js, line 205

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 role (string) and status.

options Object <optional>
return boolean <optional>

When true, returns the updated person entity.

View Source services/CustomersService.class.js, line 252

Promise.<ServiceResponse>
Example
await customers.OU.upsertEmployee('ou-engineering', 'person-ada', [
  { role: 'Engineer', status: 'active' }
])