Skip to main content

Create an SSO Enterprise Account

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 management permission

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYesBE3xxxxThe app credential used to call this API. Obtain it through the Get the access_token of an internal app API.

Request body

NameTypeRequiredExampleDescription
useridStringNozhangsanThe unique identifier of the employee (cannot be modified). 1 to 64 characters in length. Note - Must be unique within your organization. - If not specified, a userid is generated automatically.
exclusive_accountBooleanYestrueMust be set to true, which indicates that an Enterprise Account will be created. Note Only applies to Enterprise Account.
exclusive_account_typeStringNossoMust be set to sso, which indicates an SSO Enterprise Account. Note Only applies to SSO Enterprise Account.
nameStringYesZhang SanThe employee name. Up to 80 characters.
dept_id_listStringYes”2,3,4”The list of department IDs to which the employee belongs. Separate multiple department IDs with a comma (,). Up to 100 department IDs per call.
telephoneStringNo010-86123456-2345The extension number. Up to 50 characters. Note The extension number must be unique within your organization.
job_numberStringNo4The employee ID. Up to 50 characters.
titleStringNoTechnical DirectorThe job title. Up to 200 characters.
emailStringNotest@xxx.comThe personal email address of the employee. Up to 50 characters. Note The email address must be unique within your organization.
org_emailStringNotest@xxx.comThe Enterprise Mail of the employee. Up to 100 characters. Note This field takes effect only when the employee has Enterprise Mail enabled.
org_email_typeStringNoprofessionThe Enterprise Mail type of the employee: - profession: Standard edition. - base: Basic edition.
work_placeStringNoFuture ParkThe Work Location. Up to 100 characters.
remarkStringNoAlias informationThe Alias. Up to 2,000 characters.
dept_order_listObject[]NoThe order of the employee within the corresponding departments.
dept_idNumberNo2The department ID.
orderNumberNo1The order of the employee within the department. The larger the value, the higher the position.
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.
extensionStringNo{"Hobby":"Travel","Age":"24"}The extended attributes. Multiple attributes can be set. Up to 2,000 characters.Note - Up to 10 extended attributes can be displayed on mobile devices. - Before using this parameter, add the attribute in the DingTalk admin console, and then call the API to assign a value. For example, on the Contacts > Internal Contacts Settings > Contacts Information page, click the Add Custom Field button. - The value of this field supports link type. Links support automatic replacement of variable wildcards. Currently supported wildcards are userid and corpid. For example, {"Hobby":"[Hobby](http://www.dingtalk.io?userid=#userid#&corpid=#corpid#)"}.
senior_modeBooleanNofalseWhether to enable executive mode. Default: false. - true: Enabled. Note - When enabled, the mobile phone number is hidden from all employees. - Regular employees cannot send DINGs or initiate DingTalk Business Calls to the executive. - Executives can send DINGs and initiate DingTalk Business Calls to each other. - false: Disabled.
hired_dateNumberNo1597573616828The hire date. Unix timestamp in milliseconds.
manager_useridStringNo001The userId of the direct supervisor.
exclusive_mobileStringNo+86-13412341234The mobile phone number of the Enterprise Account. Note Only applies to Enterprise Account.
avatarMediaIdStringNo@lALPDfmVUw19YdrNA-jNA-gThe Profile Photo MediaId can be specified when creating an Enterprise Account for your organization. Only jpg and png formats are supported. Obtain it by calling the Upload media files API. Note Only applies to Enterprise Account.
nicknameStringNoNicknameThe Name can be specified when creating an Enterprise Account for your organization. Note Only applies to Enterprise Account.

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=871c1df6-bcd5-4acb-b2e9-815b7246d85c' \
-d 'userid=zhangsan'
-d 'exclusive_account=true' \
-d 'name=John' \
-d 'dept_id_list=2,3,4'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/topapi/v2/user/create");
OapiV2UserCreateRequest req = new OapiV2UserCreateRequest();
req.setUserid("12345678");
req.setName("SSO Enterprise Account");
req.setHideMobile(true);
req.setTelephone("123");
req.setJobNumber("123");
req.setTitle("Technical Director");
req.setEmail("test@xxx.com");
req.setOrgEmail("ceshi1");
req.setWorkPlace("Beijing");
req.setRemark("Alias information");
req.setDeptIdList("486882146,609916162");
OapiV2UserCreateRequest.DeptOrder deptOrder1 = new OapiV2UserCreateRequest.DeptOrder();
deptOrder1.setDeptId(486882146L);
deptOrder1.setOrder(2L);
OapiV2UserCreateRequest.DeptOrder deptOrder2 = new OapiV2UserCreateRequest.DeptOrder();
deptOrder2.setDeptId(609916162L);
deptOrder2.setOrder(1L);
ArrayList<OapiV2UserCreateRequest.DeptOrder> deptOrderList = new ArrayList<>();
deptOrderList.add(deptOrder1);
deptOrderList.add(deptOrder2);
req.setDeptOrderList(deptOrderList);
OapiV2UserCreateRequest.DeptTitle deptTitle1 = new OapiV2UserCreateRequest.DeptTitle();
deptTitle1.setTitle("Test position");
deptTitle1.setDeptId(486882146L);
OapiV2UserCreateRequest.DeptTitle deptTitle2 = new OapiV2UserCreateRequest.DeptTitle();
deptTitle2.setTitle("Test owner");
deptTitle2.setDeptId(609916162L);
ArrayList<OapiV2UserCreateRequest.DeptTitle> deptTitleList = new ArrayList<>();
deptTitleList.add(deptTitle1);
deptTitleList.add(deptTitle2);
req.setDeptTitleList(deptTitleList);
req.setExtension("{\"Hobby\":\"Travel\",\"Age\":\"24\"}");
req.setSeniorMode(false);
req.setHiredDate(1650351000000L);
req.setManagerUserid("001");
req.setOrgEmailType("base");
req.setExclusiveAccount(true);
req.setExclusiveAccountType("sso");
req.setExclusiveMobile("150xxxx");
req.setAvatarMediaId("@lADPDfYH3A-xxx");
req.setNickname("Nickname1");
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.dept_id_list="2,3,4"
req.exclusive_account=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->setDeptIdList("\"2,3,4\"");
$req->setExclusiveAccount("true");
$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.ExclusiveAccount = true;
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, find the solution based on the error message in the Global error codes documentation.