# 搜索知识库

该接口用于搜索服务台知识库。

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/helpdesk/v1/faqs/search
HTTP Method | GET
接口频率限制 | [特殊频控](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用** | 获取服务台资源详情(helpdesk:all:readonly)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)

**注意事项**：服务台请求Header中还需添加“服务台token”参数：

Key: X-Lark-Helpdesk-Authorization

Value: base64(helpdesk_id:helpdesk_token)，通过base64加密将helpdesk_id和helpdesk_token用':'连接而成的字符串。

[了解更多：获取与使用服务台token](https://open.feishu.cn/document/ukTMukTMukTM/ugDOyYjL4gjM24CO4IjN)

### 查询参数

名称 | 类型 | 必填 | 描述
---|---|---|---
query | string | 是 | 搜索query<br>，query内容如果不是英文，包含中文空格等有两种编码策略：1. url编码 2. base64编码，同时加上base64=true参数<br>**示例值**：wifi
base64 | string | 否 | 是否转换为base64,输入true表示是，不填写表示否<br>**示例值**：true
page_token | string | 否 | 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果<br>**示例值**：6936004780707807251
page_size | int | 否 | **示例值**：10<br>**默认值**：`20`<br>**数据校验规则**：<br>- 最大值：`100`

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-
has_more | boolean | 是否还有更多项
page_token | string | 分页标记，当 has_more 为 true 时，会同时返回新的 page_token，否则不返回 page_token
items | faq\[\] | 知识库列表
faq_id | string | 知识库ID
id | string | 知识库旧版ID，请使用faq_id
helpdesk_id | string | 服务台ID
question | string | 问题
answer | string | 答案
answer_richtext | richtext\[\] | 富文本答案
content | string | 内容
type | string | 类型
create_time | int | 创建时间
update_time | int | 修改时间
categories | category\[\] | 分类
category_id | string | 知识库分类ID
id | string | 知识库分类ID，（旧版，请使用category_id）
name | string | 名称
parent_id | string | 父知识库分类ID
helpdesk_id | string | 服务台ID
language | string | 语言
tags | string\[\] | 相似问题列表
expire_time | int | 失效时间
update_user | ticket_user | 更新用户
id | string | 用户ID
avatar_url | string | 用户头像url
name | string | 用户名
department | string | 所在部门名称
city | string | 城市
country | string | 国家代号(CountryCode)，参考：http://www.mamicode.com/info-detail-2186501.html
create_user | ticket_user | 创建用户
id | string | 用户ID
avatar_url | string | 用户头像url
name | string | 用户名
department | string | 所在部门名称
city | string | 城市
country | string | 国家代号(CountryCode)，参考：http://www.mamicode.com/info-detail-2186501.html

### 响应体示例
```json
{
  "code": 0,
  "data": {
    "has_more": false,
    "items": [
      {
        "answer": "建议根据公司实际情况编写，以文档形式答疑",
        "answer_richtext": [
          {
            "content": "建议根据公司实际情况编写，以文档形式答疑",
            "type": "text"
          }
        ],
        "categories": [
          {
            "category_id": "6975057629039083524",
            "id": "6975057629039083524",
            "name": "行政"
          },
          {
            "category_id": "6986214055581122561",
            "id": "6986214055581122561",
            "name": "名片申请"
          }
        ],
        "create_time": 1626604715,
        "create_user": {
          "avatar_url": "https://xxxxx",
          "id": "ou_f7dab73dda407c7cbc947bbf4fd49c45",
          "name": "陈xxx"
        },
        "faq_id": "6986214054851346434",
        "helpdesk_id": "6946124090457505820",
        "id": "6986214054851346434",
        "question": "盒餐发放位置查询",
        "tags": [
          "盒饭",
          "盒餐"
        ],
        "update_time": 1631242057,
        "update_user": {
          "avatar_url": "xxxxxxxxxx",
          "id": "ou_43771a6f8dfa0815600a949779xxx",
          "name": "戴xx"
        }
      },
      {
        "answer": "建议根据公司实际情况编写，以文档形式答疑",
        "answer_richtext": [
          {
            "content": "我的答案",
            "type": "text"
          }
        ],
        "categories": [
          {
            "category_id": "6975057629039083524",
            "id": "6975057629039083524",
            "name": "行政"
          },
          {
            "category_id": "6986214054805159937",
            "id": "6986214054805159937",
            "name": "餐饮服务"
          }
        ],
        "create_time": 1626604715,
        "create_user": {
          "avatar_url": "xxxxxxxxxx",
          "id": "xxxx",
          "name": "陈xx"
        },
        "faq_id": "6986214054826147841",
        "helpdesk_id": "6946124090457505820",
        "id": "6986214054826147841",
        "question": "下午茶推送和选品推荐",
        "tags": [
          "供餐",
          "下午茶"
        ],
        "update_time": 1630063323,
        "update_user": {
          "avatar_url": "xxxxxxxxxx",
          "id": "ou_eb208c4799a1f3a86c12e0b03e5a54b1",
          "name": "蔡xx"
        }
      }
    ],
    "page_size": 2,
    "page_token": "6986214054876479490",
    "total": 2
  },
  "msg": "ok"
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 154000 | Bad request, please check your request body | 请求不合法，请检查参数
401 | 154001 | Unauthorized, please check you have the correct access | 检查Authorization 和 X-Lark-Helpdesk-Authorization 是否正确，应用和服务台属于同一租户
500 | 155000 | Internal error | 内部错误，请联系我们

