获取根部门

API 说明

获取当前企业的根部门信息。根部门是企业组织架构树的顶层节点,所有其他部门均为其直接或间接子部门。

注意事项

使用限制

请求说明

字段
请求地址https://openapi.wps.cn/v7/depts/root
HTTP 方法GET
签名方式KSO-1
限频策略应用 10次/秒
权限要求查询和管理通讯录信息(应用授权) kso.contact.readwrite
查询通讯录信息(应用授权) kso.contact.read

请求头(Headers)

Header 名称参数类型是否必填可选值限制示例描述
Content-Typestringapplication/json-application/json请求内容类型(该接口为 GET 请求,可省略)
X-Kso-Datestring-必须符合 RFC1123 规范Thu, 29 May 2026 07:00:00 GMTRFC1123 格式的日期时间
X-Kso-Authorizationstring--KSO-1 AK…:…KSO-1 签名值,详见 签名方法
Authorizationstring-必须以 Bearer 开头Bearer {access_token}授权凭证,格式为:Bearer {access_token},获取方式详见 认证授权概述

请求示例

cURL

bash
curl -X GET "https://openapi.wps.cn/v7/depts/root" \
  -H "Authorization: Bearer {access_token}" \
  -H "X-Kso-Date: Thu, 29 May 2026 07:00:00 GMT" \
  -H "X-Kso-Authorization: {kso1_signature}"

Go

go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("GET", "https://openapi.wps.cn/v7/depts/root", nil)
	req.Header.Set("Authorization", "Bearer {access_token}")
	req.Header.Set("X-Kso-Date", "Thu, 29 May 2026 07:00:00 GMT")
	req.Header.Set("X-Kso-Authorization", "{kso1_signature}")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	respBody, _ := io.ReadAll(resp.Body)
	fmt.Println(string(respBody))
}

响应体(Response)

参数名称参数类型可选值限制示例描述
codeinteger--0响应代码。非 0 表示失败,参照《状态码说明》
msgstring-最大长度 128"success"响应信息
dataobject--根部门信息
∟ idstring-字符长度[1,128]"dept_root_001"部门 ID
∟ namestring-字符长度[1,128]"金山办公"部门名称
∟ parent_idstring-字符长度[1,128]"0"父部门 ID(根部门的父部门 ID 为 "0"
∟ orderinteger--0排序值
∟ abs_pathstring-最大长度 1024"/金山办公"绝对路径
∟ ex_dept_idstring-最大长度 128""部门外部 ID,可以是外部身份源的 ID,为空则默认为部门 ID
∟ leadersarray[object]-最大 10 项部门领导列表(经可见性过滤)
∟∟ user_idstring-字符长度[1,128]"uid_example_001"领导用户 ID
∟∟ orderinteger--0排序值
∟ ctimeinteger--1682000000创建时间,Unix 时间戳(秒)

响应示例

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "id": "dept_root_001",
    "name": "金山办公",
    "parent_id": "0",
    "order": 0,
    "abs_path": "/金山办公",
    "ex_dept_id": "",
    "leaders": [
      {
        "user_id": "uid_example_001",
        "order": 0
      }
    ],
    "ctime": 1682000000
  }
}

错误码

HTTP状态码错误码错误描述排查建议
400400002113根部门不存在企业可能尚未初始化组织架构,请联系管理员确认
401401000001access_token 无效或已过期检查 Authorization 头中的 token 是否正确,是否已过期,需重新获取
403403000001权限不足确认应用已被授予 kso.contact.readkso.contact.readwrite 权限;确认根部门在应用的通讯录可见范围内
429429000001请求频率超限降低请求频率
500500000004服务内部错误请稍后重试,若持续出现请联系技术支持

元信息

yaml
---
name: open_v7_get_root_dept
description: "获取根部门"
metadata:
  business_domain: "通讯录"
  updated-on: "2026-05-29"
  tags: "dept"
  operation-id: "open_v7_get_root_dept"
  sign-type: "[KSO-1](https://365.kdocs.cn/3rd/open/documents/app-integration-dev/wps365/server/api-description/signature-description)"
  auth-type: "app_access_token"
  scopes: "kso.contact.read"
  rate-limit: "应用 10次/秒"
---