Skip to main content

OU

Companies and organisation units. Guide: Companies.

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

OU.create(body, options?)​

POST /api/v2/entity/ou

BodyTypeDescription
dataobjectRequired. Validated against the full OU schema by default (same fields as update, below)
parentstringhumanId of the parent OU
employees[{ humanId, roles }]Link people on creation. roles is [{ role, status }]
groupsstring[]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}

BodyDescription
dataNew data. Merged into the existing data by default
overwritetrue: replace the entity's data entirely instead of merging. Fields on the entity but absent from data are deleted
stricttrue: reject any field in data not in the OU schema
employees, groupsReplace the whole list
returnRespond 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 }.