Reorganize a department
Code Mode: praxis.workforce.departments.update
HTTP: PATCH /workforce/v1/departments/{id}
Renames a department, moves it under another parent, or changes its sort order; send at least one of parent_id, name and order. Sub-departments and positions move with it. Requires an organization owner or admin. The root department is the organization itself: its name is the organization’s name and cannot be changed here (rename the organization in its settings), and it can never be moved, but its order can change. Errors: 400 INVALID_PARAMS when no field is given, a name is empty or over 100 characters, or a department already has that name under the same parent; 400 DEPARTMENT_CYCLE when the new parent is the department itself or one of its descendants; 403 PERMISSION_DENIED; 404 DEPARTMENT_NOT_FOUND for the department or the new parent; 409 DEPARTMENT_DISSOLVED when either is dissolved; 409 DEPARTMENT_ROOT_IMMUTABLE when parent_id or name is sent for the root.
Signature
praxis.workforce.departments.update(args:{path:{id:string};body:{/** Id of the new parent department (dept_...); not allowed for the root, and never the department itself or a descendant. */ parent_id?:string;/** New department name, 1 to 100 characters; must not equal a sibling's name, and is refused for the root, whose name is the organization's name. */ name?:string;/** New sort position among siblings; lower values come first. */ order?:number}}):Promise<{/** Department id (dept_...); use it as department_id and parent_id. */ id:string;/** Id of the organization that owns the department. */ organization_id:string;/** Id of the parent department; null for the root department, which every organization has exactly once. */ parent_id:string|null;/** Department name, 1 to 100 characters; unique among the active departments under one parent; the root department carries the organization's name. */ name:string;/** Sort position among siblings; lower values come first. */ order:number;/** Id of the position that heads the department; null while no position has been designated head; the root department's head position is created with the organizat */ head_position_id:string|null;/** Whether the department is part of the tree or was dissolved. */ status:"active"|"dissolved";/** UTC instant (RFC 3339) when the department was established. */ create_time:string;/** UTC instant (RFC 3339) of the latest change to the department. */ update_time:string}>;Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | Department id (dept_…) to change, from the departments list. |
Request body
| Required | Content types | Description |
|---|---|---|
| yes | application/json |
Responses
| Status | Content types | Description |
|---|---|---|
| 200 | application/json | The department after the change. |
| 400 | application/problem+json | INVALID_PARAMS or DEPARTMENT_CYCLE; send at least one valid field, and never move a department under itself or its descendants. |
| 401 | Missing or invalid credential; provide a valid organization API key or sign in to the Console. | |
| 403 | application/problem+json | PERMISSION_DENIED; an organization owner or admin may call this, and machine tokens are always refused (an agent’s session token may read the organization, never change it). Use an API key or Console session of an allowed role. |
| 404 | application/problem+json | DEPARTMENT_NOT_FOUND; the department or the new parent does not exist. List departments and copy ids. |
| 409 | application/problem+json | DEPARTMENT_DISSOLVED or DEPARTMENT_ROOT_IMMUTABLE; use active departments, and do not send parent_id or name for the root. |