# 查询联系人

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /wxworkapi/message/exchange:
    post:
      summary: 查询联系人
      deprecated: false
      description: >
        > 回调通知接口  /XXXX/service/result


        :::highlight blue

        命令字type:robot.contacts.inquiry

        ::: 

        同步任务命令采用异步处理，收到指令后响应指令接收成功，数据通过回调通知接口上报。


        ### 请求示例：

        ```json

        {
            "messageId":"20201029140953087689504360",
            "robotKey":"e46ff1f6a2ea4ceca04a82ad209b9dbc",
            "type":"robot.contacts.inquiry",
            "contacts":[
                "R:1231237898658"
            ]
        }

        ```

        ### 请求参数说明：

        | 名称       | 类型     | 必须 | 描述                                      |

        |------------|----------|------|-------------------------------------------|

        | type       | String   | 是   | 
        robot.contacts.inquiry                             |

        | messageld  | String   | 是   | 请求消息id，32个字符的唯一，应答时原样回传 |

        | robotKey   | String   | 是   | 机器人robotKey                            |

        | contacts   | Array  | 是   | string 数组，要查询的联系人externalUsers.userId 或
        群conversationId   |


        ### 回调通知：

        #### 联系人数据：

        ```json

        {
          "messageId":"20201029140953087689504360",
          "robotKey":"e46ff1f6a2ea4ceca04a82ad209b9dbc",
          "code":"0",
          "contacts":[
            {
              "userId":7881303487898658,
              "isExternalHideMobile":0,
              "realName":"",
              "realRemarks":"请人墨晔20230215 ",
              "markAsCustomerTime":"2023-02-15 16:46:12",
              "remarkCorpName":"微信",
              "corpanyId":1970325134026788,
              "isCustomer":1,
              "wechatImgUrl":"http:\/\/wx.qlogo.cn\/mmhead\/PiajxSqBRaEJrlO6oLkqjhukh4UaSJh4v7nHcFtuUia8mOXOicSVh3O3Q\/0",
              "name":"墨晔",
              "crmTagList":[
                {
                  "name":"小小新",
                  "labelId":"14073750083708116",
                  "isCorpLabel":1,
                  "isGroupLabel":0,
                  "fullName":"小新标签组: 小小新",
                  "groupName":"",
                  "isCustomLabelGroup":0,
                  "labelGroupId":"14073753104714198",
                  "createTime":"2022-03-25 15:46:20"
                },
                {
                  "name":"企业021416",
                  "labelId":"14073753090772073",
                  "isCorpLabel":1,
                  "isGroupLabel":0,
                  "fullName":"群聊拓客: 企业021416",
                  "groupName":"",
                  "isCustomLabelGroup":0,
                  "labelGroupId":"14073753090772072",
                  "createTime":"2023-02-14 16:36:15"
                }
              ],
              "avatorUrl":"http:\/\/wx.qlogo.cn\/mmhead\/PiajxSqBRaEJrlO6oLkqjhukh4UaSJh4v7nHcFtuUia8mOXOicSVh3O3Q\/0",
              "mobile":"",
              "remarks":"",
              "flag":2057,
              "nickName":"",
              "gender":1,
              "isExternalUser":1,
              "createTime":"2022-10-19 15:58:09",
              "unionId":"ozynqsmq6KezR7L0a4-hbrjrp5PQ",
              "isMarkedAsCustomer":1,
            }
          ],
          "robotType":2,
          "type":"contacts.inquiry",
          "dts":1677226443302,
          "reqContacts":[
            "7881303487898658"
          ]
        }

        ```


        ### 参数说明：

        | 名称                | 类型     | 必须 | 描述                          |

        |---------------------|----------|------|-------------------------------|

        | externalUsersCount  | Integer  | 是   | 当前成员客户总数              |

        | currentCount        | Integer  | 是   | 本次客户数量                  |

        | type                | String   | 是   | robot.chat.get 表示客户数据通知 |

        | externalUsers       | Array    | 是   | 客户数据列表                  |


        ###  客户数据 externalUsers ：

        | 名称                   | 类型     | 必须 |
        描述                                                                 |

        |------------------------|----------|------|----------------------------------------------------------------------|

        | userId                | Long     | 是   | 用户
        VID                                                             |

        | realRemarks           | String   | 是   |
        备注                                                                |

        | markAsCustomerTime    | String   | 是   | 成为客户的时间 "yyyy–MM–dd HH:mm:ss"
        格式的北京时间                  |

        | isMarkedAsCustomer    | Integer  | 是   |
        是否客户                                                            |

        | corpanyld             | Long     | 是   | 客户的公司
        vid                                                      |

        | remarkCorpName        | String   | 否   |
        备注公司名                                                          |

        | avatorUrl             | String   | 否   |
        头像                                                                |

        | name                  | String   | 是   |
        客户昵称或姓名                                                      |

        | gender                | Integer  | 是   | `0` 未知 `1` 男性 `2`
        女性                                                |

        | isExternalUser        | Integer  | 是   | 是否外部用户 `1` 是，`0`
        否                                             |

        | createTime            | String   | 是   | 加客户的时间 "yyyy–MM–dd HH:mm:ss"
        格式的北京时间                   |

        | remarks               | String   | 否   |
        描述信息                                                            |

        | remarkPhoneList       | Array    | 否   |
        备注手机号数组                                                      |


        :::highlight blue

        联系人和群数据，以及群成员数据字段参考 【同步联系人接口】

        :::
      tags:
        - 企微机器人/bot-联系人
      parameters:
        - name: acttype
          in: query
          description: ''
          required: false
          example: contactsinquiry
          schema:
            type: string
        - name: token
          in: query
          description: ''
          required: false
          example: '{{token}}'
          schema:
            type: string
        - name: type
          in: header
          description: ''
          required: false
          example: contactsinquiry
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                type:
                  type: string
                  description: 命令关键字 robot.contacts.inquiry
                messageId:
                  type: string
                  description: 消息ID
                robotKey:
                  type: string
                  description: 机器人robotKey
                contacts:
                  type: array
                  items:
                    type: string
              required:
                - messageId
                - robotKey
                - type
                - contacts
              x-apifox-orders:
                - messageId
                - robotKey
                - type
                - contacts
            example:
              messageId: '20201029140953087689504360'
              robotKey: e46ff1f6a2ea4ceca04a82ad209b9dbc
              type: robot.contacts.inquiry
              contacts:
                - '7881303487898658'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  messageId:
                    type: string
                  code:
                    type: string
                  msg:
                    type: string
                  type:
                    type: string
                  robotKey:
                    type: string
                required:
                  - messageId
                  - code
                  - msg
                  - type
                  - robotKey
                x-apifox-orders:
                  - messageId
                  - code
                  - msg
                  - type
                  - robotKey
          headers: {}
          x-apifox-name: 成功
      security: []
      x-apifox-folder: 企微机器人/bot-联系人
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/6148098/apis/api-279498756-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://www.example.com
    description: 测试环境
security: []

```
