Updated on 2023-12-22 GMT+08:00

Adding a Department

Description

This API is used by an enterprise administrator to add a department. Up to 10 levels of departments with up to 100 sub-departments at each level can be added. By default, an enterprise can have up to 10,000 departments.

Debugging

You can debug this API in API Explorer.

Prototype

Table 1 Prototype

Request Method

POST

Request Address

/v1/usg/dcs/corp/dept

Transport Protocol

HTTPS

Request Parameters

Table 2 Parameters

Parameter

Mandatory

Type

Location

Description

X-Access-Token

Yes

String

Header

Authorization token. Use the value of accessToken in the response to the request for Authenticating an App ID.

X-Request-Id

No

String

Header

Request ID, which is used for fault tracing and locating. You are advised to use a UUID. If this parameter is not carried, a request ID is automatically generated.

Accept-Language

No

String

Header

Language. Values: zh-CN for Chinese (default) and en-US for English.

deptCode

No

String

Body

Unique department code in the enterprise. If this parameter is carried, the actual value is used and cannot be changed.

The value can contain up to 32 characters.

deptName

Yes

String

Body

Department name.

maxLength: 128

minLength: 1

parentDeptCode

No

String

Body

Parent department code. The default value is the root department code.

Default value: 1.

The value can contain up to 32 characters.

note

No

String

Body

Remarks.

maxLength: 96

minLength: 0

inPermission

No

String

Body

Permissions of users in other departments for accessing details of uses in this department.

  • UNLIMITED: not restricted. This is the default value.
  • OPEN: Details of users in this department are accessible to other departments (regardless of others' permission configurations).

outPermission

No

String

Body

Permissions of users in this department for accessing details of uses in other departments.

  • UNLIMITED: not restricted.
  • ONLY_SELF: Users in this department can only query details about themselves.
  • SELF_AND_CHILD_DEPARTMENT: Users in the department can query details of the department and its sub-departments.
  • DESIGNATED_DEPARTMENT: Users in this department can query details of specific departments.

designatedOutDeptCodes

No

Array of strings

Body

List of departments that can be accessed. This parameter is valid only when outPermission is set to DESIGNATED_DEPARTMENT. Up to 150 departments can be configured.

sortLevel

No

Integer

Body

Department sequence number. A department with a smaller sequence number is displayed first.

minimum: 1

maximum: 10000

Status Codes

Table 3 Status codes

HTTP Status Code

Description

200

Operation successful.

400

Invalid parameters.

401

Authentication is not performed or fails.

403

Insufficient permissions.

500

Server exception.

Response Parameters

Table 4 Response parameters

Parameter

Type

Description

value

String

Department code.

Example Request

POST /v1/usg/dcs/corp/dept
Connection: keep-alive
X-Access-Token: stbvmKo5lr6vT7QIzKHg4iqicUBcYMb3qlki
Content-Type: application/json
Content-Length: 31
Host: api.meeting.huaweicloud.com 
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_191)

{
    "deptName": "test999"
}

Example Response

HTTP/1.1 200 
Date: Tue, 17 Dec 2019 09:32:47 GMT
Content-Type: application/json;charset=UTF-8
Connection: keep-alive
Pragma: No-cache
Cache-Control: no-cache
Server: api-gateway
X-Request-Id: 539e8b710378987ffc5eb844b5e5c290

{
    "value": "s4f"
}

Error Codes

If an error code starting with MMC or USG is returned when you use this API, rectify the fault by following the instructions provided in Huawei Cloud API Error Center.

Example cURL Command

curl -k -i -H 'content-type: application/json' -X POST -H 'X-Access-Token: stbvmKo5lr6vT7QIzKHg4iqicUBcYMb3qlki' -d '{"deptName": "test999"}' https://api.meeting.huaweicloud.com/v1/usg/dcs/corp/dept