Request
| Basic information | Detail |
|---|---|
| HTTP URL | https://oapi.dingtalk.io/topapi/extcontact/create |
| HTTP Method | POST |
| Supported app type | appType-Internal app |
| Required permissions | permission-qyapi_ext_write-Write permission for external contacts |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | 6d1bxxxx | The app credential used to call this API. Obtain it through the API for getting the access_token of an internal app. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| contact | OpenExtContact | Yes | The external contact information. | |
| title | String | No | Development Engineer | The job title. |
| label_ids | Number[] | Yes | [1561077317,1561077310] | The tag list. Call the Get the list of external contact tags API to query tag information. Refer to How to customize tag groups for an organization to add custom tags. A maximum of 20 label IDs can be passed per call. |
| share_dept_ids | Number[] | No | [1,2,3] | The IDs of departments to share with. Call the Get the list of sub-department IDs API to obtain them. A maximum of 20 department IDs can be passed per call. |
| address | String | No | Beijing | The address. |
| remark | String | No | Manager Wang | The alias. |
| follower_user_id | String | Yes | manager4220 | The user ID of the owner. Use the Query users by phone number API to obtain the user ID. A maximum of 20 user IDs can be passed per call. |
| name | String | Yes | Zhang xx | The name of the external contact. |
| state_code | String | Yes | 86 | The country code of the phone number. |
| company_name | String | No | DingTalk | The company name of the external contact. |
| share_user_ids | String[] | No | [“023420013644”] | The list of user IDs of employees to share with. Use the Query users by phone number API to obtain user IDs. A maximum of 20 user IDs can be passed per call. |
| mobile | String | Yes | 130xxxx8888 | The phone number of the external contact. |
Request example
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| userid | String | 123420013632 | The user ID of the external contact. |
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request_id | String | 6idz5ss49kkj | The request ID. |
Response example
Error codes
If an error is returned when you call this API, see the Global error codes document for a solution based on the error message.| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 33009 | Invalid tokenGrantType | Check whether the access_token is valid. |
| 40036 | The parameter is empty. | Check whether all required parameters above are provided. |
| 60103 | Invalid phone number | Check whether the phone number is correct. |
| 60204 | An external contact tag is required. | Provide a value for label_ids. |
| 60205 | The external contact feature is not enabled. | Enable the external contact feature after obtaining the user’s authorization letter. |
| 43007 | Authorization required | Check whether the access_token has the required permissions. |
| 60112 | Invalid user name | Check whether the user name is correct. |
| 22005 | The external contact already exists. | Check whether the phone number of the external contact is correct. |
| -1 | The system is busy. | Try again later. |