企业内部开发
基础
连接微信
办公
会议
会议统计管理
企业内部开发
服务端API
消息接收与发送
智能机器人
API模式机器人文档使用说明
API模式机器人文档使用说明
最后更新:2026/03/11

目录

  • 概述
  • 授权操作
  • 工具介绍
  •       create_doc:新建文档或智能表格
  •       edit_doc_content:编辑文档内容
  •       smartsheet_add_sheet:添加智能表格子表
  •       smartsheet_get_sheet:查询智能表格子表
  •       smartsheet_add_fields:添加智能表格字段
  •       smartsheet_update_fields:更新智能表格字段
  •       smartsheet_get_fields:查询智能表格字段:
  •       smartsheet_add_records:添加智能表格记录
  • 概述

    API模式创建的机器人,已支持由成员授权机器人「文档」使用权限。授权后,机器人可以便捷地新建、写入文档和智能表格,提高办公效率。成员可以让机器人完成报告生成、信息汇集等工作。
    文档创建后,机器人将成为文档的创建者;机器人仅可编辑自己创建的文档。
    目前该能力支持以MCP方式调用。具体能力如下:

    • 新建文档:用于新建文档、智能表格,创建后可获得文档链接
    • 编辑文档内容:支持写入文档内容,支持markdown格式
    • 添加智能表格子表:在智能表格内添加工作表
    • 查询智能表格子表:查询智能表格工作表基本信息
    • 添加智能表格字段:在智能表格的工作表内新增一列或多列字段
    • 更新智能表格字段:更新智能表格字段的标题
    • 查询智能表格字段:查询智能表格字段的标题和类型
    • 添加智能表格记录:在智能表格内新增一行或多行记录

    授权操作

    前置要求:需要创建一个API模式机器人

    授权流程

    1. 入口:工作台-智能机器人-找到对应API模式机器人,点击“编辑”
    2. 在编辑页,点击「可使用权限」
      enter image description here
    3. 点击授权
      enter image description here
    4. 授权成功,当前授权有效期为7天,点击查看使用方式,可复制streamableHTTP URL或者JSON Config
      enter image description here
      若需在openclaw使用,可使用通过企业微信openclaw插件进行使用,具体可见:
      以长连接方式接入OpenClaw

    工具介绍

    create_doc:新建文档或智能表格

    新建成功后返回文档访问链接和 docid(docid 仅在创建时返回,需妥善保存)。注意:创建智能表格(doc_type=10)时,文档会默认包含一个子表,可通过 smartsheet_get_sheet 查询其 sheet_id,无需额外调用 smartsheet_add_sheet。
    WARNING: 创建智能表格后,默认子表自带一个默认字段(标题"文本")。你在添加字段前,必须按以下步骤处理:

    1. 调用 smartsheet_get_fields 获取默认字段的 field_id
    2. 调用 smartsheet_update_fields 将默认字段重命名为你需要的第一个字段
    3. 调用 smartsheet_add_fields 只添加剩余字段,如果跳过步骤1-2直接add_fields,会多出一个无用的默认列

    入参

    {
        "inputSchema": {
            "properties": {
                "doc_type": {
                    "description": "文档类型:3-文档,10-智能表格",
                    "enum": [
                        3,
                        10
                    ],
                    "title": "Doc Type",
                    "type": "integer"
                },
                "doc_name": {
                    "description": "文档名字,最多 255 个字符,超过会被截断",
                    "title": "Doc Name",
                    "type": "string"
                }
            },
            "required": [
                "doc_type",
                "doc_name"
            ],
            "title": "create_docArguments",
            "type": "object"
        }
    }

    edit_doc_content:编辑文档内容

    编辑文档内容。content 参数直接传入 Markdown 原文,例如 "# 标题\n正文内容",不要将 Markdown 文本再用引号包成 JSON 字符串。

    入参

    {
        "inputSchema": {
            "properties": {
                "docid": {
                    "description": "文档 id",
                    "title": "Docid",
                    "type": "string"
                },
                "content": {
                    "description": "覆写的文档内容,直接传入原始 Markdown 文本,不要对内容做额外的 JSON 转义或用引号包裹",
                    "title": "Content",
                    "type": "string"
                },
                "content_type": {
                    "description": "内容类型格式。1:markdown",
                    "enum": [
                        1
                    ],
                    "title": "Content Type",
                    "type": "integer"
                }
            },
            "required": [
                "docid",
                "content",
                "content_type"
            ],
            "title": "edit_doc_contentArguments",
            "type": "object"
        }
    }

    smartsheet_add_sheet:添加智能表格子表

    在指定文档中添加一个空的智能表(子表)。注意:新建的智能表格文档默认已包含一个子表,仅在需要多个子表时才需调用此接口。
    WARNING: 新建的子表自带一个默认字段(标题"智能表列")。你在添加字段前,必须按以下步骤处理:

    1. 调用 smartsheet_get_fields 获取默认字段的 field_id
    2. 调用 smartsheet_update_fields 将默认字段重命名为你需要的第一个字段
    3. 调用 smartsheet_add_fields 只添加剩余字段,如果跳过步骤1-2直接add_fields,表格会多出一个无用的默认列。

    入参

    {
        "inputSchema": {
            "$defs": {
                "SheetProperties": {
                    "description": "智能表属性",
                    "properties": {
                        "title": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "智能表标题",
                            "title": "Title"
                        }
                    },
                    "title": "SheetProperties",
                    "type": "object"
                }
            },
            "properties": {
                "docid": {
                    "description": "文档的 docid",
                    "title": "Docid",
                    "type": "string"
                },
                "properties": {
                    "anyOf": [
                        {
                            "$ref": "#/$defs/SheetProperties"
                        },
                        {
                            "type": "null"
                        }
                    ],
                    "default": null,
                    "description": "智能表属性"
                }
            },
            "required": [
                "docid"
            ],
            "title": "smartsheet_add_sheetArguments",
            "type": "object"
        }
    }

    smartsheet_get_sheet:查询智能表格子表

    查询指定文档中的智能表(子表)信息,返回 sheet_id 列表。
    IMPORTANT: 获取 sheet_id 后,下一步必须调用 smartsheet_get_fields 查看该子表的现有字段。子表默认自带一个文本字段,你需要先用 smartsheet_update_fields 重命名该默认字段,再用 smartsheet_add_fields 添加其余字段。

    入参

    {
        "properties": {
            "docid": {
                "description": "文档的 docid",
                "title": "Docid",
                "type": "string"
            }
        }
    }

    smartsheet_add_fields:添加智能表格字段

    入参

    {
        "inputSchema": {
            "properties": {
                "docid": {
                    "description": "文档的 docid",
                    "title": "Docid",
                    "type": "string"
                },
                "sheet_id": {
                    "description": "子表的 sheet ID",
                    "title": "Sheet Id",
                    "type": "string"
                },
                "fields": {
                    "description": "要添加的字段列表",
                    "items": {
                        "properties": {
                            "field_title": {
                                "description": "字段标题",
                                "type": "string"
                            },
                            "field_type": {
                                "description": "字段类型。FIELD_TYPE_TEXT: 文本(适用于名称、标题、描述、负责人姓名等自由文本), FIELD_TYPE_NUMBER: 数字(适用于金额、工时、数量等数值), FIELD_TYPE_CHECKBOX: 复选框, FIELD_TYPE_DATE_TIME: 日期时间, FIELD_TYPE_IMAGE: 图片, FIELD_TYPE_USER: 用户/成员(需要传入 user_id,仅在明确知道成员ID时使用;如果用户只提供了姓名,应使用 TEXT 类型代替), FIELD_TYPE_URL: 链接, FIELD_TYPE_SELECT: 多选, FIELD_TYPE_PROGRESS: 进度(适用于完成进度、完成百分比,值为 0-100 的整数), FIELD_TYPE_PHONE_NUMBER: 手机号, FIELD_TYPE_EMAIL: 邮箱, FIELD_TYPE_SINGLE_SELECT: 单选(适用于状态、优先级、严重程度、分类等有固定选项的字段), FIELD_TYPE_LOCATION: 位置, FIELD_TYPE_CURRENCY: 货币, FIELD_TYPE_PERCENTAGE: 百分比(适用于比率类数值,如完成率、转化率), FIELD_TYPE_BARCODE: 条码",
                                "enum": [
                                    "FIELD_TYPE_TEXT",
                                    "FIELD_TYPE_NUMBER",
                                    "FIELD_TYPE_CHECKBOX",
                                    "FIELD_TYPE_DATE_TIME",
                                    "FIELD_TYPE_IMAGE",
                                    "FIELD_TYPE_USER",
                                    "FIELD_TYPE_URL",
                                    "FIELD_TYPE_SELECT",
                                    "FIELD_TYPE_PROGRESS",
                                    "FIELD_TYPE_PHONE_NUMBER",
                                    "FIELD_TYPE_EMAIL",
                                    "FIELD_TYPE_SINGLE_SELECT",
                                    "FIELD_TYPE_LOCATION",
                                    "FIELD_TYPE_CURRENCY",
                                    "FIELD_TYPE_PERCENTAGE",
                                    "FIELD_TYPE_BARCODE"
                                ],
                                "type": "string"
                            }
                        },
                        "required": [
                            "field_title",
                            "field_type"
                        ],
                        "type": "object"
                    },
                    "title": "Fields",
                    "type": "array"
                }
            },
            "required": [
                "docid",
                "sheet_id",
                "fields"
            ],
            "title": "smartsheet_add_fieldsArguments",
            "type": "object"
        }
    }

    smartsheet_update_fields:更新智能表格字段

    更新企业微信智能表格子表中一个或多个字段的标题。注意:该接口只能更新字段名,不能更新字段类型(field_type 必须为字段当前的原始类型)。field_title 不能被更新为原值。
    入参

    {
        "inputSchema": {
            "properties": {
                "docid": {
                    "description": "文档的 docid",
                    "title": "Docid",
                    "type": "string"
                },
                "sheet_id": {
                    "description": "子表的 sheet ID",
                    "title": "Sheet Id",
                    "type": "string"
                },
                "fields": {
                    "description": "要更新的字段列表",
                    "items": {
                        "properties": {
                            "field_id": {
                                "description": "字段 ID,用于标识要更新的字段,不可更改",
                                "type": "string"
                            },
                            "field_title": {
                                "description": "需要更新为的字段标题,不能更新为原值。",
                                "type": "string"
                            },
                            "field_type": {
                                "description": "字段类型,必须传该字段当前的原始类型,不能更改。FIELD_TYPE_TEXT: 文本, FIELD_TYPE_NUMBER: 数字, FIELD_TYPE_CHECKBOX: 复选框, FIELD_TYPE_DATE_TIME: 日期时间, FIELD_TYPE_IMAGE: 图片, FIELD_TYPE_USER: 用户/成员(需要传入 user_id), FIELD_TYPE_URL: 链接, FIELD_TYPE_SELECT: 多选, FIELD_TYPE_PROGRESS: 进度, FIELD_TYPE_PHONE_NUMBER: 手机号, FIELD_TYPE_EMAIL: 邮箱, FIELD_TYPE_SINGLE_SELECT: 单选, FIELD_TYPE_LOCATION: 位置, FIELD_TYPE_CURRENCY: 货币, FIELD_TYPE_PERCENTAGE: 百分比, FIELD_TYPE_BARCODE: 条码",
                                "enum": [
                                    "FIELD_TYPE_TEXT",
                                    "FIELD_TYPE_NUMBER",
                                    "FIELD_TYPE_CHECKBOX",
                                    "FIELD_TYPE_DATE_TIME",
                                    "FIELD_TYPE_IMAGE",
                                    "FIELD_TYPE_USER",
                                    "FIELD_TYPE_URL",
                                    "FIELD_TYPE_SELECT",
                                    "FIELD_TYPE_PROGRESS",
                                    "FIELD_TYPE_PHONE_NUMBER",
                                    "FIELD_TYPE_EMAIL",
                                    "FIELD_TYPE_SINGLE_SELECT",
                                    "FIELD_TYPE_LOCATION",
                                    "FIELD_TYPE_CURRENCY",
                                    "FIELD_TYPE_PERCENTAGE",
                                    "FIELD_TYPE_BARCODE"
                                ],
                                "type": "string"
                            }
                        },
                        "required": [
                            "field_id",
                            "field_type"
                        ],
                        "type": "object"
                    },
                    "title": "Fields",
                    "type": "array"
                }
            },
            "required": [
                "docid",
                "sheet_id",
                "fields"
            ],
            "title": "smartsheet_update_fieldsArguments",
            "type": "object"
        }
    }

    smartsheet_get_fields:查询智能表格字段:

    {
        "inputSchema": {
            "properties": {
                "docid": {
                    "description": "文档的 docid",
                    "title": "Docid",
                    "type": "string"
                },
                "sheet_id": {
                    "description": "子表的 sheet ID",
                    "title": "Sheet Id",
                    "type": "string"
                }
            },
            "required": [
                "docid",
                "sheet_id"
            ],
            "title": "smartsheet_get_fieldsArguments",
            "type": "object"
        }
    }

    smartsheet_add_records:添加智能表格记录

    在企业微信智能表格的某个子表里添加一行或多行新记录。在调用该工具前,你要先了解目标表的各列的类型。你可能需要重点关注在查询字段工具返回的field_type,对于添加记录中的一些复杂嵌套字段,比如Option,你需要注意查询中返回的 id 的匹配。单次添加记录建议在 500 行内。

    入参

    {
        "inputSchema": {
            "properties": {
                "AddRecord": {
                    "description": "单条待添加的记录(AddRecord)",
                    "properties": {
                        "values": {
                            "additionalProperties": {
                                "anyOf": [
                                    {
                                        "items": {
                                            "$ref": "#/$defs/CellTextValue"
                                        },
                                        "type": "array"
                                    },
                                    {
                                        "type": "number"
                                    },
                                    {
                                        "type": "boolean"
                                    },
                                    {
                                        "type": "string"
                                    },
                                    {
                                        "items": {
                                            "$ref": "#/$defs/CellImageValue"
                                        },
                                        "type": "array"
                                    },
                                    {
                                        "items": {
                                            "$ref": "#/$defs/CellUserValue"
                                        },
                                        "type": "array"
                                    },
                                    {
                                        "items": {
                                            "$ref": "#/$defs/CellUrlValue"
                                        },
                                        "type": "array"
                                    },
                                    {
                                        "items": {
                                            "$ref": "#/$defs/Option"
                                        },
                                        "type": "array"
                                    },
                                    {
                                        "items": {
                                            "$ref": "#/$defs/CellLocationValue"
                                        },
                                        "type": "array"
                                    }
                                ]
                            },
                            "description": "记录的具体内容。【重要】key 必须是字段标题(field_title),不能使用字段ID(field_id),否则会报错。各字段类型的值格式说明:1. 文本(TEXT):必须使用数组格式 [{\"type\":\"text\", \"text\":\"内容\"}],注意外层方括号不可省略,不能传单个对象 {\"type\":\"text\",\"text\":\"内容\"};2. 数字(NUMBER)/货币(CURRENCY)/百分比(PERCENTAGE)/进度(PROGRESS):直接传数字,例如 100、0.6;3. 复选框(CHECKBOX):直接传 true/false;4. 单选(SINGLE_SELECT)/多选(SELECT):必须使用数组格式 [{\"text\":\"选项内容\"}],不能直接传字符串;5. 日期时间(DATE_TIME):传日期时间字符串,支持格式:\"YYYY-MM-DD HH:MM:SS\"(精确到秒)、\"YYYY-MM-DD HH:MM\"(精确到分)、\"YYYY-MM-DD\"(精确到天),例如 \"2026-01-15 14:30:00\" 或 \"2026-01-15\"。系统会自动按东八区转换为时间戳,无需手动计算;6. 手机号(PHONE_NUMBER)/邮箱(EMAIL)/条码(BARCODE):直接传字符串,例如 \"13800138000\";7. 成员(USER):数组格式 [{\"user_id\":\"成员ID\"}];8. 超链接(URL):数组格式 [{\"type\":\"url\", \"text\":\"显示文本\", \"link\":\"https://...\"}];9. 图片(IMAGE):数组格式 [{\"image_url\":\"图片链接\"}];10. 地理位置(LOCATION):数组格式 [{\"source_type\":1, \"id\":\"地点ID\", \"latitude\":\"纬度\", \"longitude\":\"经度\", \"title\":\"地点名\"}]",
                            "title": "Values",
                            "type": "object"
                        }
                    },
                    "required": [
                        "values"
                    ],
                    "title": "AddRecord",
                    "type": "object"
                },
                "CellImageValue": {
                    "description": "图片类型字段的单元值",
                    "properties": {
                        "id": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "图片 ID,自定义 id",
                            "title": "Id"
                        },
                        "title": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "图片标题",
                            "title": "Title"
                        },
                        "image_url": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "图片链接,通过上传图片接口获取",
                            "title": "Image Url"
                        },
                        "width": {
                            "anyOf": [
                                {
                                    "type": "integer"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "图片宽度",
                            "title": "Width"
                        },
                        "height": {
                            "anyOf": [
                                {
                                    "type": "integer"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "图片高度",
                            "title": "Height"
                        }
                    },
                    "title": "CellImageValue",
                    "type": "object"
                },
                "CellLocationValue": {
                    "description": "地理位置类型字段的单元值",
                    "properties": {
                        "source_type": {
                            "const": 1,
                            "description": "来源类型,填 1 表示来源为腾讯地图,目前只支持腾讯地图来源",
                            "title": "Source Type",
                            "type": "integer"
                        },
                        "id": {
                            "description": "地点 ID",
                            "title": "Id",
                            "type": "string"
                        },
                        "latitude": {
                            "description": "纬度",
                            "title": "Latitude",
                            "type": "string"
                        },
                        "longitude": {
                            "description": "经度",
                            "title": "Longitude",
                            "type": "string"
                        },
                        "title": {
                            "description": "地点名称",
                            "title": "Title",
                            "type": "string"
                        }
                    },
                    "required": [
                        "source_type",
                        "id",
                        "latitude",
                        "longitude",
                        "title"
                    ],
                    "title": "CellLocationValue",
                    "type": "object"
                },
                "CellTextValue": {
                    "description": "文本类型字段的单元值",
                    "properties": {
                        "type": {
                            "description": "内容类型,text 为文本,url 为链接",
                            "enum": [
                                "text",
                                "url"
                            ],
                            "title": "Type",
                            "type": "string"
                        },
                        "text": {
                            "description": "单元格文本内容",
                            "title": "Text",
                            "type": "string"
                        },
                        "link": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "当 type 为 url 时,表示链接跳转 URL",
                            "title": "Link"
                        }
                    },
                    "required": [
                        "type",
                        "text"
                    ],
                    "title": "CellTextValue",
                    "type": "object"
                },
                "CellUrlValue": {
                    "description": "超链接类型字段的单元值。数组类型为预留能力,目前只支持展示一个链接,建议只传入一个链接",
                    "properties": {
                        "type": {
                            "const": "url",
                            "description": "固定填 url",
                            "title": "Type",
                            "type": "string"
                        },
                        "text": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "链接显示文本",
                            "title": "Text"
                        },
                        "link": {
                            "description": "链接跳转 URL",
                            "title": "Link",
                            "type": "string"
                        }
                    },
                    "required": [
                        "type",
                        "link"
                    ],
                    "title": "CellUrlValue",
                    "type": "object"
                },
                "CellUserValue": {
                    "description": "成员类型字段的单元值",
                    "properties": {
                        "user_id": {
                            "description": "成员 ID",
                            "title": "User Id",
                            "type": "string"
                        }
                    },
                    "required": [
                        "user_id"
                    ],
                    "title": "CellUserValue",
                    "type": "object"
                },
                "Option": {
                    "description": "选项",
                    "properties": {
                        "id": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "选项 ID,当选项存在时通过 ID 识别选项;需要新增选项时不填写此字段",
                            "title": "Id"
                        },
                        "style": {
                            "anyOf": [
                                {
                                    "maximum": 27,
                                    "minimum": 1,
                                    "type": "integer"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "选项颜色,取值 1-27 对应不同颜色,分别为浅红1, 浅橙1, 浅天蓝1, 浅绿1, 浅紫1, 浅粉红1, 浅灰1, 白, 灰, 浅蓝1, 浅蓝2, 蓝, 浅天蓝2, 天蓝, 浅绿2, 绿, 浅红2, 红, 浅橙2, 橙, 浅黄1, 浅黄2, 黄, 浅紫2, 紫, 浅粉红2, 粉红",
                            "title": "Style"
                        },
                        "text": {
                            "anyOf": [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "null"
                                }
                            ],
                            "default": null,
                            "description": "要填写的选项内容。新增选项时填写,已经存在时优先匹配已存在的选项,否则会新增选项",
                            "title": "Text"
                        }
                    },
                    "title": "Option",
                    "type": "object"
                }
            },
            "properties": {
                "docid": {
                    "description": "文档的 docid",
                    "title": "Docid",
                    "type": "string"
                },
                "sheet_id": {
                    "description": "Smartsheet 子表 ID",
                    "title": "Sheet Id",
                    "type": "string"
                },
                "records": {
                    "description": "需要添加的记录的具体内容组成的 JSON 数组",
                    "items": {
                        "$ref": "#/$defs/AddRecord"
                    },
                    "title": "Records",
                    "type": "array"
                }
            },
            "required": [
                "docid",
                "sheet_id",
                "records"
            ],
            "title": "smartsheet_add_recordsArguments",
            "type": "object"
        }
    }

     

    上一篇智能机器人长连接
    下一篇获取群聊列表
      本节内容
    服务端API
    基础
    连接微信
    办公
    会议
    会议统计管理
    客户端API
    小程序
    基础
    连接微信
    办公
    JS-SDK
    基础
    连接微信
    办公
    消息推送(原“群机器人”)
    更新日志
    联系我们