ogenes

DingTalk API

Developmentv1.4.0
By ogenesUpdated 2026-05-1811 versions · latest released 2026-02-23dingtalk-api@clawhub_ogenes/dingtalk-api
Scripting#消息#钉钉

According to AlphaMoat, as of 2026-10, DingTalk API has 8,760 downloads and 9 stars — ranked by downloads #3,171 among 10,914 AI skills in this ranking, and #253 of 1,069 in Development.

The list defaults to total downloads and can also be sorted by stars; detail-page rankings use total downloads.

Downloads
8.8K
Stars
9
Overall download rank
#3,171
Top 30% overall · Top 24% in Development
PlatformDownloadsStarsComments
ClawHub ↗5.3K8-
SkillHub ↗8.8K9—

Platforms count differently and update at different times.

What this skill does

It searches users and departments, reads details and sub-departments, sends robot messages to a person or a group, lists group bots and resignation records, and handles OA approval queries, submission, approval, transfer and comments. DINGTALK_APP_KEY and DINGTALK_APP_SECRET must be set first.

Profile published 2026-10-27

What you can do with it

  • Message everyone under a department through a robot
  • Check resignation records for a period

When to use it

  • When DingTalk people and department data is queried
  • When an approval flow has to be driven

Example prompts

Generated from the skill’s documentation as examples; not results of actual runs.

List the people under this department
Send a robot notice to this group

Monthly Trend

Downloads8.8K
2.9K6.0K9.2K2026-03 · Downloads 3.3K2026-05 · Downloads 4.2K2026-06 · Downloads 4.5K2026-07 · Downloads 4.8K2026-08 · Downloads 5.0K2026-09 · Downloads 5.7K2026-10 · Downloads 8.8K26-0326-0926-10
Stars9
8992026-03 · Stars 82026-05 · Stars 82026-06 · Stars 92026-07 · Stars 92026-08 · Stars 92026-09 · Stars 92026-10 · Stars 926-0326-0926-10

The counting method changed in 2026-09: skills with the same name are now counted separately by author, and the full catalog is covered. Dashed lines show months before the change; they are not compared with later months, and no growth is computed across the change.

MonthDownloadsMoMStars
2026-108.8K—9
2026-095.7K—9
2026-085.0K+5.3%9
2026-074.8K+6.3%9
2026-064.5K+6.2%9
2026-054.2K—8
2026-033.3K—8

SKILL.md (original)

The author’s original file, shown as plain text without edits or review by AlphaMoat. Links are not clickable; check commands before running them. Fetched 2026-10-23.

13 KB · ClawHub v1.4.0
---
name: dingtalk-api
description: 调用钉钉开放平台API,支持用户搜索/详情/查询、部门管理(搜索/详情/子部门/用户列表/父部门)、机器人单聊消息发送、群聊消息发送、群内机器人列表查询、离职记录查询。Use when needing to search DingTalk users or departments, get user/department details, send robot messages, list group bots, or query resigned employees.
---

# DingTalk API Skill

用于调用钉钉开放平台 API 的技能,支持用户搜索/详情/查询、部门管理(搜索/详情/子部门/用户列表/父部门)、机器人消息发送、群内机器人查询、离职记录查询、OA审批管理(查询/发起/审批/转交/评论)等功能。

## 前置要求
Show all (645 lines)

- 已设置环境变量 `DINGTALK_APP_KEY` 和 `DINGTALK_APP_SECRET`
- 钉钉应用已创建并拥有相应 API 权限

## 环境变量配置

```bash
export DINGTALK_APP_KEY="<your-app-key>"
export DINGTALK_APP_SECRET="<your-app-secret>"
```

## 功能列表

### 1. 搜索用户 (search-user)

根据姓名搜索用户,返回匹配的 UserId 列表。

```bash
npx ts-node scripts/search-user.ts "<搜索关键词>"
```

输出:

```json
{
  "success": true,
  "keyword": "张三",
  "totalCount": 3,
  "hasMore": false,
  "userIds": ["123456789", "987654321"]
}
```

### 2. 搜索部门 (search-department)

根据名称搜索部门,返回匹配的部门 ID 列表。

```bash
npx ts-node scripts/search-department.ts "<搜索关键词>" [--debug]
```

输出:

```json
{
  "success": true,
  "keyword": "技术部",
  "totalCount": 2,
  "hasMore": false,
  "departmentIds": [12345, 67890]
}
```

### 3. 获取部门详情 (get-department)

获取指定部门的详细信息。

```bash
npx ts-node scripts/get-department.ts <deptId> [--debug]
```

输出:

```json
{
  "success": true,
  "department": {
    "deptId": 12345,
    "name": "技术部",
    "parentId": 1
  }
}
```

### 4. 获取子部门列表 (list-sub-departments)

获取指定部门下的子部门 ID 列表。根部门 deptId 为 1。

```bash
npx ts-node scripts/list-sub-departments.ts <deptId> [--debug]
```

输出:

```json
{
  "success": true,
  "deptId": 1,
  "subDepartmentIds": [12345, 67890, 11111]
}
```

### 5. 获取部门用户列表 (list-department-users)

获取指定部门下的用户列表(userId + 姓名),自动分页获取全部用户。

```bash
npx ts-node scripts/list-department-users.ts <deptId> [--debug]
```

输出:

```json
{
  "success": true,
  "deptId": 12345,
  "users": [
    { "userId": "user001", "name": "张三" },
    { "userId": "user002", "name": "李四" }
  ]
}
```

### 6. 发送单聊消息 (send-user-message)

通过机器人向指定用户发送单聊消息。

```bash
npx ts-node scripts/send-user-message.ts "<userId>" "<robotCode>" "<消息内容>" [--debug]
```

输出:

```json
{
  "success": true,
  "userId": "123456",
  "robotCode": "robot_code",
  "processQueryKey": "query_key",
  "flowControlledStaffIdList": [],
  "invalidStaffIdList": [],
  "message": "消息内容"
}
```

### 7. 发送群聊消息 (send-group-message)

通过机器人向指定群会话发送消息。

```bash
npx ts-node scripts/send-group-message.ts "<openConversationId>" "<robotCode>" "<消息内容>" [--debug]
```

输出:

```json
{
  "success": true,
  "openConversationId": "cid",
  "robotCode": "robot_code",
  "processQueryKey": "query_key",
  "message": "消息内容"
}
```

### 8. 获取群内机器人列表 (get-bot-list)

查询群内已配置的机器人列表。

```bash
npx ts-node scripts/get-bot-list.ts "<openConversationId>" [--debug]
```

输出:

```json
{
  "success": true,
  "openConversationId": "cid",
  "botList": [
    {
      "robotCode": "code",
      "robotName": "name",
      "robotAvatar": "url",
      "openRobotType": 1
    }
  ]
}
```

### 9. 查询用户详情 (get-user)

获取指定用户的详细信息,包括姓名、手机号、邮箱、部门列表等。

```bash
npx ts-node scripts/get-user.ts "<userId>" [--debug]
```

输出:

```json
{
  "success": true,
  "user": {
    "userid": "user001",
    "name": "张三",
    "mobile": "138****1234",
    "email": "[email protected]",
    "dept_id_list": [12345, 67890]
  }
}
```

### 10. 获取用户父部门列表 (list-user-parent-departments)

获取指定用户所属的所有父部门列表,从直接部门到根部门。

```bash
npx ts-node scripts/list-user-parent-departments.ts "<userId>" [--debug]
```

输出:

```json
{
  "success": true,
  "userId": "user001",
  "parentIdList": [12345, 67890, 1]
}
```

### 11. 获取部门父部门列表 (list-department-parents)

获取指定部门的所有父部门列表,第一个是自身,最后一个是根部门。

```bash
npx ts-node scripts/list-department-parents.ts <deptId> [--debug]
```

输出:

```json
{
  "success": true,
  "deptId": 12345,
  "parentIdList": [12345, 67890, 1]
}
```

### 12. 获取部门用户ID列表 (list-department-user-ids)

获取指定部门下所有用户的 userid 列表。

```bash
npx ts-node scripts/list-department-user-ids.ts <deptId> [--debug]
```

输出:

```json
{
  "success": true,
  "deptId": 12345,
  "userIds": ["user001", "user002", "user003"]
}
```

### 13. 获取部门用户详情分页版 (list-department-user-details)

分页获取部门用户详细信息,支持自定义 cursor 和 size。

```bash
npx ts-node scripts/list-department-user-details.ts <deptId> [--cursor <cursor>] [--size <size>] [--debug]
```

输出:

```json
{
  "success": true,
  "deptId": 12345,
  "users": [
    { "userid": "user001", "name": "张三" },
    { "userid": "user002", "name": "李四" }
  ],
  "hasMore": true,
  "nextCursor": 100
}
```

### 14. 获取员工人数 (get-user-count)

获取企业员工总数,可选择是否仅统计已激活员工。

```bash
npx ts-node scripts/get-user-count.ts [--onlyActive] [--debug]
```

输出:

```json
{
  "success": true,
  "onlyActive": false,
  "count": 150
}
```

### 15. 根据手机号查询用户 (get-user-by-mobile)

根据手机号查询用户 userid。仅企业内部应用可用,只能查询在职员工。

```bash
npx ts-node scripts/get-user-by-mobile.ts "<mobile>" [--debug]
```

输出:

```json
{
  "success": true,
  "mobile": "13800138000",
  "userId": "user001"
}
```

### 16. 根据 unionid 查询用户 (get-user-by-unionid)

根据 unionid 获取用户 userid。

```bash
npx ts-node scripts/get-user-by-unionid.ts "<unionid>" [--debug]
```

输出:

```json
{
  "success": true,
  "unionid": "xxxxx",
  "userId": "user001"
}
```

### 17. 获取未登录用户列表 (list-inactive-users)

获取指定日期未登录钉钉的员工列表。只能查询一个月内数据,每天9点后调用才能确保获取前一天数据。

```bash
npx ts-node scripts/list-inactive-users.ts "<queryDate>" [--deptIds "id1,id2"] [--offset <offset>] [--size <size>] [--debug]
```

输出:

```json
{
  "success": true,
  "queryDate": "20240115",
  "userIds": ["user001", "user002"],
  "hasMore": false
}
```

### 18. 查询离职记录列表 (list-resigned-users)

查询指定时间范围内的离职员工记录。仅企业内部应用可用。

```bash
npx ts-node scripts/list-resigned-users.ts "<startTime>" ["<endTime>"] [--nextToken <token>] [--maxResults <max>] [--debug]
```

输出:

```json
{
  "success": true,
  "startTime": "2024-01-01T00:00:00+08:00",
  "endTime": "2024-02-01T00:00:00+08:00",
  "records": [
    {
      "userId": "user001",
      "name": "张三",
      "leaveTime": "2024-01-15T10:00:00Z",
      "leaveReason": "个人原因"
    }
  ]
}
```

### 19. 获取审批实例 ID 列表 (list-approval-instance-ids)

获取指定审批模板在时间段内的审批实例 ID 列表。

```bash
npx ts-node scripts/list-approval-instance-ids.ts <processCode> --startTime <timestamp> --endTime <timestamp> [--size <size>] [--nextToken <token>] [--debug]
```

输出:

```json
{
  "success": true,
  "processCode": "PROC-XXX",
  "instanceIds": ["xxx-123", "xxx-456"],
  "totalCount": 2,
  "hasMore": false,
  "nextToken": null
}
```

### 20. 获取审批实例详情 (get-approval-instance)

获取单个审批实例的详细信息,包括表单数据、审批记录、任务列表等。

```bash
npx ts-node scripts/get-approval-instance.ts <instanceId> [--debug]
```

输出:

```json
{
  "success": true,
  "instanceId": "xxx-123",
  "instance": {
    "processInstanceId": "xxx-123",
    "title": "请假申请",
    "createTimeGMT": "2024-01-01T00:00:00Z",
    "finishTimeGMT": "2024-01-01T12:00:00Z",
    "originatorUserId": "user001",
    "originatorDeptId": "1",
    "status": "COMPLETED",
    "processCode": "PROC-XXX",
    "formComponentValues": [...],
    "operationRecords": [...],
    "tasks": [...]
  }
}
```

### 21. 获取用户发起审批列表 (list-user-initiated-approvals)

获取用户发起的审批实例列表。

```bash
npx ts-node scripts/list-user-initiated-approvals.ts <userId> [--startTime <timestamp>] [--endTime <timestamp>] [--maxResults <max>] [--nextToken <token>] [--debug]
```

输出:

```json
{
  "success": true,
  "userId": "user001",
  "instances": [...],
  "totalCount": 5,
  "hasMore": false,
  "nextToken": null
}
```

### 22. 获取抄送用户审批列表 (list-user-cc-approvals)

获取抄送给用户的审批实例列表。

```bash
npx ts-node scripts/list-user-cc-approvals.ts <userId> [--startTime <timestamp>] [--endTime <timestamp>] [--maxResults <max>] [--nextToken <token>] [--debug]
```

### 23. 获取待处理审批列表 (list-user-todo-approvals)

获取用户待处理的审批任务列表。

```bash
npx ts-node scripts/list-user-todo-approvals.ts <userId> [--maxResults <max>] [--nextToken <token>] [--debug]
```

输出:

```json
{
  "success": true,
  "userId": "user001",
  "instances": [...],
  "totalCount": 3,
  "hasMore": false,
  "nextToken": null
}
```

### 24. 获取已处理审批列表 (list-user-done-approvals)

获取用户已处理的审批实例列表。

```bash
npx ts-node scripts/list-user-done-approvals.ts <userId> [--startTime <timestamp>] [--endTime <timestamp>] [--maxResults <max>] [--nextToken <token>] [--debug]
```

### 25. 获取待审批数量 (get-user-todo-count)

获取用户待审批任务数量。

```bash
npx ts-node scripts/get-user-todo-count.ts <userId> [--debug]
```

输出:

```json
{
  "success": true,
  "userId": "user001",
  "count": 5
}
```

### 26. 发起审批实例 (create-approval-instance)

创建新的审批实例。

```bash
npx ts-node scripts/create-approval-instance.ts <processCode> <originatorUserId> <deptId> '<formValuesJson>' [--ccList "user1,user2"] [--debug]
```

示例:

```bash
npx ts-node scripts/create-approval-instance.ts "PROC-XXX" "user001" "1" '[{"name":"标题","value":"请假申请"},{"name":"请假天数","value":"3"}]'
```

输出:

```json
{
  "success": true,
  "processCode": "PROC-XXX",
  "originatorUserId": "user001",
  "instanceId": "xxx-new"
}
```

### 27. 终止审批实例 (terminate-approval-instance)

撤销/终止指定的审批实例。

```bash
npx ts-node scripts/terminate-approval-instance.ts <instanceId> <operatingUserId> [--remark "撤销原因"] [--debug]
```

输出:

```json
{
  "success": true,
  "instanceId": "xxx-123",
  "message": "审批实例已终止"
}
```

### 28. 执行审批任务 (execute-approval-task)

同意或拒绝审批任务。

```bash
npx ts-node scripts/execute-approval-task.ts <instanceId> <userId> <agree|refuse> [--taskId <taskId>] [--remark "审批意见"] [--debug]
```

示例:

```bash
npx ts-node scripts/execute-approval-task.ts "xxx-123" "user001" "agree" --remark "同意申请"
npx ts-node scripts/execute-approval-task.ts "xxx-123" "user001" "refuse" --remark "条件不符"
```

输出:

```json
{
  "success": true,
  "instanceId": "xxx-123",
  "userId": "user001",
  "action": "agree",
  "message": "已同意审批"
}
```

### 29. 转交审批任务 (transfer-approval-task)

将审批任务转交给其他用户处理。

```bash
npx ts-node scripts/transfer-approval-task.ts <instanceId> <userId> <transferToUserId> [--taskId <taskId>] [--remark "转交原因"] [--debug]
```

输出:

```json
{
  "success": true,
  "instanceId": "xxx-123",
  "userId": "user001",
  "transferToUserId": "user002",
  "message": "审批任务已转交"
}
```

### 30. 添加审批评论 (add-approval-comment)

为审批实例添加评论。

```bash
npx ts-node scripts/add-approval-comment.ts <instanceId> <userId> "<comment>" [--debug]
```

输出:

```json
{
  "success": true,
  "instanceId": "xxx-123",
  "userId": "user001",
  "message": "评论已添加"
}
```

## 错误处理

所有脚本在错误时返回统一格式:

```json
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "错误描述"
  }
}
```

常见错误码:
- `MISSING_CREDENTIALS` - 未设置环境变量
- `INVALID_ARGUMENTS` - 参数不足
- `AUTH_FAILED` - access_token 获取失败
- `UNKNOWN_ERROR` - API 调用异常

Popular in Development

编程大神.SkillDevelopment

【全栈能力】编程大神.Skill:面向复杂真实项目的高阶全栈编程助手。不止生成代码,而是从一句目标接手陌生代码库,拆解需求、补齐实现、追到根因、完成重构、联调前后端,并把结果推进到能运行、能验证、能交付。覆盖 Web、后端、脚本、iOS、安卓、鸿蒙 ArkUI、微信小程序及其他技术栈,支持中英文工程、疑难 Bug、跨模块任务和长任务续做;用构建、日志、真实入口、设备或接口证据说明结果。仅问概念时直接回答,要求落地时持续推进到验收或明确阻塞。

↓ 11.3M★ 82u_42bbb65f
编程专家Pro.SkillDevelopment

编程专家 Pro:融合编程专家 2.0.3 工程专题与编程大神的鸿蒙 ArkTS/ArkUI、微信小程序和小游戏开发资料。用于项目实现、根因调试、审查、重构、测试、架构性能分析及多端开发验证。支持自然语言和 @专题标识,按任务读取包内知识;只问概念时直接回答。

↓ 6.3M★ 32user_47d655f0
编程专家.SkillDevelopment

编程专家.Skill P8级编程助手,25年实战经验技能Skill,全栈:Java/Php网站/软件项目、API设计、Bug诊断、代码生成、代码审查、重构、测试用例、性能基准、技术选型、文档生成、任务拆解、Spec驱动、Karpathy规范、CMS二次开发、前端设计、MySQL/Mariadb、项目知识图谱,以及工程纪律层(根因调试硬闭环、阶段导航、事故复盘/SLO、威胁建模/供应链安全、生产就绪/渐进式发布、AI编码治理、面向Agent代码可读性、LLM应用安全)。支持 @标识 显式调用跳过路由。

↓ 6.0M★ 378user_741dc82b
dev-expertDevelopment

编程专家.Skill P8级编程助手,25年实战经验技能Skill,全栈:Java/Php网站/软件项目、API设计、Bug诊断、代码生成、代码审查、重构、测试用例、性能基准、技术选型、文档生成、任务拆解、Spec驱动、Karpathy规范、CMS二次开发、前端设计、MySQL/Mariadb、项目知识图谱,以及工程纪律层(根因调试硬闭环、阶段导航、事故复盘/SLO、威胁建模/供应链安全、生产就绪/渐进式发布、AI编码治理、面向Agent代码可读性、LLM应用安全)。支持 @标识 显式调用跳过路由。

↓ 5.3M★ 32user_814dbe54
dev-expert-proDevelopment

工程专题、鸿蒙与微信小程序开发的集成派生版

↓ 1.0M★ -user_814dbe54
编程专家 ProDevelopment

编程专家 Pro:融合编程专家 2.0.3 工程专题与编程大神的鸿蒙 ArkTS/ArkUI、微信小程序和小游戏开发资料。用于项目实现、根因调试、审查、重构、测试、架构性能分析及多端开发验证。支持自然语言和 @专题标识,按任务读取包内知识;只问概念时直接回答。

↓ 981.8K★ 1user_28275a78
编程专家.SkillDevelopment

适用场景:全栈编程助手。接到需求先读现有代码和约束,再动手:Java/PHP 开发、接口设计、缺陷定位、代码评审、重构、测试用例、性能排查、技术选型与文档产出,也做 CMS 二次开发、前端页面和 MySQL 调优。每次改动先给方案和影响范围,改完必须跑验证,交付附交接说明。适合要把代码真正跑通、而不是只要片段的场景。写完代码常要配套的造价、法律、工程文档,站内已有现成技能,用「查找技能」按需求找即可。

↓ 701.1K★ 6user_613b33ea
GithubDevelopment

A skill for working with GitHub through the gh CLI: pull request checks, workflow runs, and API queries.

↓ 479.6K★ 714Peter Steinberger

More from ogenes

Data as of 2026-10. Downloads and stars are aggregated monthly from public skill registries (ClawHub, SkillHub). See data methodology.