> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an SSO Enterprise Account

> Call this API to create a new SSO Enterprise Account user for organizations that have purchased and enabled this feature, with full request parameters and response field references.

# Create an SSO Enterprise Account

## Request

| **Basic information** |                                                                                                |
| --------------------- | ---------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://api.dingtalk.io/topapi/v2/user/create](https://api.dingtalk.io/topapi/v2/user/create) |
| HTTP Method           | POST                                                                                           |
| Supported app types   | appType-Internal app                                                                           |
| Required permissions  | permission-qyapi\_manage\_addresslist-Contacts management permission                           |

### Query parameters

| Name          | Type   | Required | Example | Description                                                                                                                                            |
| ------------- | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| access\_token | String | Yes      | BE3xxxx | The app credential used to call this API. Obtain it through the Get the [access\_token of an internal app](/open/development/obtain-orgapp-token) API. |

### Request body

| Name                     | Type      | Required | Example                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------ | --------- | -------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| userid                   | String    | No       | zhangsan                            | The 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\_account       | Boolean   | Yes      | true                                | Must be set to true, which indicates that an Enterprise Account will be created.  **Note**  Only applies to Enterprise Account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| exclusive\_account\_type | String    | No       | sso                                 | Must be set to sso, which indicates an SSO Enterprise Account.  **Note**  Only applies to SSO Enterprise Account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| name                     | String    | Yes      | Zhang San                           | The employee name. Up to 80 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| dept\_id\_list           | String    | Yes      | "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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| telephone                | String    | No       | 010-86123456-2345                   | The extension number. Up to 50 characters.  **Note**  The extension number must be unique within your organization.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| job\_number              | String    | No       | 4                                   | The employee ID. Up to 50 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| title                    | String    | No       | Technical Director                  | The job title. Up to 200 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| email                    | String    | No       | [test@xxx.com](mailto:test@xxx.com) | The personal email address of the employee. Up to 50 characters.  **Note**  The email address must be unique within your organization.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| org\_email               | String    | No       | [test@xxx.com](mailto:test@xxx.com) | The Enterprise Mail of the employee. Up to 100 characters.  **Note**  This field takes effect only when the employee has Enterprise Mail enabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| org\_email\_type         | String    | No       | profession                          | The Enterprise Mail type of the employee:   - **profession:** Standard edition. - **base:** Basic edition.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| work\_place              | String    | No       | Future Park                         | The Work Location. Up to 100 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| remark                   | String    | No       | Alias information                   | The Alias. Up to 2,000 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| dept\_order\_list        | Object\[] | No       |                                     | The order of the employee within the corresponding departments.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| dept\_id                 | Number    | No       | 2                                   | The department ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| order                    | Number    | No       | 1                                   | The order of the employee within the department. The larger the value, the higher the position.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| dept\_title\_list        | Object\[] | No       |                                     | The job title of the employee within the corresponding departments.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| dept\_id                 | Number    | No       | 2                                   | The department ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| title                    | String    | No       | Senior Product Manager              | The job title of the employee within the department.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| extension                | Object    | No       | `{"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](https://oa.dingtalk.io/index_new.htm#/setting/contactInfo), 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\_mode             | Boolean   | No       | false                               | Whether 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\_date              | Number    | No       | 1597573616828                       | The hire date. Unix timestamp in milliseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| manager\_userid          | String    | No       | 001                                 | The userId of the direct supervisor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| exclusive\_mobile        | String    | No       | +86-13412341234                     | The mobile phone number of the Enterprise Account.  **Note**  Only applies to Enterprise Account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| avatarMediaId            | String    | No       | @lALPDfmVUw19YdrNA-jNA-g            | The 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](/open/development/upload-media-files) API.  **Note**  Only applies to Enterprise Account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| nickname                 | String    | No       | Nickname                            | The Name can be specified when creating an Enterprise Account for your organization.  **Note**  Only applies to Enterprise Account.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.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

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.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

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiV2UserCreateRequest("https://api.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

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
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://api.dingtalk.io/topapi/v2/user/create");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.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

| Name    | Type   | Example  | Description                          |
| ------- | ------ | -------- | ------------------------------------ |
| errcode | Number | 0        | The error code. 0 indicates success. |
| errmsg  | String | ok       | The error message.                   |
| result  | Object |          | The returned result.                 |
| userid  | String | zhangsan | The employee ID.                     |
| unionId | String | xxxx     | The unique ID of the employee.       |

### Response body example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "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](/open/development/server-api-error-codes-1) documentation.
