# 知识节点接口

# 创建文件夹

请求URL

POST https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为文件夹创建者

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

请求参数

{
  "data": {
    "attributes": {
      "name": "一级目录",
      "entry_type": "folder"
    },
    "relationships": {
      "parent_entry": {
        "data": {
          "type": "entry",
          "id": "e8270053d38a41e3b80eb52fca8a30bb"
        }
      }
    }
  }
}

参数说明

参数 是否必须 说明
name 节点名称
entry_type 节点类型,创建文件夹时固定为 folder
relationships.parent_entry.data.id 父节点ID

响应 200 Ok 状态码

{
  "data": {
    "type": "kb_entry",
    "id": "e8270053d38a41e3b80eb52fca8a30bb",
    "attributes": {
      "name": "一级目录",
      "entry_type": "folder",
      "created_at": "2025-03-18 15:25:11",
      "updated_at": "2025-03-18 15:25:11"
    }
  }
}

# 上传文件

此接口只用于创建知识实体,不负责文件传输。开发者需先通过本地文件上传接口将文件上传于腾讯云,再把state通过此接口把文件和实体关联起来。

请求URL

POST https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries?state={STATE}

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为文件创建者

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

请求参数

{
  "data": {
    "attributes": {
      "name": "报销流程",
      "entry_type": "file"
    },
    "relationships": {
      "parent_entry": {
        "data": {
          "type": "entry",
          "id": "e8270053d38a41e3b80eb52fca8a30bb"
        }
      }
    }
  }
}

参数说明

参数 是否必须 说明
state 文件上传临时标识
name 节点标题,缺省时节点标题直接使用上传的文件名
entry_type 节点类型,决定文件预览方式。目前支持值:video、file
video: 支持视频类型文件预览,文件后缀包括WMV、RM、MOV、MPEG、MP4、3GP、FLV、AVI、RMVB、TS、ASF、MPG、WEBM、MKV、M3U8、WM、ASX、RAM、MPE、VOB、DAT、MP4V、M4V、F4V、MXF、QT

file: 支持图片类型文件预览,文件后缀包括jpg、jpeg、png、bmp、webp、tiff、gif;文档类型文件预览,文件后缀包括doc、dot、wps、wpt、docx、dotx、docm、dotm;表格类型文件预览,文件后缀包括xls、xlt、et、ett、xlsx、xltx、csv、xlsb、xlsm、xltm、ets;幻灯片文件预览,文件后缀包括pptx、ppt、pot、potx、pps、ppsx、dps、dpt、pptm、potm、ppsm;其他类型文件后缀支持pdf、txt
relationships.parent_entry.data.id 父节点ID

提醒:不同类型文件可在线预览大小以及是否支持AI解析与站内上传一致,若有疑问可到页面上传测试对比

响应

200 Ok 状态码

{
  "data": {
    "type": "kb_entry",
    "id": "e8270053d38a41e3b80eb52fca8a30bb",
    "attributes": {
      "name": "报销流程",
      "entry_type": "file",
      "created_at": "2025-03-18 15:25:11",
      "updated_at": "2025-03-18 15:25:11"
    }
  }
}

# 重新上传文件

开发者需先通过本地文件上传接口将文件上传于腾讯云,再把state通过此接口把文件和实体关联起来。

请求URL

PUT https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries/{entry_id}/upload?state={STATE}

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为修改者需具有操作权限

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
state 文件上传临时标识。新版本文件扩展名必须与原文件一致

响应

200 Ok 状态码

{
  "data": {
    "type": "kb_entry",
    "id": "e8270053d38a41e3b80eb52fca8a3xxx",
    "attributes": {
      "name": "报销流程",
      "entry_type": "file",
      "created_at": "2025-03-18 15:25:11",
      "updated_at": "2025-03-18 15:25:11"
    }
  }
}

# 获取知识列表

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
space_id 知识库ID
parent_id 节点ID,默认为查询知识库根目录
limit 拉取条数
page_token 分页游标,根据上一页返回的page_token传入

响应

200 Ok 状态码

{
    "data": [
        {
            "type": "kb_entry",
            "id": "0e75db22d07c4ad593982baf77xxxxxx",
            "attributes": {
                "name": "知识节点标题1",
                "entry_type": "video",
                "created_at": "2025-06-30 15:26:14",
                "updated_at": "2025-06-30 16:30:03"
            }
        },
        {
            "type": "kb_entry",
            "id": "be8eeddc2ed64845b616a98ef7xxxxxx",
            "attributes": {
                "name": "知识节点标题2",
                "entry_type": "page",
                "created_at": "2025-06-30 19:24:17",
                "updated_at": "2025-07-15 02:07:52"
            }
        },
        {
            "type": "kb_entry",
            "id": "ee32105ee9e545d681d94941b4xxxxxx",
            "attributes": {
                "name": "知识节点标题3",
                "entry_type": "video",
                "created_at": "2025-06-30 15:26:03",
                "updated_at": "2025-07-15 02:07:52"
            }
        }
    ],
    "meta": {
        "page_token": "WyIyMDI1LTA2LTMwVDE1OjI2OjAzKzA4OjAwIiwzNDgyMl0="
    }
}

参数说明

参数 说明
data.attributes.name 节点名称
data.attributes.entry_type 节点类型
folder: 文件夹
file: 文件
video: 视频
audio: 音频
link: 链接
page: 线上文档
smartsheet: 智能表格

# 获取知识详情

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries/{entry_id}

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
entry_id 节点ID

响应

文件类型(entry_type=file)的响应


{
  "data": {
    "type": "kb_entry",
    "id": "552d9d5729e94b1485c34afa3dae6b1f",
    "attributes": {
      "name": "excel",
      "entry_type": "file",
      "created_at": "2025-05-23 15:55:39",
      "updated_at": "2025-05-23 15:55:39"
    },
    "relationships": {
      "parent": {
        "data": {
          "type": "kb_entry",
          "id": "09c081349f704daba4185da852cf0df5"
        }
      },
      "owner": {
        "data": {
          "type": "staff",
          "id": "ThreeZhang"
        }
      }
    }
  },
  "included": [
    {
      "type": "kb_entry",
      "id": "09c081349f704daba4185da852cf0df5",
      "attributes": {
        "name": "#ROOT#",
        "entry_type": "root",
        "created_at": "2025-04-18 10:20:09",
        "updated_at": "2025-05-23 15:55:39"
      }
    },
    {
      "type": "staff",
      "id": "ThreeZhang",
      "attributes": {
        "name": "张三",
        "english_name": "ThreeZhang",
        "organization": "开发部"
      }
    }
  ],
  "links": {
    "download": "https://file.lexiang-asset.com/xxx/kb/entries/2025/05/xxx.xlsx?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=X-Amz-Credential"
  }
}

参数说明

参数 说明
data.attributes.name 文件标题
data.attributes.created_at 文件创建时间
data.attributes.updated_at 文件内容最后修改时间
links.download 可下载原始文件,有效时长为60分钟

# 获取知识自定义属性

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries/{entry_id}/properties/values

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
entry_id 节点ID

响应


{
  "data": {
    "attributes": {
      "自定义属性名1": [
        {
          "value": "选项1"
        },
        {
          "value": "选项2"
        }
      ],
      "自定义属性名2": {
        "value": "分类1"
      } 
    }
  }
}

参数说明

参数 是否必须 说明
data.attributes.自定义属性名 自定义属性值
自定义字段为选项时,值为列表套value对象
自定义字段为分类时,值为value对象
自定义字段为文本时,值为value对象

# 获取线上文档内容

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries/{entry_id}/content

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
entry_id 知识节点ID,只支持entry_type=page的知识节点,即线上文档
content_type 导出内容格式,固定值:"html"

响应

200 Ok 状态码


{
    "data": {
        "type": "kb_entry",
        "id": "a0a5aaxxxxxxxxxxxxxxxxxxxxxx3b27e3c2",
        "attributes": {
            "name": "文档标题",
            "html_content": "\n<div class=\"page\" data-type=\"page\">\n<p class=\"p\" data-type=\"p\" >内容1</p>\n\n<p class=\"p\" data-type=\"p\" >内容2</p>\n\n<p class=\"p\" data-type=\"p\" >内容3</p>\n</div>\n"
        }
    }
}

参数说明

参数 说明
name 文档标题
html_content 转化为html格式内容

返回的html_content里可能会包含附件链接/kb_files/{file_id},若需要下载附件,参考获取附件详情

# 删除知识节点

此接口删除知识节点时需要保证要删除的知识节点下没有其他的子知识节点。

请求URL

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/kb/entries/{entry_id}

请求头

参数 是否必须 说明
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为知识节点的删除者
若不希望指定删除者或忽略权限校验,可设置为固定值:"system-bot"

其他说明

事项 说明
权限要求 知识库管理
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
entry_id 知识节点ID

响应

204 No Content