# 新增联系人

>批量创建联系人，若开启"允许不同联系人的号码重复"，则重复号码的联系人能创建成功，否则，联系人不能创建成功，并抛出异常code码（详细code码对应关系参照文档末页）

- 存在于回收站的联系人数据，不会参与手机号码判重;
- 如有大量数据需要导入尘锋，请规范调用，串行请求，单次请求最多传递500条联系人数据;
- 如生产出现并发调用&单次请求只传递1条联系人数据，则会被检测封禁！

```
POST https://qw-openapi-tx.dustess.com/customer/v1/batchAddCustomer?accessToken=

Content-Type: application/json
```

**接口限制**：每分钟调用600次；单次请求最多传递500条数据；

**注**：自定义字段多级联选数据类型，采用字段"array_value"，可见请求参数示例，多级联选规则：数组中为单个字符串;传参方式："组01=1148942280694972416"或"组01/组001/组001001=1148942280694972416/1148942280694972417/1148942280694972418"，规则为选项值和选项ID之间以“=”分割，选项值与选项ID自身之间以“/”分割，可选父级支持两种方式，仅选最后一级仅支持第二种方式，错误格式传参可能导致数据不可用等情况，请严格按照规则传参；

**请求参数**

| 请求参数名                                        | 类型       | 说明                                                                                                                               | 是否必须 |
| ------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------- |
| customer_list                                     | `Object[]` | 联系人信息                                                                                                                         | false    |
| customer_list.remark                              | `String`   | 联系人名称（必填）                                                                                                                 | true     |
| customer_list.corp_full_name                      | `String`   | 企业名称                                                                                                                           | false    |
| customer_list.corp_id                             | `String`   | 企业id  [查询企业列表](https://open.dustess.com/doc-5158676.md)                                                                                                                           | false    |
| customer_list.mobiles                             | `Object[]` | 联系方式（联系人去重核心字段）                                                                                                     | false    |
| customer_list.mobiles.tel                         | `String`   | 联系方式具体内容，如：type=mobile，则值为手机号码，支持传递国际手机号码，支持前缀传"+"                                             | false    |
| customer_list.mobiles.type                        | `String`   | mobile（手机号），landline（座机），other（其他）,11b90rp60zya（自定义联系方式，如：微信号，id为示例，非真实自定义联系方式id）[联系人联系方式](https://open.dustess.com/doc-5147969.md)     | false    |
| customer_list.mobiles.display                     | `String`   | 联系方式名称                                                                                                                       | false    |
| customer_list.position                            | `String`   | 职务                                                                                                                               | false    |
| customer_list.source                              | `String`   | 来源id，可传任意层级的来源id，该联系人会挂在来源id的所属层级 [来源列表查询（企业&联系人）](https://open.dustess.com/doc-5147962.md)                                                                      | false    |
| customer_list.prov_city                           | `String`   | 省市区（县）,传参格式示例："四川省-成都市-武侯区" 或 "四川省/成都市/武侯区"，同时支持只传省、省市                                  | false    |
| customer_list.address                             | `String`   | 地址                                                                                                                               | false    |
| customer_list.birthday                            | `String`   | 生日                                                                                                                               | false    |
| customer_list.email                               | `String`   | email信息                                                                                                                          | false    |
| customer_list.gender                              | `Int`      | 外部联系人性别 0-未知 1-男性 2-女性                                                                                                | false    |
| customer_list.description                         | `String`   | 描述                                                                                                                               | false    |
| customer_list.custom_fields                       | `Object[]` | 自定义字段[查询字段模版](https://open.dustess.com/doc-5147965.md)                                                                                                                         | false    |
| customer_list.custom_fields.id                    | `String`   | 字段id                                                                                                                             | false    |
| customer_list.custom_fields.array_value           | `Object[]` | 字段类型为：checkbox（多项选择）,cascader（多级联选单选），multiCascader（多级联选多选）时使用此字段                               | false    |
| customer_list.custom_fields.type                  | `String`   | 字段类型                                                                                                                           | false    |
| customer_list.custom_fields.float_value           | `Float64`  | 字段类型为：number（数字）时使用此字段                                                                                             | false    |
| customer_list.custom_fields.string_value          | `String`   | 字段类型为：radio（单选），date（日期），datetime（日期时间），text（单行文本），textarea（多行文本）时使用此字段,多行文本使用“\n” | false    |
| customer_list.custom_fields.files_value           | `Object[]` | 字段类型为：附件列表 时使用此字段, 最大文件个数5个                                                                                 | false    |
| customer_list.custom_fields.files_value.name      | `String`   | 文件名称, 使用附件类型必填                                                                                                         | false    |
| customer_list.custom_fields.files_value.url       | `String`   | 文件链接, 使用附件类型必填                                                                                                         | false    |
| customer_list.custom_fields.files_value.file_type | `String`   | 文件类型, 可填为: `word`、`image`、`text`、`pdf`、`audio`、<br />`spreadsheetml`(excel)、`presentationml`(ppt)、`video`、`other`   | false    |
| customer_list.tags                                | `String[]` | 好友标签id集合 [查询好友标签列表](https://open.dustess.com/doc-5147890.md)                                                                                                                    | false    |
| customer_list.age                                 | `Int`      | 年龄                                                                                                                               | false    |
| customer_list.national                            | `String`   | 民族id                                                                                                                             | false    |
| customer_list.nationality                         | `String`   | 国籍                                                                                                                               | false    |
| customer_list.education                           | `String`   | 学历id（小学 01，初中 02，高中 03，专科 04，本科 05，硕士 06，博士 07）                                                            | false    |
| customer_list.major                               | `String`   | 专业                                                                                                                               | false    |
| customer_list.id_card                             | `String`   | 身份证                                                                                                                             | false    |
| customer_list.wx                                  | `String`   | 微信                                                                                                                               | false    |
| customer_list.qq                                  | `String`   | QQ                                                                                                                                 | false    |
| customer_list.category_id                         | `String`   | 联系人类型id，[联系人类型](https://open.dustess.com/doc-5147967.md)                                                                                                                       | false    |
| customer_list.owner                               | `String`   | 联系人主跟进人id（和公海id二选一必填）[查询员工信息](https://open.dustess.com/doc-5158538.md)                                                                                             | false    |
| customer_list.pool                                | `String`   | 公海id（和联系人主跟进人id二选一必填）,公海参数请确保系统中已经存在该公海，否则可能添加成功但查询不到联系人的情况[查询联系人公海列表](https://open.dustess.com/doc-5147968.md)                  | false    |
| customer_list.reason                              | `String`   | 无效原因id[无效&放弃&删除原因查询](https://open.dustess.com/doc-5147963.md)                                                                                                                         | false    |
| customer_list.status                              | `String`   | 联系人状态id[查询跟进状态列表](https://open.dustess.com/doc-5147964.md)                                                                                                                       | false    |
| customer_list.share_uids                          | `String[]` | 共享人员工id集合                                                                                                                   | false    |
| customer_list.external_id                         | `String`   | 需要关联的外部系统ID（全局唯一）                                                                                                   | false    |


**请求参数示例**
`json` - Request-Example:

```json
 {
    "customer_list":[
        {
            "custom_fields":[
                {
                    "id":"field01",
                    "string_value":"",
                    "type":"text"
                },
                {
                    "id":"field71",
                    "array_value":[
                        "撒旦法",
                        "地方"
                    ],
                    "type":"checkbox"
                },
                {
                    "id":"field91",
                    "array_value":[
                        "嗯嗯"
                    ],
                    "type":"checkbox"
                },{
                     "id": "field15",
                     "array_value": [
                         "组01=testttest"
                     ],
                     "type":"multi-cascader"
                },{
                     "id": "field16",
                     "array_value": [
                          "组01/组001/组001001=path/to/value"
                     ],
                     "type":"multi-cascader"
                }
            ],
            "mobiles": [
                {
                    "tel":"12500010002",
                    "type":"mobile",
                    "display":"手机号"
                },
                {
                    "tel": "ead12312acxzcasd",
                    "type": "11b90rp60zya",
                    "display": "微信号"
                }
            ],
            "category_id":"00000000-0000-0000-0000-000000000000",
            "age":26,
            "remark":"张三",
            "tags":[
                "etDolHEAAAF2A3f71_1111111111",
                "etDolHEAAAG0BIKWd7UHHP111111111"
            ],
            "source":"searchEngines",
            "prov_city":"天津市-天津市-河东区",
            "address":"和平村",
            "birthday":"2020-09-16",
            "gender":1,
            "corp_full_name":"北京尘锋信息技术有限公司",
            "corp_id":"cda55210-9fe5-11ea-bce3-111111111",
            "email":"0000000@qq.com",
            "national":"02",
            "position":"高级工程师",
            "qq":"0000000",
            "education":"05",
            "description":"我是描述",
            "nationality":"中国",
            "id_card":"100101010",
            "wx":"dsaf325",
            "major":"工程造价"
        },{
            "pool":"19c52ad4-af85-11ea-a74d-11111111111",
            "custom_fields":[
                {
                    "id":"field01",
                    "string_value":"",
                     "type":"text"
                },
                {
                    "id":"field21",
                    "string_value":"",
                     "type":"text"
                },
                {
                    "id":"field91",
                    "array_value":[
                        "嗯嗯"
                    ],
                     "type":"checkbox"
                }
            ],
            "mobiles":[
                {
                    "display":"手机",
                    "type":"mobile",
                    "tel":"18108067541"
                }
            ],
            "categoryId":"00000000-0000-0000-0000-000000000000",
            "age":26,
            "remark":"张三",
            "tags":[
                "etDolHEAAAF2A3f71_Y111111",
                "etDolHEAAAG0BIKWd7UHHP1111111"
            ],
            "source":"searchEngines",
            "prov_city":"天津市-天津市-河东区",
            "address":"和平村",
            "birthday":"2020-09-16",
            "gender":1,
            "corp_full_name":"北京尘锋信息技术有限公司",
            "corp_id":"cda55210-9fe5-11ea-bce3-111111111",
            "email":"test@qq.com",
            "national":"02",
            "position":"高级工程师",
            "qq":"test",
            "education":"05",
            "description":"我是描述",
            "nationality":"中国",
            "id_card":"test",
            "wx":"test",
            "major":"工程造价"
        }
    ]
}
```

**成功响应**
> 受历史原因， 新增联系人成功/失败 的 “index” 字段 （非数组index） **从1 开始， "index"字段 = 1 对应的是 传入params 中 index（下标） 为 0 的创建结果** （第一个param 的创建结果）

| 响应参数名         | 类型       | 说明                                                                      |
| ------------------ | ---------- | ------------------------------------------------------------------------- |
| code               | `Int`      | 响应码                                                                    |
| msg                | `String`   | 消息提示                                                                  |
| data               | `Object`   | 数据信息                                                                  |
| data.success       | `Object[]` | 新增联系人成功的数据                                                      |
| data.success.index | `Int`      | 新增联系人成功的索引                                                      |
| data.success.id    | `String`   | 新增联系人成功的id                                                        |
| data.fail          | `Object[]` | 新增联系人失败的数据                                                      |
| data.fail.code     | `String`   | 新增联系人失败的code码                                                    |
| data.fail.index    | `Int`      | 新增联系人成功的索引                                                      |
| data.fail.id       | `String`   | 添加联系人电话号码重复，code：13001，返回系统中已存在最早创建的联系人的id |

**成功响应示例**

```json
 {
    "success": true,
    "msg": "",
    "data": {
        "fail": null,
        "success": [
            {
                "code": 0,
                "index": 1,
                "id": "ad14ce98-ee88-11ea-9926-acde4811111",
                "msg":""
            },
            {
                "code": 0,
                "index": 2,
                "id": "ad334abc-ee88-11ea-9926-acde480000000",
                "msg":""
            }
        ]
    }
}
```

**错误响应示例**

```json
 {
    "success": false,
    "code": 4126,
    "msg": "",
    "data": {
        "fail": [{
            "code": 13001,
            "index": 3,
            "id": "",
            "msg":""
        }],
        "success": [{
            "code": 0,
            "index": 1,
            "id": "ad14ce98-ee88-11ea-9926-acde4811111",
            "msg":""
        },{
            "code": 0,
            "index": 2,
            "id": "ad334abc-ee88-11ea-9926-acde480000000",
            "msg":""
        }
      ]
    }
}
```

```json
 {
    "success": false,
    "code": 4126,
    "msg": "",
    "data": {
        "fail": [{
            "code": 13001,
            "index": 1,
            "id": "0",
            "msg":""
        },{
            "code": 4126,
            "index": 2,
            "id": "0",
            "msg":"地址字段必填"
        }
      ],
         "success":null
    }
}
```
