返回顶部
f

feishu-doc-editor飞书文档编辑

Feishu document creation and editing operations using OpenAPI. Activate when user needs to create, edit, or read Feishu documents programmatically.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
1,751
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

feishu-doc-editor

Feishu 文档编辑器技能

本技能提供使用飞书开放API创建和编辑飞书文档的全面指导。

前置条件

1. 应用创建与配置

创建企业自建应用:登录飞书开放平台,创建应用并添加机器人能力。

申请API权限:在权限管理中申请以下权限:

  • - 文档编辑:docx:document:write_only
  • 文档查看:docx:document:readonly

发布应用:提交版本并发布,确保应用覆盖范围包含目标用户/部门。

2. 获取访问令牌

调用自建应用获取 tenantaccesstoken 接口:

bash
curl -X POST https://open.feishu.cn/open-apis/auth/v3/tenantaccesstoken/internal \
-H Content-Type: application/json \
-d {appid: yourappid, appsecret: yourappsecret}

响应示例:

json
{
code: 0,
tenantaccesstoken: t-xxx,
expire: 7200
}

核心操作

提取文档ID

从文档URL中获取 document_id:

示例URL:https://bigdatacenter.feishu.cn/docx/HpK2dtGu9omhMAxV12zcB6i7ngd

document_id = HpK2dtGu9omhMAxV12zcB6i7ngd

授予应用文档权限

手动添加协作者

  • - 在飞书客户端打开文档 → 点击右上角... → 更多 → 添加文档应用
  • 搜索并添加你的应用,授予可编辑权限。

写入文本内容

接口:创建块

  • - 路径参数:documentid = 文档ID,blockid = 文档ID(根节点即为文档本身)
  • 请求头
http Authorization: Bearer {tenantaccesstoken} Content-Type: application/json
  • - 请求体示例(写入hello):
json { index: -1, children: [ { block_type: 2, text: { elements: [ { text_run: { content: hello } } ] } } ] }

读取文档内容

接口:获取文档纯文本

bash
curl -X GET https://open.feishu.cn/open-apis/docx/v1/documents/{document_id}/plaintext \
-H Authorization: Bearer {tenantaccesstoken}

响应示例:

json
{
code: 0,
data: {
content: 文档文本内容在此
}
}

常见问题

1. 权限错误(403 Forbidden)

  • - 诊断:应用未添加为文档协作者,或 tenantaccesstoken 无效。
  • 解决方案:重新将应用添加为协作者,或重新获取 tenantaccesstoken。

2. 缺少访问令牌(99991661)

  • - 诊断:请求头未携带 Authorization: Bearer {token}。
  • 解决方案:确保在请求头中正确添加 tenantaccesstoken。

3. 文档未找到(404 Not Found)

  • - 诊断:documentid 错误或文档已被删除。
  • 解决方案:从文档URL中重新提取 documentid。

参考文档

  • - 创建块接口
  • 获取文档纯文本接口
  • 权限配置指南

通过以上步骤,你可以实现通过API编辑飞书文档,支持文本、表格、图片等多种内容类型的增删改查操作。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 feishu-doc-editor-1776420033 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 feishu-doc-editor-1776420033 技能

通过命令行安装

skillhub install feishu-doc-editor-1776420033

下载

⬇ 下载 feishu-doc-editor v1.0.0(免费)

文件大小: 12.38 KB | 发布时间: 2026-4-17 18:51

v1.0.0 最新 2026-4-17 18:51
Initial release of the Feishu Document Editor skill.

- Supports programmatic creation, editing, and reading of Feishu documents using the Feishu OpenAPI.
- Provides step-by-step setup: app creation, permission assignment, and token generation.
- Includes detailed instructions for adding the app as a collaborator and managing document permissions.
- Explains API usage for both writing and reading document content with example requests and responses.
- Documents common error scenarios and their solutions for smoother troubleshooting.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部