tencent-docs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tencent Docs (腾讯文档)

Tencent Docs (腾讯文档)

Drive the Tencent Docs Open API with
curl + jq
. 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。所有操作均在用户自己的腾讯文档账户中进行——仅访问用户有权限的文件,仅使用用户在连接时授予的权限范围。

Auth — three headers (NOT a single Bearer)

认证——三个请求头(而非单个Bearer令牌)

The
tencentdocs
BYOC connector injects three env vars; every call sends all three headers:
  • TENCENTDOCS_ACCESS_TOKEN
    Access-Token
    header (OAuth2 access token). Secret.
  • TENCENTDOCS_CLIENT_ID
    Client-Id
    header (the developer app's Client ID).
  • TENCENTDOCS_OPEN_ID
    Open-Id
    header (the user id returned with the token).
All endpoints live under
https://docs.qq.com/openapi
. Define a reusable header set once per session:
sh
AUTH=(-H "Access-Token: $TENCENTDOCS_ACCESS_TOKEN" \
      -H "Client-Id: $TENCENTDOCS_CLIENT_ID" \
      -H "Open-Id: $TENCENTDOCS_OPEN_ID")
Never echo, print, or log
TENCENTDOCS_ACCESS_TOKEN
— it is full account access.
tencentdocs
BYOC连接器会注入三个环境变量;每次调用都需要发送全部三个请求头:
  • TENCENTDOCS_ACCESS_TOKEN
    Access-Token
    请求头(OAuth2访问令牌)。保密信息
  • TENCENTDOCS_CLIENT_ID
    Client-Id
    请求头(开发者应用的客户端ID)。
  • TENCENTDOCS_OPEN_ID
    Open-Id
    请求头(令牌返回的用户ID)。
所有接口端点都位于
https://docs.qq.com/openapi
下。定义一个可复用的请求头集合,每个会话只需设置一次:
sh
AUTH=(-H "Access-Token: $TENCENTDOCS_ACCESS_TOKEN" \
      -H "Client-Id: $TENCENTDOCS_CLIENT_ID" \
      -H "Open-Id: $TENCENTDOCS_OPEN_ID")
切勿回显、打印或记录
TENCENTDOCS_ACCESS_TOKEN
——它拥有账户的完全访问权限。

Response shape & error handling

响应格式与错误处理

Every response is
{"ret": 0, "msg": "Succeed", "data": {…}}
.
ret == 0
means success
; any non-zero
ret
is an error — surface
msg
to the user. Always check it:
sh
resp=$(curl -sS "${AUTH[@]}")
echo "$resp" | jq 'if .ret == 0 then .data else error("Tencent Docs \(.ret): \(.msg)") end'
Common error codes:
codemeaningwhat to do
400006
access token invalid / expiredtell the user to reconnect 腾讯文档 at https://auth.acedata.cloud/user/connections — do not loop-retry
400007
VIP (超级会员) privilege requiredthe requested capability needs a Tencent Docs 超级会员; tell the user, link https://docs.qq.com/vip
400008
积分 (credits) insufficientAI-generation quota is exhausted; tell the user to top up
11607
/
-32603
bad request paramsrecheck
fileID
/
type
/ body fields against the recipe below
每个响应的格式均为
{"ret": 0, "msg": "Succeed", "data": {…}}
ret == 0
表示成功
;任何非零的
ret
值均为错误——需将
msg
内容展示给用户。务必检查该值:
sh
resp=$(curl -sS "${AUTH[@]}")
echo "$resp" | jq 'if .ret == 0 then .data else error("Tencent Docs \(.ret): \(.msg)") end'
常见错误码:
错误码含义处理方式
400006
访问令牌无效/过期告知用户前往https://auth.acedata.cloud/user/connections重新连接腾讯文档——请勿循环重试
400007
需要超级会员权限请求的功能需要腾讯文档超级会员;告知用户并链接至https://docs.qq.com/vip
400008
积分不足AI生成配额已耗尽;告知用户进行充值
11607
/
-32603
请求参数错误根据下方的操作指南重新检查
fileID
/
type
/请求体字段

Doc types (
type
when creating)

文档类型(创建时的
type
参数)

typeProductNotes
doc
在线文档 (Word-style)classic rich-text document
sheet
在线表格 (Excel)data tables
slide
幻灯片 (PPT)presentations
mind
思维导图mind map
flowchart
流程图flowchart
smartsheet
智能表格structured multi-view table
form
收集表form / survey
类型值产品说明
doc
在线文档(类Word)经典富文本文档
sheet
在线表格(类Excel)数据表格
slide
幻灯片(类PPT)演示文稿
mind
思维导图思维导图
flowchart
流程图流程图
smartsheet
智能表格结构化多视图表格
form
收集表表单/调查问卷

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
400006
, the connection is expired — have the user reconnect.
简单的完整性检查——读取应用的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'
如果返回
400006
,则连接已过期——请用户重新连接。

List 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'
%2F
is the URL-encoded root folder id. For a sub-folder use its folder id in the path.
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'
%2F
是URL编码后的根目录ID。对于子文件夹,请在路径中使用其文件夹ID。

Search 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
fileID
is the last path segment of a
https://docs.qq.com/doc/<id>
(or
/sheet/
,
/slide/
, …) URL.
sh
curl -sS "${AUTH[@]}" \
  "https://docs.qq.com/openapi/drive/v2/files/FILE_ID/metadata" \
  | jq 'if .ret == 0 then .data else . end'
fileID
https://docs.qq.com/doc/<id>
(或
/sheet/
/slide/
等)URL路径的最后一段。
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
sheetId
list from the metadata first, then read a range (
A1:D10
):
sh
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'
首先从元数据中获取表格的
sheetId
列表,然后读取指定区域(如
A1:D10
):
sh
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/files
with form-urlencoded
title
+
type
. Returns the new file's
ID
and
url
.
sh
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
type=sheet
/
slide
/
mind
/
flowchart
/
smartsheet
/
form
for other doc types. Pass
--data-urlencode "folderID=<id>"
to create inside a folder instead of the root.
POST /openapi/drive/v2/files
发送表单编码的
title
+
type
参数。返回新文件的
ID
url
sh
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=sheet
/
slide
/
mind
/
flowchart
/
smartsheet
/
form
替换为其他文档类型。添加
--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
title
+
url
and the new title, get an explicit "yes", then run:
sh
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'
向用户展示当前文件的
title
+
url
以及新标题,获取明确的“确认”后再执行:
sh
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
title
+ location and the destination folder, get an explicit "yes", then run.
folderID=/
moves it back to the root.
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'
向用户展示文件当前的
title
+ 位置以及目标文件夹,获取明确的“确认”后再执行。
folderID=/
表示将文件移回根目录。
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
title
+
url
, get an explicit "yes", then run:
sh
curl -sS -X DELETE "${AUTH[@]}" \
  "https://docs.qq.com/openapi/drive/v2/files/FILE_ID" \
  | jq 'if .ret == 0 then "deleted" else . end'
删除操作会将文件移至回收站,但仍具有破坏性。务必向用户展示准确的
title
+
url
,获取明确的“确认”后再执行:
sh
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
    docs.qq.com/doc/<id>
    (or
    /sheet/
    ,
    /slide/
    ,
    /mind/
    ,
    /flowchart/
    ,
    /form/
    ,
    /smartsheet/
    ) URL, take the id from the path rather than asking for it.
  • Pagination. List / search endpoints return a cursor /
    next
    marker in
    data
    ; pass it back to fetch the next page. Stop when the marker is empty.
  • 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
    400007
    /
    400008
    means the account tier / credits, not a bug in the request.
  • 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/
    /smartsheet/
    )链接时,直接从路径中提取ID,而非向用户索要。
  • 分页处理。列出/搜索接口会在
    data
    中返回游标/
    next
    标记;将其传回接口以获取下一页数据。当标记为空时停止请求。
  • 调用频率/配额。免费应用每月可调用20,000次API(超级会员每日20,000次,Plus会员每日40,000次)。AI生成功能还会消耗积分,且可能需要超级会员权限——返回
    400007
    /
    400008
    表示账户等级/积分不足,而非请求存在错误。
  • 完整API索引。除上述操作指南外,开放API还涵盖智能表格记录、表单收集、文件夹增删改查、权限管理以及导入/导出等功能——详见接口索引