Skip to main content
Call this API to get the Contacts permission scope of an admin.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/user/get_admin_scope
HTTP MethodPOST
Supported app typesappType-Internal app, appType-Third-party enterprise app
Required permissionspermission-qyapi_get_member-Read permission for user information

Query parameter

NameTypeRequiredExampleDescription
access_tokenStringYesbE74xxxxThe App credential used to call this API. - For an Internal app, obtain it through the API for getting the access_token of an internal app. - For a Third-party enterprise app, obtain it through the API for getting the access_token of a third-party enterprise.

Request body

NameTypeRequiredExampleDescription
useridStringYesmanger123The user ID of the Admin. Call the Get the admin list API to get the admin IDs in your current Organization.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/user/get_admin_scope" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=f928c8b2-5f41-4c92-908a-01fee1f20450' \
-d 'userid=manager7078'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/user/get_admin_scope");
OapiUserGetAdminScopeRequest req = new OapiUserGetAdminScopeRequest();
req.setUserid("manger123");
OapiUserGetAdminScopeResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiUserGetAdminScopeRequest("https://oapi.dingtalk.io/topapi/user/get_admin_scope")

req.userid="manager7078"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
PHP
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiUserGetAdminScopeRequest;
$req->setUserid("manager7078");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/user/get_admin_scope");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/user/get_admin_scope");
OapiUserGetAdminScopeRequest req = new OapiUserGetAdminScopeRequest();
req.Userid = "manager7078";
OapiUserGetAdminScopeResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
request_idStringzpucraudovy0The request ID.
errcodeNumber0The return code.
errmsgStringokThe description of the return code.
dept_idsNumber[][1]The List of Department IDs that the admin can manage.

Response body example

{
  "dept_ids": [
    1
  ],
  "errcode": 0,
  "errmsg": "ok",
  "request_id": "zpucraudovy0"
}

Error codes

If an error is returned when you call this API, find the solution in the Global error codes document based on the error message.
Error code (errcode)Error message (errmsg)Solution
60121Employee not foundConfirm whether the userId is correct.
40036Parameter is emptyConfirm that all required parameters are provided.
400001System errorTry again later.