feishu-task

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

飞书任务管理

Lark Task Management

你是飞书任务自动化专家,负责通过 Task v2 API 实现任务的创建、完成、评论和附件管理。

You are a Lark task automation expert, responsible for implementing task creation, completion, comment and attachment management via the Task v2 API.

一、API 基础信息

1. API Basic Information

项目
Base URL
https://open.feishu.cn/open-apis/task/v2
认证方式
Authorization: Bearer {tenant_access_token}
Content-Type
application/json

ItemValue
Base URL
https://open.feishu.cn/open-apis/task/v2
Authentication Method
Authorization: Bearer {tenant_access_token}
Content-Type
application/json

二、任务操作

2. Task Operations

1. 创建任务

1. Create Task

POST /open-apis/task/v2/tasks
json
{
  "summary": "任务标题",
  "description": "任务详细描述",
  "due": {
    "timestamp": "1770508800",
    "is_all_day": false
  },
  "members": [
    { "id": "ou_xxx", "role": "assignee" }
  ],
  "origin": {
    "platform_i18n_name": "{\"zh_cn\": \"AI Agent\"}"
  }
}
实测心法
  • 必须指派执行人(assignee),否则移动端无提醒,用户看不见任务
  • due.timestamp
    13 位毫秒级字符串 (例如 "1770508800000")。注意:如果传成 10 位秒级,任务截止日期会变成 1970 年。
  • origin
    标注任务来源,便于追溯
POST /open-apis/task/v2/tasks
json
{
  "summary": "任务标题",
  "description": "任务详细描述",
  "due": {
    "timestamp": "1770508800",
    "is_all_day": false
  },
  "members": [
    { "id": "ou_xxx", "role": "assignee" }
  ],
  "origin": {
    "platform_i18n_name": "{\"zh_cn\": \"AI Agent\"}"
  }
}
Practical Tips:
  • Must assign an assignee, otherwise there will be no reminder on mobile and users won't see the task
  • due.timestamp
    is a 13-digit millisecond string (e.g., "1770508800000"). Note: If you pass a 10-digit second-level timestamp, the task due date will be set to 1970.
  • origin
    marks the task source for easy traceability

2. 完成任务

2. Complete Task

POST /open-apis/task/v2/tasks/:task_id/complete
实测心法:支持批量完成,提升效率。自动化流程跑完后同步闭环。
POST /open-apis/task/v2/tasks/:task_id/complete
Practical Tips: Supports batch completion to improve efficiency. Close the task synchronously after the automated process is finished.

3. 更新任务

3. Update Task

PATCH /open-apis/task/v2/tasks/:task_id
json
{
  "task": {
    "summary": "更新后的标题"
  },
  "update_fields": ["summary"]
}
实测心法:必须在
update_fields
中指定要更新的字段名。

PATCH /open-apis/task/v2/tasks/:task_id
json
{
  "task": {
    "summary": "更新后的标题"
  },
  "update_fields": ["summary"]
}
Practical Tips: Must specify the field names to update in
update_fields
.

三、任务评论

3. Task Comments

4. 添加任务评论

4. Add Task Comment

POST /open-apis/task/v2/tasks/:task_id/comments
json
{ "content": "已完成审计,结果正常" }
实测心法:支持富文本,可插入链接。用于同步执行过程中的关键日志。

POST /open-apis/task/v2/tasks/:task_id/comments
json
{ "content": "已完成审计,结果正常" }
Practical Tips: Supports rich text and link insertion. Used to synchronize key logs during execution.

四、任务附件

4. Task Attachments

5. 挂载任务附件

5. Attach Task Files

POST /open-apis/task/v2/tasks/:task_id/attachments
json
{ "file_token": "..." }
实测心法:需先通过 Drive 上传接口(
feishu-drive
Skill)获取
file_token
,再关联至任务。

POST /open-apis/task/v2/tasks/:task_id/attachments
json
{ "file_token": "..." }
Practical Tips: You need to obtain the
file_token
via the Drive upload API (the
feishu-drive
Skill) first, then associate it with the task.

五、最佳实践

5. Best Practices

  1. 必须指派:创建任务一定要指定 assignee,否则等于没创建
  2. 来源标注:通过
    origin
    字段标注任务由 AI Agent 创建,便于区分人工和自动化任务
  3. 闭环管理:自动化流程完成后,调用 complete 接口关闭任务
  4. 评论留痕:关键执行节点通过评论记录,形成审计链
  5. 附件关联:报告、设计稿等产出物通过附件挂载到任务上
  1. Must Assign Assignee: Always specify an assignee when creating a task, otherwise it's equivalent to not creating it
  2. Mark Source: Use the
    origin
    field to mark tasks created by AI Agent, making it easy to distinguish between manual and automated tasks
  3. Closed-Loop Management: Call the complete API to close the task after the automated process is completed
  4. Comment for Traceability: Record key execution nodes via comments to form an audit trail
  5. Attachment Association: Attach deliverables such as reports and design drafts to tasks as attachments