OU
Companies and organisation units. Guide: Companies.
const { OU } = sdk.asAdmin().Customers()
OU.create(body, options?)
POST /api/v2/entity/ou
| Body | Type | Description |
|---|---|---|
data | object | Required. Validated against the full OU schema by default (same fields as update, below) |
parent | string | humanId of the parent OU |
employees | [{ humanId, roles }] | Link people on creation. roles is [{ role, status }] |
groups | string[] | Group names |
Options: { return: true } responds with the created entity instead of { result: 'OK', humanId }. { schema: 'minimal' } validates against just ouType, name (≥ 3 chars) and legalForm instead. { strict: true } rejects any field in data not in the schema being validated against. Status 201.
Errors: entity/data-missing, entity/data-invalid, entity/parent-not-found, entity/invalid-parent, relationship/roles-required, relationship/role-missing, relationship/invalid-status, entity/group-…, validation { errors }. customers/group-not-found is thrown by the SDK for unknown group names.
OU.update(humanId, body)
PUT /api/v2/entity/ou/{humanId}
| Body | Description |
|---|---|
data | New data. Merged into the existing data by default |
overwrite | true: replace the entity's data entirely instead of merging. Fields on the entity but absent from data are deleted |
strict | true: reject any field in data not in the OU schema |
employees, groups | Replace the whole list |
return | Respond with the entity |
Updatable fields: active, avatar, ouType, name, legalForm, hasAddress, extra, street, houseNo, zipCode, city, countryCode, location, contacts, openingHours, website, hasBank, bankHistory.
Errors: entity/data-missing, entity/wrong-entity-type, validation { errors }.
OU.delete(humanId)
DELETE /api/v2/entity/ou/{humanId}. Status 200, { result: 'deleted', humanId }.
OU.move(humanId, targetHumanId?)
Move under a new parent. Without a target, the OU becomes a top-level company.
PUT /api/v2/entity/ou/{humanId}/parent/{target} or DELETE /api/v2/entity/ou/{humanId}/parent.
Errors: entity/parent-not-found, entity/invalid-parent.
OU.upsertEmployee(ouId, personId, roles, options?)
POST /api/v2/entity/ou/{ou}/employees/{person} with { data: { roles }, return? }.
roles: [{ role: string, status: 'active' | 'paused' | 'separated' | 'retired' | 'inactive' }].
OU.removeEmployee(ouId, personId)
DELETE /api/v2/entity/ou/{ou}/employees/{person}. Status 200, { result: 'deleted', humanId }.