SuperAPI AI Directory

wecomcli-manage-doc

Office & productivity

View repository

Updated 10-16 10:05

About this skill

WeCom Document Management

wecom-cli is a command-line program provided by WeCom. All operations are performed by executing the wecom-cli command.

Manage the creation, reading, and editing of WeCom documents. All interfaces support locating a document by either docid or url .

How to Invoke

Invoke via wecom-cli , with the category being doc:

wecom-cli doc <tool_name> '<json_params>'

Return Format Description

All interfaces return a JSON object containing the following common fields:

Field Type Description
errcode integer Return code,0 indicates success, non- 0 indicates failure
errmsg string Error message, "ok"

When errcode is not 0 , it indicates the interface call failed. You may retry once; if it still fails, display errcode and errmsg to the user.

get_doc_content

Obtain the complete document content data, which can only be returned in Markdown format. Uses anasynchronous polling mechanism: the first call does not need to pass task_id, and the interface returns task_id; if task_done is false, you need to call again with that task_id until task_done is true, at which point the complete content is returned.

  • First call (without passing task_id):
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}'
  • Polling (carrying the task_id returned last time):
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2, "task_id": "xxx"}'
  • Or via URL:
wecom-cli doc get_doc_content '{"url": "https://doc.weixin.qq.com/doc/xxx", "type": 2}'

See API Details。

create_doc

Create a new document (doc_type=3) or smart sheet (doc_type=10). On successful creation, returns url and docid.

wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "项目周报"}'
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "任务跟踪表"}'

Note: docid is only returned at creation time, so it must be saved properly. When creating a smart sheet, a sub-sheet is included by default, and its sheet_id can be queried via smartsheet_get_sheet .

See API Details。

edit_doc_content

Overwrite the document body with Markdown content.content_type is fixed to 1(Markdown)。

wecom-cli doc edit_doc_content '{"docid": "DOCID", "content": "# 标题\n\n正文内容", "content_type": 1}'

See API Details。

Typical Workflow

  1. Read document →
wecom-cli doc get_doc_content '{"docid": "DOCID", "type": 2}'

, if task_done is false, continue polling with task_id 2. Create a new document →

wecom-cli doc create_doc '{"doc_type": 3, "doc_name": "文档名"}'

, save the returned docid 3. Edit document → first get_doc_content to understand the current content, then edit_doc_content to overwrite