# 团队知识库接口

# 创建知识库

请求URL

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

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为知识库创建人,需具备在团队内创建知识库的权限

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参data.relationships.team.data.id需在该范围内
频率限制 3000次/分钟

请求参数

{
  "data": {
    "type": "kb_space",
    "attributes": {
      "name": "API新建知识库",
      "logo": "https://lexiangla.com/assets/68975160a41211ebbcc38ead0db1c463",
      "visible_type": 1,
      "manager_inherit_type": "viewer",
      "member_inherit_type": "editor"
    },
    "relationships": {
      "team": {
        "data": {
          "type": "team",
          "id": "xx"
        }
      },
      "subject": {
        "data": [
          {
            "type": "staff",
            "id": "ThreeZhang",
            "attributes": {
              "role": "viewer"
            }
          },
          {
            "type": "department",
            "id": 1,
            "attributes": {
              "role": "editor"
            }
          }
        ]
      }
    }
  }
}

参数说明

参数 是否必须 说明
data.attributes.name 知识库名称,长度为1~100个字符
data.attributes.logo 知识库图标,建议使用乐享图片地址,参考素材上传,长度为1~1000个字符
data.attributes.visible_type 可见类型 0 不可见 1 可见 2 跟随团队
data.attributes.manager_inherit_type 给知识库所属团队的管理员分配角色
none:无权限 viewer:仅查看 downloader:可查看/下载 editor:可编辑 manager:可管理
data.attributes.member_inherit_type 给知识库所属团队的成员分配角色
none:无权限 default:与团队一致 viewer:仅查看 downloader:可查看/下载 editor:可编辑 manager:可管理
data.relationships.team 知识库所属团队
data.relationships.team.data.id 知识库所属团队ID
data.relationships.subject 知识库权限设置
data.relationships.subject.data.type 知识库权限设置的对象类型
staff:成员;department:部门
data.relationships.subject.data.id 知识库权限设置的对象ID,成员帐号或部门ID
data.relationships.subject.data.attributes.role 给当前对象分配的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

响应

200 Ok 状态码

{
  "data": {
    "type": "kb_space",
    "id": "fe604f859a7d495fbb5f0d477f655a4b",
    "attributes": {
      "name": "API新建知识库",
      "logo": "https://lexiangla.com/assets/68975160a41211ebbcc38ead0db1c463",
      "visible_type": 1,
      "manager_inherit_type": "viewer",
      "member_inherit_type": "editor"
    },
    "relationships": {
      "team": {
        "data": {
          "type": "team",
          "id": "xx"
        }
      },
      "root_entry": {
        "data": {
          "type": "kb_entry",
          "id": "bb04ff9a1d484d02ab5419a81170b01b"
        }
      }
    }
  },
  "included": [
    {
      "type": "team",
      "id": "xx",
      "attributes": {
        "name": "xx",
        "code": "xx"
      },
      "links": {
        "platform": "https://lexiangla.com/teams/fdbfgbs"
      }
    },
    {
      "type": "kb_entry",
      "id": "bb04ff9a1d484d02ab5419a81170b01b",
      "attributes": {
        "name": "#ROOT#",
        "entry_type": "root",
        "created_at": "2025-03-18 16:32:19",
        "updated_at": "2025-03-18 16:32:19"
      }
    }
  ]
}

参数说明

参数 说明
name 知识库名称
logo 知识库图标
relationships.team.data.id 知识库所属团队ID
relationships.root_entry.data.id 知识库的根目录节点

# 更新知识库

请求URL

PUT https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为更新者需具有对应知识库操作权限

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

URL 参数说明

参数 是否必须 说明
space_id 知识库ID

请求参数

{
  "data": {
    "attributes": {
      "name": "API新建知识库"
    }
  }
}

参数说明

参数 是否必须 说明
data.attributes.name 知识库名称,长度为1~100个字符

响应

200 Ok 状态码

{
  "data": {
    "type": "kb_space",
    "id": "fe604f859a7d495fbb5f0d477f655a4b",
    "attributes": {
      "name": "API新建知识库"
    }
  }
}

参数说明

参数 说明
name 知识库名称

# 删除知识库

请求URL

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为删除者需具有对应知识库操作权限

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

URL 参数说明

参数 是否必须 说明
space_id 知识库ID

响应

200 Ok 状态码

# 设置成员与权限

请求URL

POST https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}/subject?downgrade={downgrade}

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为设置者需具有操作权限
若不希望指定设置者或忽略权限校验,可设置为固定值:"system-bot"

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

URL 参数说明

参数 是否必须 说明
space_id 知识库ID
downgrade 是否允许覆盖权限。默认为1,设置为1时新权限会直接覆盖原有权限。设置为0时,只增加权限,低权限不会覆盖高权限

请求参数

{
  "data": [
    {
      "type": "staff",
      "id": "ThreeZhang",
      "attributes": {
        "role": "viewer"
      }
    },
    {
      "type": "department",
      "id": 1,
      "attributes": {
        "role": "editor"
      }
    }
  ]
}

参数说明

参数 是否必须 说明
data 请求数据数组,每项为一个对象。
data.*.type 对象类型,staff, department 或 contact_tag。
data.*.id 对象ID。staff 填成员帐号,department 填部门ID,contact_tag填成员标签ID。
data.*.attributes.role 给当前对象分配的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

响应

200 Ok 状态码

# 移除成员与权限

请求URL

DELETE https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}/subject

请求头

参数 是否必须 说明
Content-Type 固定值:"application/json; charset=utf-8"
Authorization 接口调用凭证 access_token
值格式:"Bearer access_token"
示例值:"Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJS"
x-staff-id 成员帐号,作为移除者需具有操作权限
若不希望指定移除者或忽略权限校验,可设置为固定值:"system-bot"

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

URL 参数说明

参数 是否必须 说明
space_id 知识库ID

请求参数

{
  "data": {
    "type": "staff",
    "id": "ThreeZhang",
    "attributes": {
      "role": "viewer"
    }
  }
}

参数说明

参数 是否必须 说明
data.type 对象类型,staff, department 或 contact_tag。
data.id 对象ID。staff 填成员帐号,department 填部门ID,contact_tag填成员标签ID。
data.attributes.role 当前对象的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

响应

200 Ok 状态码

# 获取知识库列表

请求URL

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

请求头

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

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参team_id需在该范围内
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
team_id 团队ID
limit 拉取条数
page_token 分页游标,根据上一页返回的page_token传入

响应

200 Ok 状态码

{
  "data": [
    {
      "type": "kb_space",
      "id": "fe604f859a7d495fbb5f0d477f655a4b",
      "attributes": {
        "name": "知识库1",
        "logo": ""
      },
      "relationships": {
        "root_entry": {
          "data": {
            "type": "kb_entry",
            "id": "bb04ff9a1d484d02ab5419a81170b01b"
          }
        }
      }
    },
    {
      "type": "kb_space",
      "id": "1a3d51a4295d44f9806a1a8f04af4021",
      "attributes": {
        "name": "知识库2",
        "logo": ""
      },
      "relationships": {
        "root_entry": {
          "data": {
            "type": "kb_entry",
            "id": "ef94c6bd5bdb41b6b9b6ba9f47f0e34b"
          }
        }
      }
    }
  ],
  "included": [
    {
      "type": "kb_entry",
      "id": "bb04ff9a1d484d02ab5419a81170b01b",
      "attributes": {
        "name": "#ROOT#",
        "entry_type": "root",
        "created_at": "2025-03-18 16:32:19",
        "updated_at": "2025-03-18 16:32:19"
      }
    },
    {
      "type": "kb_entry",
      "id": "ef94c6bd5bdb41b6b9b6ba9f47f0e34b",
      "attributes": {
        "name": "#ROOT#",
        "entry_type": "root",
        "created_at": "2025-03-18 16:51:40",
        "updated_at": "2025-03-18 20:08:20"
      }
    }
  ],
  "meta": {
    "page_token": "xx"
  }
}

参数说明

参数 说明
name 知识库名称
logo 知识库图标,若是上传的素材需要下载可参考素材下载
relationships.root_entry.data.id 知识库的根目录节点

# 获取知识库详情

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}

请求头

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

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
space_id 知识库ID

响应

200 Ok 状态码


{
  "data": {
    "type": "kb_space",
    "id": "28b531639c9a4bef8ac0a324a8e3xxxx",
    "attributes": {
      "name": "知识库名称",
      "description": "知识库空间描述",
      "logo": "xxx",
      "visible_type": 1,
      "manager_inherit_type": "viewer",
      "member_inherit_type": "editor"
    },
    "relationships": {
      "team": {
        "data": {
          "type": "team",
          "id": "cc96233cd55711ebb6120242ac1cxxxx"
        }
      },
      "root_entry": {
        "data": {
          "type": "kb_entry",
          "id": "1c3955b7c3e64992aeb48b17c53xxxx"
        }
      }
    }
  },
  "included": [
    {
      "type": "team",
      "id": "cc96233cd55711ebb6120242ac1cxxxx",
      "attributes": {
        "name": "团队名称",
        "code": "xxx"
      }
    },
    {
      "type": "kb_entry",
      "id": "1c3955b7c3e64992aeb48b17c53xxxx",
      "attributes": {
        "name": "#ROOT#",
        "entry_type": "root",
        "created_at": "2025-07-12 10:02:45",
        "updated_at": "2025-07-12 10:26:46"
      }
    }
  ]
}

参数说明

参数 说明
data.attributes.name 知识库名称
data.attributes.logo 知识库图标,若是上传的素材需要下载可参考素材下载
data.attributes.visible_type 可见类型 0 不可见 1 可见 2 跟随团队
data.attributes.manager_inherit_type 给知识库所属团队的管理员分配角色
none:无权限 viewer:仅查看 downloader:可查看/下载 editor:可编辑 manager:可管理
data.attributes.member_inherit_type 给知识库所属团队的成员分配角色
none:无权限 default:与团队一致 viewer:仅查看 downloader:可查看/下载 editor:可编辑 manager:可管理
data.relationships.team 知识库所属团队
data.relationships.root_entry 知识库根目录节点

# 获取成员与权限

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}/subject

请求头

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

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
space_id 知识库的 id
page_token 用于分页,从响应的meta.page_token获取
limit 每页拉取条数,默认100;最大100
role 指定要拉取的角色。可选值:
manager(可管理)
editor(可编辑)
downloader(可查看/下载)
viewer(仅查看)
不指定时拉取所有角色

响应

200 Ok 状态码

{
  "data": [
    {
      "type": "staff",
      "id": "xiaochen",
      "attributes": {
        "name": "小陈",
        "english_name": "chen",
        "organization": "开发组",
        "role": "viewer"
      }
    },
    {
      "type": "department",
      "id": 1,
      "attributes": {
        "name": "xx公司",
        "order": 33655,
        "role": "viewer"
      }
    },
    {
        "type": "contact_tag",
        "id": "1",
        "attributes": {
            "id": "1",
            "name": "成员标签",
            "role": "viewer"
        }
    }
  ],
  "meta": {
    "page_token": "WyJzdGFmZiIsMTE3ODk2XQ"
  }
}

参数说明

data.type = staff

参数 说明
name 成员名称
english_name 成员别名
organization 成员所属部门
role 给当前对象分配的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

data.type = department

参数 说明
name 部门名称
order 显示优先级
role 给当前对象分配的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

data.type = contact_tag

参数 说明
name 成员标签名称
role 给当前对象分配的角色
manager:管理 editor:编辑 downloader:查看下载 viewer:仅查看

# 获取反馈列表

请求URL

GET https://lxapi.lexiangla.com/cgi-bin/v1/kb/spaces/{space_id}/feedbacks

请求头

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

其他说明

事项 说明
权限要求 知识库管理
授权范围 AppKey绑定团队时,入参space_id知识库需在授权的团队下
频率限制 3000次/分钟

参数说明

参数 是否必须 说明
space_id 知识库ID
limit 限制个数,1~100 以内的整数
page_token 分页游标,根据上一页返回的page_token传入

响应

200 Ok 状态码


{
    "data": [
        {
            "type": "kb_feedback",
            "id": "48d8a0fc13b84eb594439676000xxxxx",
            "attributes": {
                "status": "unprocessed",
                "type": "kb_content_incomplete",
                "created_at": "2025-06-30 18:53:28",
                "reviewed_at": "2025-06-30 19:20:20",
                "content": "这是反馈的内容",
                "attachments": [
                    "https://abc.lexiangla.com/assets/78942ea5a81d459eb5656f3c3d1329f8?company_from=abc",
                    "https://abc.lexiangla.com/assets/8e38f9f2d4104e20ac4bd4afe81c0743?company_from=abc",
                    "https://abc.lexiangla.com/assets/8c8fb79edf9f4ab6b81f840559915dc4?company_from=abc"
                ]
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": " LX002"
                    }
                },
                "reviewers": {
                    "data": [
                        {
                            "type": "staff",
                            "id": "LX001"
                        }
                    ]
                },
                "entry": {
                    "data": {
                        "type": "kb_entry",
                        "id": "1e6b5571856b4b50b4c7d9c66d0xxxxx"
                    }
                }
            }
        },
        {
            "type": "kb_feedback",
            "id": "f47c845ee4484651852e0fc2e7xxxxx",
            "attributes": {
                "status": "unprocessed",
                "type": "kb_content_incomplete",
                "created_at": "2025-06-30 19:59:24",
                "content": "这是第二个反馈内容",
                "attachments": [
                    "https://abc.lexiangla.com/assets/48bb2746c94d46f2ae3398e3b66445a5?company_from=abc",
                    "https://abc.lexiangla.com/assets/b4d68433966f4e0abce3d95fdedcddfc?company_from=abc",
                    "https://abc.lexiangla.com/assets/15fd7461212748a3b3cf78ad73bfd796?company_from=abc",
                    "https://abc.lexiangla.com/assets/9b9bb659730b4c68bffd56cb2ecd98d4?company_from=abc"
                ]
            },
            "relationships": {
                "owner": {
                    "data": {
                        "type": "staff",
                        "id": " LX002"
                    }
                },
                "reviewers": {
                    "data": [
                        {
                            "type": "staff",
                            "id": "LX003"
                        }
                    ]
                },
                "entry": {
                    "data": {
                        "type": "kb_entry",
                        "id": "1e6b5571856b4b50b4c7d9c66dxxxxx"
                    }
                }
            }
        }
    ],
    "included": [
        {
            "type": "staff",
            "id": "LX002",
            "attributes": {
                "name": "LX002",
                "english_name": "别名2",
                "organization": "开发组"
            }
        },
        {
            "type": "staff",
            "id": "LX001",
            "attributes": {
                "name": "LX001",
                "english_name": "别名",
                "organization": "开发组"
            }
        },
        {
            "type": "kb_entry",
            "id": "1e6b5571856b4b50b4c7d9c66dxxxxx",
            "attributes": {
                "name": "这是页面名称",
                "entry_type": "page",
                "created_at": "2025-06-25 16:45:50",
                "updated_at": "2025-07-01 02:07:19"
            }
        }
    ],
    "meta": {
        "page_token": "WyIyMDI1LTA2LTMwVDE4OjUzOjI4KzA4OjAwIiwiNDhkOGEwZmMxM2I4NGViNTk0NDM5Njc2MDAwMzA0NjMiXQ=="
    }
}

参数说明

参数 说明
status 状态;
unprocessed表示未处理;
processing表示处理中;
processed表示已处理;
not_process表示无需处理
type 类型;
kb_content_incomplete表示内容缺失;
kb_content_mistake表示内容有误;
kb_content_suggestion表示内容建议;
kb_content_too_old表示内容陈旧;
kb_content_other表示其他
created_at 创建时间
reviewed_at 反馈处理时间
content 反馈内容
attachments 反馈图片,可根据 id 在 included 中查找
relationships.owner 反馈创建者,可根据 id 在 included 中查找
reviewers 反馈处理人,多个,可根据 id 在 included 中查找
entry 反馈对象,可根据 id 在 included 中查找