Departments

Lists and gets departments for the current tenant; create, update, delete. Set tenant context before calling these methods.

List departments

List all departments for the current tenant (from v_departments).

client.departments.list()

const departments = await client.departments.list()
// Returns DepartmentRow[]

Get by ID

Fetch a single department by ID.

client.departments.getById(id)

const department = await client.departments.getById('uuid-of-department')
// Returns DepartmentRow | null

Create department

Create a new department. Returns the new department UUID.

client.departments.create(params)

const departmentId = await client.departments.create({
  tenantId: 'uuid-of-tenant',
  name: 'Maintenance',
  description: 'Facilities maintenance',
  code: 'MNT',
})
// Returns string (UUID)
  • Name
    tenantId
    Description

    Required. Tenant UUID.

  • Name
    name
    Description

    Required. Department display name.

  • Name
    description
    Description

    Optional. Description.

  • Name
    code
    Description

    Optional. Department code.

Update department

Update an existing department. All fields except tenantId and departmentId are optional.

client.departments.update(params)

await client.departments.update({
  tenantId: 'uuid-of-tenant',
  departmentId: 'uuid-of-department',
  name: 'Facilities & Maintenance',
  description: null,
  code: 'FM',
})

Delete department

Delete a department by tenant and department ID.

client.departments.delete(tenantId, departmentId)

await client.departments.delete('uuid-of-tenant', 'uuid-of-department')

Was this page helpful?