Establish a department
Code Mode: praxis.workforce.departments.create
HTTP: POST /workforce/v1/departments
Creates a department under an existing active parent department; use it to grow the tree, and use reorganize to rename or move one that already exists. order defaults to one after the last active sibling. The new department has no head position: open a position in it, then designate that position as head. Requires an organization owner or admin, or the head of the parent department or of a department above it. Errors: 400 INVALID_PARAMS for a missing or empty name, a name over 100 characters, an unknown body field or an active sibling with the same name; 403 PERMISSION_DENIED; 404 DEPARTMENT_NOT_FOUND when the parent does not exist; 409 DEPARTMENT_DISSOLVED when the parent is dissolved. Example body: {“parent_id”:“dept_123”,“name”:“Support”}.
签名
praxis.workforce.departments.create(args:{body:{/** Id of the active department (dept_...) to create the new one under; list departments to find it. */ parent_id:string;/** Name of the new department, 1 to 100 characters; must not equal an active sibling's name. e.g. "Support" */ name:string;/** Sort position among siblings; omit to place it after the last active sibling. */ 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}>;请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 201 | application/json | The new department. |
| 400 | application/problem+json | INVALID_PARAMS; fix the name or the unknown body field named in the message, or pick a name no active sibling uses. |
| 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, or the head of the parent department or of a department above it 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; parent_id is not a department of your organization. List departments and copy an id. |
| 409 | application/problem+json | DEPARTMENT_DISSOLVED; the parent department was dissolved. Choose an active parent. |