wecom-cliis a command-line program provided by WeCom. All operations are performed by executing thewecom-clicommand.
Manage the sub-sheet and field (column) structure of a smart sheet. All interfaces support locating the document by choosing either docid or url .
Invocation method
Invoke through wecom-cli , with category 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, on success it is "ok" |
When errcode is not 0 , it indicates the interface call failed. You may retry once; if it still fails, show errcode and errmsg to the user.
Sub-sheet management
smartsheet_get_sheet
Query information for all sub-sheets in the document, returning sheet_id, title, type, etc.
wecom-cli doc smartsheet_get_sheet '{"docid": "DOCID"}'
smartsheet_add_sheet
Add an empty sub-sheet. The new sub-sheet does not contain views, records, or fields, and must be supplemented through other interfaces.
wecom-cli doc smartsheet_add_sheet '{"docid": "DOCID", "properties": {"title": "新子表"}}'
Note: A newly created smart sheet document already contains one sub-sheet by default. Call this only when multiple sub-sheets are needed.
smartsheet_update_sheet
Modify the sub-sheet title. sheet_id and the new title must be provided.
wecom-cli doc smartsheet_update_sheet '{"docid": "DOCID", "properties":{"sheet_id":"SHEET_ID", "title":"新子表"}}'
smartsheet_delete_sheet
Permanently delete a sub-sheet.The operation is irreversible。
wecom-cli doc smartsheet_delete_sheet '{"docid": "DOCID", "sheet_id": "SHEETID"}'
Field management
smartsheet_get_fields
Query all field information of a sub-sheet, returning field_id, field_title, and field_type.
wecom-cli doc smartsheet_get_fields '{"docid": "DOCID", "sheet_id": "SHEETID"}'
smartsheet_add_fields
Add one or more fields to a sub-sheet. A single sub-sheet can have at most 150 fields.
wecom-cli doc smartsheet_add_fields '{"docid": "DOCID", "sheet_id": "SHEETID", "fields": [{"field_title": "任务名称", "field_type": "FIELD_TYPE_TEXT"}]}'
For supported field types, see Field type reference。
smartsheet_update_fields
Update a field title.Only the name can be changed, not the type(field_type must be passed with the original type). field_title cannot be updated to the original value.
wecom-cli doc smartsheet_update_fields '{"docid": "DOCID", "sheet_id": "SHEETID", "fields": [{"field_id": "FIELDID", "field_title": "新标题", "field_type": "FIELD_TYPE_TEXT"}]}'
smartsheet_delete_fields
Delete one or more columns of fields.The operation is irreversible. field_id can be obtained through smartsheet_get_fields .
wecom-cli doc smartsheet_delete_fields '{"docid": "DOCID", "sheet_id": "SHEETID", "field_ids": ["FIELDID"]}'
Typical workflow
- Understand the table structure →
wecom-cli doc smartsheet_get_sheet '{"docid": "DOCID"}'
→
wecom-cli doc smartsheet_get_fields '{"docid": "DOCID", "sheet_id": "SHEETID"}'
- Create table structure →
smartsheet_add_sheetadd sub-sheet →smartsheet_add_fieldsdefine columns - Modify table structure →
smartsheet_update_fieldschange column name /smartsheet_delete_fieldsdelete column