Skip to main content
Call this API to get the tags of external contacts in your organization. Use this API to retrieve the list of external contact tags. For example, if an external contact is a customer of the company, the tag may be “Customer”.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/extcontact/listlabelgroups
HTTP MethodPOST
Supported app typesappType-Internal app appType-Third-party enterprise app
Required permissionspermission-qyapi_ext_read-Read permission for external contacts of the organization

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
sizeNumberNo20Supports pagination. Takes effect only when set together with the offset parameter. This parameter indicates the page size, with a maximum of 100.
offsetNumberNo0Supports pagination. Takes effect only when set together with the size parameter. This parameter indicates the offset, which starts from 0.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/extcontact/listlabelgroups" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=e6eaxxxxa401' \
-d 'offset=0' \
-d 'size=20'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/listlabelgroups");
OapiExtcontactListlabelgroupsRequest req = new OapiExtcontactListlabelgroupsRequest();
req.setSize(20L);
req.setOffset(0L);
OapiExtcontactListlabelgroupsResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiExtcontactListlabelgroupsRequest("https://oapi.dingtalk.io/topapi/extcontact/listlabelgroups")

req.size=20
req.offset=0
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 OapiExtcontactListlabelgroupsRequest;
$req->setSize("20");
$req->setOffset("0");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/extcontact/listlabelgroups");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/extcontact/listlabelgroups");
OapiExtcontactListlabelgroupsRequest req = new OapiExtcontactListlabelgroupsRequest();
req.Size = 20L;
req.Offset = 0L;
OapiExtcontactListlabelgroupsResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
resultsOpenLabelGroup[]The query results.
nameStringTypeThe name of the tag group.
colorNumber-15220075The color of the tag group.
labelsOpenLabel[]The list of tags.
nameStringCustomerThe name of the tag.
idNumber1026002The tag ID.
errcodeNumber0The return code.
request_idString8n3mksu5hqzyThe request ID.

Response body example

{
  "errcode":0,
  "results":[
    {
      "color":-15220075,
      "name":"Type",
      "labels":[
        {
          "name":"Customer",
          "id":1561077310
        },
        {
          "name":"Channel partner",
          "id":1561077311
        },
        {
          "name":"Supplier",
          "id":1561077312
        },
        {
          "name":"Partner",
          "id":1561077313
        },
        {
          "name":"Interviewee",
          "id":1561077314
        },
        {
          "name":"Other type",
          "id":1561077315
        }
      ]
    },
    {
      "color":-11687445,
      "name":"Level",
      "labels":[
        {
          "name":"General",
          "id":1561077317
        },
        {
          "name":"Important",
          "id":1561077318
        },
        {
          "name":"Core",
          "id":1561077319
        }
      ]
    },
    {
      "color":-543394,
      "name":"Status",
      "labels":[
        {
          "name":"Potential",
          "id":1561077321
        },
        {
          "name":"Interested",
          "id":1561077322
        },
        {
          "name":"In negotiation",
          "id":1561077323
        },
        {
          "name":"Closed deal",
          "id":1561077324
        },
        {
          "name":"Lost",
          "id":1561077325
        }
                        ]
                },
                {
                        "color":-543394,
                        "name":"Recruitment status",
                        "labels":[
                                {
                                        "name":"To be invited",
                                        "id":1561077327
                                },
                                {
                                        "name":"To be interviewed",
                                        "id":1561077328
                                },
                                {
                                        "name":"First-round interview",
                                        "id":1561077329
                                },
                                {
                                        "name":"Second-round interview",
                                        "id":1561077330
                                },
                                {
                                        "name":"Onboarded",
                                        "id":1561077331
                                }
                        ]
                }
        ],
        "request_id":"51jof1jt5f4t"
}

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
33009Invalid tokenGrantTypeCheck whether the access_token is correct.
400043Invalid orgIdCheck whether the access_token is correct.
41101Invalid sizeCheck whether the page size is valid.
40068Invalid offsetAdjust the offset.
-1System busyTry again later.