Skip to main content
Call this API to create a new user.

API call description

This API supports creating either a regular user or an Enterprise Account user. Because parameter usage differs significantly between the two scenarios, the documentation is split by account type for clarity:

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/topapi/v2/user/create
HTTP MethodPOST
Supported app typesappType-Internal app
Required permissionspermission-qyapi_manage_addresslist-Contacts data management permission

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYesBE3xxxxThe app credential for calling this API. Obtain it by calling the API that retrieves the access_token of an internal app.

Request body

NameTypeRequiredExampleDescription
useridStringNozhangsanThe unique identifier of the employee (cannot be modified). It must be unique within your organization. The length must be 1 to 64 characters. If not specified, a userid is automatically generated.
nameStringYesZhang SanThe employee name. Maximum 80 characters.
mobileStringYes185xxxxThe mobile number. It must be unique within your organization and cannot be duplicated. - For international numbers or numbers from Hong Kong (China), Macao (China), or Taiwan (China), use the format +xx-xxxxxx. - If the company is registered outside the Chinese mainland, use the format +86-xxxxxx when adding a user. Note Sign in to the DingTalk Admin Console to view the organization’s registered address.
hide_mobileBooleanNofalseWhether to hide the mobile number: - true: Hide. After the mobile number is hidden, it is not displayed on the Profile page, but other users can still send DINGs and initiate free DingTalk business calls. - false: Do not hide.
telephoneStringNo010-86123456-2345The extension number. Maximum 50 characters. Note Extension numbers must be unique within your organization.
job_numberStringNo4The Employee ID. Maximum 50 characters.
titleStringNoTechnical DirectorThe Job Title. Maximum 200 characters.
emailStringNotest@xxx.comThe personal Mail of the employee. Maximum 50 characters. Note Employee mail addresses must be unique within your organization.
org_emailStringNotest@xxx.comThe Enterprise Mail of the employee. Maximum 100 characters. Note This field takes effect only when Enterprise Mail has been activated for the employee.
org_email_typeStringNoprofessionThe Enterprise Mail type of the employee. - profession: Standard - base: Basic
work_placeStringNoFuture ParkThe Work Location. Maximum 100 characters.
remarkStringNoAliasThe alias. Maximum 2000 characters.
dept_id_listStringYes”2,3,4”The list of department IDs the employee belongs to. Up to 100 department IDs can be passed per call.
dept_order_listObject[]NoThe sort order of the employee within the corresponding departments.
dept_idNumberNo2The department ID.
orderNumberNo1The sort order of the employee within the department.
dept_title_listObject[]NoThe Job Title of the employee within the corresponding departments.
dept_idNumberNo2The department ID.
titleStringNoSenior Product ManagerThe Job Title of the employee within the department.
extensionObjectNo{"Hobby":"Travel","Age":"24"}Extension attributes. Multiple attributes can be configured. Maximum 2000 characters. Note - Up to 10 extension attributes can be displayed on a mobile device. - Before using this parameter, add the attribute in the DingTalk Admin Console > Internal Contacts Settings > Member Field Management, and then call the API to set its value. For details, see About the extension parameter below. - The value of this field supports link types, and links support automatic replacement of variable wildcards. Currently supported wildcards include: userid and corpid. For example: {"Hobby":"[Hobby](http://www.dingtalk.io?userid=#userid#&corpid=#corpid#)"} - Important: Directly adding a new attribute will overwrite the existing attribute values. Retrieve the existing attributes first, append the new attribute to them, and then perform a full update.
senior_modeBooleanNofalseWhether to enable executive mode. Default: false. - true: Enable. Note - When enabled, the mobile number is hidden from all employees. - Regular employees cannot send DINGs or initiate DingTalk business calls to the user. - Executives can send DINGs and initiate DingTalk business calls to each other. - false: Do not enable.
hired_dateNumberNo1597573616828The hire date, as a Unix timestamp in milliseconds.
manager_useridStringNo001The userId of the direct manager.
login_emailStringNotest@xxx.comThe sign-in mail address. Note This field applies only to mail accounts. Setting this field for non-mail accounts has no effect.
dept_position_listDeptPosition[]NoThe position information within the department.
extension_i18nJsonNo{"Hobby": {"zh_CN": "Travel", "en_US": "Travel", "aJP": "Trip"}}The internationalized values of extension attributes.

Request example

curl -X POST "https://oapi.dingtalk.io/topapi/v2/user/create" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=1c016742-9383-4276-beb1-ebb375acc454' \
-d 'name=John' \
-d 'mobile=13800138000' \
-d 'dept_id_list=%5C%222%2C3%2C4%5C%22'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/v2/user/create");
OapiV2UserCreateRequest req = new OapiV2UserCreateRequest();
req.setUserid("002");
req.setName("Test");
req.setSeniorMode(false);
req.setMobile("184806*****");
req.setTitle("Faculty");
req.setEmail("test@xx.com");
req.setOrgEmail("test@xxx.com");
req.setOrgEmailType("profession");
req.setDeptIdList("1");
ArrayList<OapiV2UserCreateRequest.DeptTitle> deptTitles = new ArrayList<>();
OapiV2UserCreateRequest.DeptTitle deptTitle = new OapiV2UserCreateRequest.DeptTitle();
deptTitle.setDeptId(1L);
deptTitle.setTitle("Test");
OapiV2UserCreateRequest.DeptTitle deptTitle1 = new OapiV2UserCreateRequest.DeptTitle();
deptTitle1.setDeptId(1L);
deptTitle1.setTitle("Specialist");
deptTitles.add(deptTitle);
deptTitles.add(deptTitle1);
req.setDeptTitleList(deptTitles);
req.setHideMobile(false);
req.setTelephone("010-8xxxxx6-2345");
req.setJobNumber("100828");
req.setHiredDate(1615219200000L);
req.setWorkPlace("Future Park");
req.setRemark("Remarks");
List<OapiV2UserCreateRequest.DeptOrder> deptOrderList = new ArrayList<OapiV2UserCreateRequest.DeptOrder>();
OapiV2UserCreateRequest.DeptOrder deptOrder = new OapiV2UserCreateRequest.DeptOrder();
deptOrder.setDeptId(1L);
deptOrder.setOrder(1L);
OapiV2UserCreateRequest.DeptOrder deptOrder1 = new OapiV2UserCreateRequest.DeptOrder();
deptOrder1.setDeptId(1L);
deptOrder1.setOrder(1L);
deptOrderList.add(deptOrder);
deptOrderList.add(deptOrder1);
req.setDeptOrderList(deptOrderList);
req.setExtension("{\"Hobby\":\"[Hobby](http://test.com?userid=#userid#&corpid=#corpid#)\"}");
req.setManagerUserid("001");
req.setLoginEmail("test@xxx.com");
OapiV2UserCreateResponse rsp = client.execute(req, "");
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiV2UserCreateRequest("https://oapi.dingtalk.io/topapi/v2/user/create")

req.userid="zhangsan"
req.name="John"
req.mobile="13800138000"
req.job_number="4"
req.title="Technical Director"
req.email="test@xxx.com"
req.org_email="test@xxx.com"
req.work_place="Future Park"
req.remark="Remarks"
req.dept_id_list="2,3,4"
req.check_user_protect=true
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 OapiV2UserCreateRequest;
$req->setUserid("zhangsan");
$req->setName("John");
$req->setMobile("13800138000");
$req->setTelephone("010-86123456-2345");
$req->setTitle("Technical Director");
$req->setEmail("test@xxx.com");
$req->setWorkPlace("Future Park");
$req->setRemark("Remarks");
$req->setDeptIdList("\"2,3,4\"");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/topapi/v2/user/create");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/v2/user/create");
OapiV2UserCreateRequest req = new OapiV2UserCreateRequest();
req.Userid = "zhangsan";
req.Name = "John";
req.Mobile = "13800138000";
req.Title = "Technical Director";
req.Email = "test@xxx.com";
req.OrgEmail = "test@xxx.com";
req.WorkPlace = "Future Park";
req.Remark = "Remarks";
req.DeptIdList = "\"2,3,4\"";
OapiV2UserCreateResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
errcodeNumber0The error code. 0 indicates success.
errmsgStringokThe error message.
resultObjectThe returned result.
useridStringzhangsanThe employee ID.
unionIdStringxxxxThe unique ID of the employee.

Response body example

{
  "errcode":"0",
  "result":{
    "unionId":"xxxx",
    "userid":"zhangsan"
  },
  "errmsg":"ok"
}

Error codes

If an error occurs when calling this API, refer to the Global error codes document for solutions based on the error message.

About the extension parameter

To display the user attributes configured in the extension field, complete the following steps.
  1. Sign in to the DingTalk Admin Console.
  2. Click Internal Contacts Settings, then click Member Field Management > Add Custom Field.