tencent-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTencent Docs (腾讯文档)
Tencent Docs (腾讯文档)
Drive the Tencent Docs Open API with
. Everything runs in the user's own Tencent Docs account — only
files they can access, only the scopes they granted at connect time.
curl + jq借助调用Tencent Docs Open API。所有操作均在用户自己的腾讯文档账户中进行——仅访问用户有权限的文件,仅使用用户在连接时授予的权限范围。
curl + jqAuth — three headers (NOT a single Bearer)
认证——三个请求头(而非单个Bearer令牌)
The BYOC connector injects three env vars; every call sends all
three headers:
tencentdocs- →
TENCENTDOCS_ACCESS_TOKENheader (OAuth2 access token). Secret.Access-Token - →
TENCENTDOCS_CLIENT_IDheader (the developer app's Client ID).Client-Id - →
TENCENTDOCS_OPEN_IDheader (the user id returned with the token).Open-Id
All endpoints live under . Define a reusable header
set once per session:
https://docs.qq.com/openapish
AUTH=(-H "Access-Token: $TENCENTDOCS_ACCESS_TOKEN" \
-H "Client-Id: $TENCENTDOCS_CLIENT_ID" \
-H "Open-Id: $TENCENTDOCS_OPEN_ID")Never echo, print, or log — it is full account access.
TENCENTDOCS_ACCESS_TOKENtencentdocs- →
TENCENTDOCS_ACCESS_TOKEN请求头(OAuth2访问令牌)。保密信息。Access-Token - →
TENCENTDOCS_CLIENT_ID请求头(开发者应用的客户端ID)。Client-Id - →
TENCENTDOCS_OPEN_ID请求头(令牌返回的用户ID)。Open-Id
所有接口端点都位于下。定义一个可复用的请求头集合,每个会话只需设置一次:
https://docs.qq.com/openapish
AUTH=(-H "Access-Token: $TENCENTDOCS_ACCESS_TOKEN" \
-H "Client-Id: $TENCENTDOCS_CLIENT_ID" \
-H "Open-Id: $TENCENTDOCS_OPEN_ID")切勿回显、打印或记录——它拥有账户的完全访问权限。
TENCENTDOCS_ACCESS_TOKENResponse shape & error handling
响应格式与错误处理
Every response is .
means success; any non-zero is an error — surface to the user.
Always check it:
{"ret": 0, "msg": "Succeed", "data": {…}}ret == 0retmsgsh
resp=$(curl -sS "${AUTH[@]}" … )
echo "$resp" | jq 'if .ret == 0 then .data else error("Tencent Docs \(.ret): \(.msg)") end'Common error codes:
| code | meaning | what to do |
|---|---|---|
| access token invalid / expired | tell the user to reconnect 腾讯文档 at https://auth.acedata.cloud/user/connections — do not loop-retry |
| VIP (超级会员) privilege required | the requested capability needs a Tencent Docs 超级会员; tell the user, link https://docs.qq.com/vip |
| 积分 (credits) insufficient | AI-generation quota is exhausted; tell the user to top up |
| bad request params | recheck |
每个响应的格式均为。表示成功;任何非零的值均为错误——需将内容展示给用户。务必检查该值:
{"ret": 0, "msg": "Succeed", "data": {…}}ret == 0retmsgsh
resp=$(curl -sS "${AUTH[@]}" … )
echo "$resp" | jq 'if .ret == 0 then .data else error("Tencent Docs \(.ret): \(.msg)") end'常见错误码:
| 错误码 | 含义 | 处理方式 |
|---|---|---|
| 访问令牌无效/过期 | 告知用户前往https://auth.acedata.cloud/user/connections重新连接腾讯文档——请勿循环重试 |
| 需要超级会员权限 | 请求的功能需要腾讯文档超级会员;告知用户并链接至https://docs.qq.com/vip |
| 积分不足 | AI生成配额已耗尽;告知用户进行充值 |
| 请求参数错误 | 根据下方的操作指南重新检查 |
Doc types (type
when creating)
type文档类型(创建时的type
参数)
type| type | Product | Notes |
|---|---|---|
| 在线文档 (Word-style) | classic rich-text document |
| 在线表格 (Excel) | data tables |
| 幻灯片 (PPT) | presentations |
| 思维导图 | mind map |
| 流程图 | flowchart |
| 智能表格 | structured multi-view table |
| 收集表 | form / survey |
| 类型值 | 产品 | 说明 |
|---|---|---|
| 在线文档(类Word) | 经典富文本文档 |
| 在线表格(类Excel) | 数据表格 |
| 幻灯片(类PPT) | 演示文稿 |
| 思维导图 | 思维导图 |
| 流程图 | 流程图 |
| 智能表格 | 结构化多视图表格 |
| 收集表 | 表单/调查问卷 |
Recipes
操作指南
Verify auth (always run first)
验证认证(务必首先执行)
Cheap sanity check — read the app's OpenAPI usage counter:
sh
curl -sS "${AUTH[@]}" "https://docs.qq.com/openapi/drive/v2/util/resource-use" \
| jq 'if .ret == 0 then .data else "ERR \(.ret): \(.msg)" end'If this returns , the connection is expired — have the user reconnect.
400006简单的完整性检查——读取应用的OpenAPI使用计数器:
sh
curl -sS "${AUTH[@]}" "https://docs.qq.com/openapi/drive/v2/util/resource-use" \
| jq 'if .ret == 0 then .data else "ERR \(.ret): \(.msg)" end'如果返回,则连接已过期——请用户重新连接。
400006List a folder (root = /
)
/列出文件夹内容(根目录 = /
)
/sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/folders/%2F?listType=folder&sortType=browse&asc=0" \
| jq 'if .ret == 0 then [.data.list[]? | {ID, title, type, url}] else . end'%2Fsh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/folders/%2F?listType=folder&sortType=browse&asc=0" \
| jq 'if .ret == 0 then [.data.list[]? | {ID, title, type, url}] else . end'%2FSearch files by keyword
按关键词搜索文件
sh
curl -sS -G "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/search" \
--data-urlencode "searchName=Q1 预算" \
| jq 'if .ret == 0 then [.data.list[]? | {ID, title, type, url}] else . end'sh
curl -sS -G "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/search" \
--data-urlencode "searchName=Q1 预算" \
| jq 'if .ret == 0 then [.data.list[]? | {ID, title, type, url}] else . end'Read a file's metadata
读取文件元数据
The is the last path segment of a (or
, , …) URL.
fileIDhttps://docs.qq.com/doc/<id>/sheet//slide/sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/metadata" \
| jq 'if .ret == 0 then .data else . end'fileIDhttps://docs.qq.com/doc/<id>/sheet//slide/sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/metadata" \
| jq 'if .ret == 0 then .data else . end'Read an online document's content
读取在线文档内容
sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/document/v3/files/FILE_ID/export?exportType=text" \
| jq 'if .ret == 0 then .data else . end'sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/document/v3/files/FILE_ID/export?exportType=text" \
| jq 'if .ret == 0 then .data else . end'Read a sheet's cell range
读取表格单元格区域
Get the sheet's list from the metadata first, then read a range
():
sheetIdA1:D10sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/spreadsheet/v2/files/FILE_ID/sheets/SHEET_ID/values?range=A1:D10" \
| jq 'if .ret == 0 then .data.values else . end'首先从元数据中获取表格的列表,然后读取指定区域(如):
sheetIdA1:D10sh
curl -sS "${AUTH[@]}" \
"https://docs.qq.com/openapi/spreadsheet/v2/files/FILE_ID/sheets/SHEET_ID/values?range=A1:D10" \
| jq 'if .ret == 0 then .data.values else . end'Create a file
创建文件
POST /openapi/drive/v2/filestitletypeIDurlsh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files" \
--data-urlencode "title=会议纪要 2026-07-03" \
--data-urlencode "type=doc" \
| jq 'if .ret == 0 then {ID: .data.ID, url: .data.url} else . end'Swap / / / / / for
other doc types. Pass to create inside a
folder instead of the root.
type=sheetslidemindflowchartsmartsheetform--data-urlencode "folderID=<id>"向发送表单编码的 + 参数。返回新文件的和。
POST /openapi/drive/v2/filestitletypeIDurlsh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files" \
--data-urlencode "title=会议纪要 2026-07-03" \
--data-urlencode "type=doc" \
| jq 'if .ret == 0 then {ID: .data.ID, url: .data.url} else . end'将/////替换为其他文档类型。添加参数可在指定文件夹内创建文件,而非根目录。
type=sheetslidemindflowchartsmartsheetform--data-urlencode "folderID=<id>"Upload an image (for embedding in docs)
上传图片(用于嵌入文档)
sh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/resources/v2/images" \
-F "file=@./cover.png" \
| jq 'if .ret == 0 then .data else . end'sh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/resources/v2/images" \
-F "file=@./cover.png" \
| jq 'if .ret == 0 then .data else . end'Rename a file — GATED, confirm first
重命名文件——需确认,执行前先核实
Show the user the current + and the new title, get an explicit
"yes", then run:
titleurlsh
curl -sS -X PATCH "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID" \
--data-urlencode "title=新的标题" \
| jq 'if .ret == 0 then "renamed" else . end'向用户展示当前文件的 + 以及新标题,获取明确的“确认”后再执行:
titleurlsh
curl -sS -X PATCH "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID" \
--data-urlencode "title=新的标题" \
| jq 'if .ret == 0 then "renamed" else . end'Move a file — GATED, confirm first
移动文件——需确认,执行前先核实
Show the user the file's current + location and the destination folder,
get an explicit "yes", then run. moves it back to the root.
titlefolderID=/sh
curl -sS -X PATCH "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/move" \
--data-urlencode "folderID=DEST_FOLDER_ID" \
| jq 'if .ret == 0 then "moved" else . end'向用户展示文件当前的 + 位置以及目标文件夹,获取明确的“确认”后再执行。表示将文件移回根目录。
titlefolderID=/sh
curl -sS -X PATCH "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/move" \
--data-urlencode "folderID=DEST_FOLDER_ID" \
| jq 'if .ret == 0 then "moved" else . end'Copy a file
复制文件
sh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/copy" \
--data-urlencode "title=副本 - 项目计划" \
| jq 'if .ret == 0 then {ID: .data.ID, url: .data.url} else . end'sh
curl -sS -X POST "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID/copy" \
--data-urlencode "title=副本 - 项目计划" \
| jq 'if .ret == 0 then {ID: .data.ID, url: .data.url} else . end'Delete a file — GATED, confirm first
删除文件——需确认,执行前先核实
Deletion moves the file to the recycle bin but is still destructive. Show the
user the exact + , get an explicit "yes", then run:
titleurlsh
curl -sS -X DELETE "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID" \
| jq 'if .ret == 0 then "deleted" else . end'删除操作会将文件移至回收站,但仍具有破坏性。务必向用户展示准确的 + ,获取明确的“确认”后再执行:
titleurlsh
curl -sS -X DELETE "${AUTH[@]}" \
"https://docs.qq.com/openapi/drive/v2/files/FILE_ID" \
| jq 'if .ret == 0 then "deleted" else . end'Notes
注意事项
- Gate writes. Rename / move / delete / copy and any share-permission change act on the user's real files — confirm the exact target before running.
- Extract ids from links. When the user pastes a (or
docs.qq.com/doc/<id>,/sheet/,/slide/,/mind/,/flowchart/,/form/) URL, take the id from the path rather than asking for it./smartsheet/ - Pagination. List / search endpoints return a cursor / marker in
next; pass it back to fetch the next page. Stop when the marker is empty.data - Rate / quota. Free apps get 20,000 API calls/month (超级会员 20,000/day,
Plus 40,000/day). AI-generation features additionally consume 积分 and may
require 超级会员 — a /
400007means the account tier / credits, not a bug in the request.400008 - Full API index. Beyond the recipes above, the Open API also covers smart-table records, form collection, folder CRUD, permissions, and import/export — see the 接口索引.
- 写入操作需确认。重命名/移动/删除/复制以及任何共享权限变更都会作用于用户的真实文件——执行前务必确认目标对象的准确性。
- 从链接中提取ID。当用户粘贴(或
docs.qq.com/doc/<id>、/sheet/、/slide/、/mind/、/flowchart/、/form/)链接时,直接从路径中提取ID,而非向用户索要。/smartsheet/ - 分页处理。列出/搜索接口会在中返回游标/
data标记;将其传回接口以获取下一页数据。当标记为空时停止请求。next - 调用频率/配额。免费应用每月可调用20,000次API(超级会员每日20,000次,Plus会员每日40,000次)。AI生成功能还会消耗积分,且可能需要超级会员权限——返回/
400007表示账户等级/积分不足,而非请求存在错误。400008 - 完整API索引。除上述操作指南外,开放API还涵盖智能表格记录、表单收集、文件夹增删改查、权限管理以及导入/导出等功能——详见接口索引。