# 团队知识库接口

# 创建知识库

请求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 成员帐号,作为知识库创建人

其他说明

事项 说明
权限要求 知识库管理
频率限制 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 知识库名称
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.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": "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

POST 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"

其他说明

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

URL 参数说明

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

请求参数

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

参数说明

参数 是否必须 说明
data 请求数据数组,每项为一个对象。
data.*.type 对象类型,staff 或 department。
data.*.id 对象ID。staff 填成员帐号,department 填部门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"

其他说明

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

URL 参数说明

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

请求参数

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

参数说明

参数 是否必须 说明
data.type 对象类型,staff 或 department。
data.id 对象ID。staff 填成员帐号,department 填部门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"

其他说明

事项 说明
权限要求 知识库管理
频率限制 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": "entry",
            "id": "bb04ff9a1d484d02ab5419a81170b01b"
          }
        }
      }
    },
    {
      "type": "kb_space",
      "id": "1a3d51a4295d44f9806a1a8f04af4021",
      "attributes": {
        "name": "知识库2",
        "logo": ""
      },
      "relationships": {
        "root_entry": {
          "data": {
            "type": "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"

其他说明

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

参数说明

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

响应

200 Ok 状态码


{
  "data": {
    "type": "kb_space",
    "id": "28b531639c9a4bef8ac0a324a8e3xxxx",
    "attributes": {
      "name": "知识库名称",
      "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"

其他说明

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

参数说明

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

响应

200 Ok 状态码

{
  "data": [
    {
      "type": "staff",
      "id": "3bffb092526f11f08bd622e604893cfb",
      "attributes": {
        "name": "小陈",
        "english_name": "chen",
        "organization": "开发组",
        "role": "viewer"
      }
    },
    {
      "type": "department",
      "id": 1,
      "attributes": {
        "name": "xx公司",
        "order": 33655,
        "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:仅查看