Feishu API Lookup
Query Feishu Open Platform API documentation on demand. Since the Feishu docs site is a SPA that can't be statically scraped, this skill uses web search + page fetch to find API docs in real-time.
When to Use
- - Need to find a Feishu API endpoint (e.g., "how to forward a thread")
- Need to understand API parameters, request/response format
- Writing a Python/Node script that calls Feishu APIs
- Troubleshooting Feishu API error codes
- The built-in OpenClaw feishu plugin doesn't support the needed operation
How to Look Up
Step 1: Search for the API
Use web_search with targeted queries:
CODEBLOCK0
Search tips:
- - Use Chinese keywords for better results: "发送消息", "转发话题", "合并转发", "创建文档", "多维表格"
- Add
site:open.feishu.cn to limit to official docs - Add
POST /im/v1/ or similar path patterns if you know the API domain - Alternative: search
site:feishu.apifox.cn for the Apifox mirror (sometimes more accessible)
Common API domains:
| Domain | Path prefix | Description |
|---|
| 消息 (IM) | INLINECODE4 | Messages, threads, reactions, pins |
| 通讯录 |
/contact/v3/ | Users, departments, groups |
| 云文档 |
/drive/v1/,
/docx/v1/ | Docs, sheets, files |
| 多维表格 |
/bitable/v1/ | Bitable (multidimensional tables) |
| 知识库 |
/wiki/v2/ | Wiki spaces, nodes |
| 日历 |
/calendar/v4/ | Calendars, events |
| 审批 |
/approval/v4/ | Approvals |
| 任务 |
/task/v2/ | Tasks |
| 群组 |
/im/v1/chats/ | Chat groups |
| 权限 |
/drive/v1/permissions/ | File permissions |
| 应用 |
/application/v6/ | App management |
Step 2: Fetch the API doc page
Use web_fetch to get the doc content:
CODEBLOCK1
⚠️ The official docs site is SPA-rendered — web_fetch may return empty content.
Fallbacks when web_fetch fails:
- 1. Try the Apifox mirror:
https://feishu.apifox.cn (search for the API there) - Search for the Chinese doc URL pattern: INLINECODE19
- Use
web_search with more specific queries to find the exact parameters
Step 3: Extract key information
From the doc, extract:
- - HTTP Method + URL: e.g., INLINECODE21
- Headers: Usually
Authorization: Bearer {tenant_access_token} + INLINECODE23 - Path params: Variables in the URL
- Query params: Required/optional query parameters
- Request body: JSON structure with field types and descriptions
- Response body: Expected response format
- Error codes: Common errors and fixes
- Required permissions: Which scopes are needed
Authentication
Almost all Feishu APIs need a tenant_access_token. Get it from:
CODEBLOCK2
Common Patterns
Send a request to Feishu API
CODEBLOCK3
Pagination pattern
Many list APIs use cursor-based pagination:
CODEBLOCK4
Frequently Used APIs (Quick Reference)
Messages (IM)
| Action | Method | Path |
|---|
| Send message | POST | INLINECODE25 |
| Reply to message |
POST |
/im/v1/messages/{message_id}/reply |
| Forward message | POST |
/im/v1/messages/{message_id}/forward?receive_id_type={type} |
| Merge forward | POST |
/im/v1/messages/merge_forward?receive_id_type={type} |
| Forward thread | POST |
/im/v1/threads/{thread_id}/forward?receive_id_type={type} |
| Get message | GET |
/im/v1/messages/{message_id} |
| List messages | GET |
/im/v1/messages?container_id_type=chat&container_id={id} |
| Delete message | DELETE |
/im/v1/messages/{message_id} |
| Update message | PATCH |
/im/v1/messages/{message_id} |
| Add reaction | POST |
/im/v1/messages/{message_id}/reactions |
| Get message file | GET |
/im/v1/messages/{message_id}/resources/{file_key}?type={type} |
Groups (Chat)
| Action | Method | Path |
|---|
| Create group | POST | INLINECODE36 |
| Get group info |
GET |
/im/v1/chats/{chat_id} |
| List members | GET |
/im/v1/chats/{chat_id}/members |
| Add members | POST |
/im/v1/chats/{chat_id}/members |
Docs
| Action | Method | Path |
|---|
| Create document | POST | INLINECODE40 |
| Get document content |
GET |
/docx/v1/documents/{document_id}/raw_content |
| List blocks | GET |
/docx/v1/documents/{document_id}/blocks |
| Create block | POST |
/docx/v1/documents/{document_id}/blocks/{block_id}/children |
| Update block | PATCH |
/docx/v1/documents/{document_id}/blocks/{block_id} |
| Delete block | DELETE |
/docx/v1/documents/{document_id}/blocks/{block_id}/children/batch_delete |
Drive
| Action | Method | Path |
|---|
| Upload file | POST | INLINECODE46 |
| List folder |
GET |
/drive/v1/files?folder_token={token} |
| Get file info | GET |
/drive/v1/metas/batch_query |
| Move file | POST |
/drive/v1/files/{file_token}/move |
Bitable
| Action | Method | Path |
|---|
| List records | GET | INLINECODE50 |
| Create record |
POST |
/bitable/v1/apps/{app_token}/tables/{table_id}/records |
| Update record | PUT |
/bitable/v1/apps/{app_token}/tables/{table_id}/records/{record_id} |
| List fields | GET |
/bitable/v1/apps/{app_token}/tables/{table_id}/fields |
| Search records | POST |
/bitable/v1/apps/{app_token}/tables/{table_id}/records/search |
Wiki
| Action | Method | Path |
|---|
| List spaces | GET | INLINECODE55 |
| Get node |
GET |
/wiki/v2/spaces/get_node?token={token} |
| List nodes | GET |
/wiki/v2/spaces/{space_id}/nodes |
| Create node | POST |
/wiki/v2/spaces/{space_id}/nodes |
Permissions
| Action | Method | Path |
|---|
| List permissions | GET | INLINECODE59 |
| Add permission |
POST |
/drive/v1/permissions/{token}/members?type={type} |
| Remove permission | DELETE |
/drive/v1/permissions/{token}/members/{member_id}?type={type} |
Error Handling
Common error codes:
- -
99991663 — Invalid tenantaccesstoken (expired or wrong) - INLINECODE63 — Invalid useraccesstoken
- INLINECODE64 — Invalid request parameter
- INLINECODE65 — Bot not in group
- INLINECODE66 — User not in bot's availability scope
- INLINECODE67 — Rate limit exceeded
- INLINECODE68 — Insufficient permissions
Tips
- 1. Always use the
/open-apis/ prefix in the full URL: INLINECODE70 - Token expires in 2 hours — cache it but refresh before expiry
- receiveidtype matters —
open_id for users, chat_id for groups, union_id for cross-app - File uploads use multipart/form-data, not JSON
- Feishu vs Lark — same API, different domain (
open.feishu.cn vs open.larksuite.com)
飞书 API 查询
按需查询飞书开放平台 API 文档。由于飞书文档站点是一个单页应用(SPA),无法进行静态爬取,本技能使用网络搜索+页面抓取来实时查找 API 文档。
使用场景
- - 需要查找飞书 API 端点(例如:如何转发话题)
- 需要了解 API 参数、请求/响应格式
- 编写调用飞书 API 的 Python/Node 脚本
- 排查飞书 API 错误码
- 内置的 OpenClaw 飞书插件不支持所需操作
查询方法
步骤 1:搜索 API
使用 web_search 进行针对性查询:
web_search(飞书 open API {你要找的功能} site:open.feishu.cn)
搜索技巧:
- - 使用中文关键词可获得更好结果:发送消息、转发话题、合并转发、创建文档、多维表格
- 添加 site:open.feishu.cn 限制在官方文档范围内
- 如果知道 API 域名,可添加 POST /im/v1/ 或类似路径模式
- 备选方案:搜索 site:feishu.apifox.cn 访问 Apifox 镜像(有时更易访问)
常见 API 域名:
| 域名 | 路径前缀 | 描述 |
|---|
| 消息 (IM) | /im/v1/ | 消息、话题、表情回复、置顶 |
| 通讯录 |
/contact/v3/ | 用户、部门、群组 |
| 云文档 | /drive/v1/、/docx/v1/ | 文档、表格、文件 |
| 多维表格 | /bitable/v1/ | 多维表格 |
| 知识库 | /wiki/v2/ | 知识库空间、节点 |
| 日历 | /calendar/v4/ | 日历、事件 |
| 审批 | /approval/v4/ | 审批 |
| 任务 | /task/v2/ | 任务 |
| 群组 | /im/v1/chats/ | 聊天群组 |
| 权限 | /drive/v1/permissions/ | 文件权限 |
| 应用 | /application/v6/ | 应用管理 |
步骤 2:获取 API 文档页面
使用 web_fetch 获取文档内容:
web_fetch(https://open.feishu.cn/document/server-docs/im-v1/message/create, maxChars=15000)
⚠️ 官方文档站点是 SPA 渲染的——web_fetch 可能返回空内容。
当 web_fetch 失败时的备选方案:
- 1. 尝试 Apifox 镜像:https://feishu.apifox.cn(在此搜索 API)
- 搜索中文文档 URL 模式:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/...
- 使用 web_search 进行更具体的查询以找到精确参数
步骤 3:提取关键信息
从文档中提取:
- - HTTP 方法 + URL:例如 POST /open-apis/im/v1/messages/{messageid}/forward
- 请求头:通常为 Authorization: Bearer {tenantaccess_token} + Content-Type: application/json
- 路径参数:URL 中的变量
- 查询参数:必需/可选的查询参数
- 请求体:包含字段类型和描述的 JSON 结构
- 响应体:预期的响应格式
- 错误码:常见错误及修复方法
- 所需权限:需要哪些作用域
身份认证
几乎所有飞书 API 都需要 tenantaccesstoken。获取方式如下:
python
import json, urllib.request
with open(/root/.openclaw/openclaw.json) as f:
cfg = json.load(f)
app_id = cfg[channels][feishu][appId]
app_secret = cfg[channels][feishu][appSecret]
req = urllib.request.Request(
https://open.feishu.cn/open-apis/auth/v3/tenantaccesstoken/internal,
data=json.dumps({appid: appid, appsecret: appsecret}).encode(),
headers={Content-Type: application/json}
)
token = json.loads(urllib.request.urlopen(req).read())[tenantaccesstoken]
常见模式
向飞书 API 发送请求
python
req = urllib.request.Request(
fhttps://open.feishu.cn/open-apis/{api_path},
data=json.dumps(body).encode(),
headers={
Content-Type: application/json,
Authorization: fBearer {token}
}
)
try:
resp = json.loads(urllib.request.urlopen(req).read())
except urllib.error.HTTPError as e:
resp = json.loads(e.read().decode())
分页模式
许多列表 API 使用游标分页:
python
page_token = None
all_items = []
while True:
url = fhttps://open.feishu.cn/open-apis/{path}?page_size=50
if page_token:
url += f&pagetoken={pagetoken}
resp = fetch(url)
all_items.extend(resp[data][items])
if not resp[data].get(has_more):
break
pagetoken = resp[data][pagetoken]
常用 API(快速参考)
消息(IM)
| 操作 | 方法 | 路径 |
|---|
| 发送消息 | POST | /im/v1/messages?receiveidtype={type} |
| 回复消息 |
POST | /im/v1/messages/{message_id}/reply |
| 转发消息 | POST | /im/v1/messages/{message
id}/forward?receiveid_type={type} |
| 合并转发 | POST | /im/v1/messages/merge
forward?receiveid_type={type} |
| 转发话题 | POST | /im/v1/threads/{thread
id}/forward?receiveid_type={type} |
| 获取消息 | GET | /im/v1/messages/{message_id} |
| 列出消息 | GET | /im/v1/messages?container
idtype=chat&container_id={id} |
| 删除消息 | DELETE | /im/v1/messages/{message_id} |
| 更新消息 | PATCH | /im/v1/messages/{message_id} |
| 添加表情回复 | POST | /im/v1/messages/{message_id}/reactions |
| 获取消息文件 | GET | /im/v1/messages/{message
id}/resources/{filekey}?type={type} |
群组(聊天)
| 操作 | 方法 | 路径 |
|---|
| 创建群组 | POST | /im/v1/chats |
| 获取群组信息 |
GET | /im/v1/chats/{chat_id} |
| 列出成员 | GET | /im/v1/chats/{chat_id}/members |
| 添加成员 | POST | /im/v1/chats/{chat_id}/members |
文档
| 操作 | 方法 | 路径 |
|---|
| 创建文档 | POST | /docx/v1/documents |
| 获取文档内容 |
GET | /docx/v1/documents/{document
id}/rawcontent |
| 列出块 | GET | /docx/v1/documents/{document_id}/blocks |
| 创建块 | POST | /docx/v1/documents/{document
id}/blocks/{blockid}/children |
| 更新块 | PATCH | /docx/v1/documents/{document
id}/blocks/{blockid} |
| 删除块 | DELETE | /docx/v1/documents/{document
id}/blocks/{blockid}/children/batch_delete |
云空间
| 操作 | 方法 | 路径 |
|---|
| 上传文件 | POST | /drive/v1/medias/uploadall |
| 列出文件夹 |
GET | /drive/v1/files?foldertoken={token} |
| 获取文件信息 | GET | /drive/v1/metas/batch_query |
| 移动文件 | POST | /drive/v1/files/{file_token}/move |
多维表格
| 操作 | 方法 | 路径 |
|---|
| 列出记录 | GET | /bitable/v1/apps/{apptoken}/tables/{tableid}/records |
| 创建记录 |
POST | /bitable/v1/apps/{app
token}/tables/{tableid}/records |
| 更新记录 | PUT | /bitable/v1/apps/{app
token}/tables/{tableid}/records/{record_id} |
| 列出字段 | GET | /bitable/v1/apps/{app_token}/t