OpenCLI Online

DingTalk

DingTalk CLI

DingTalk Open Platform—internal apps, group bots, and approvals from the CLI.

TypeLink
DingTalk Open Platformhttps://open.dingtalk.com/
Developer documentationhttps://open.dingtalk.com/document/
App consolehttps://open-dev.dingtalk.com/

Lists all opencli dingtalk subcommands; HTTP field details follow the Open Platform docs, CLI entry points follow this page.

Overview

opencli dingtalk configures app credentials, maintains access_token, sends group robot messages, and supports ops scripts and local integration tests.

Prerequisites

ItemNotes
Enterprise app on Open Platform“Internal development” or ISV app
AppKey / AppSecretFrom app details
Required API permissionse.g. contacts read, group chat write—apply in console
Node.js 20+For opencli

Install

npm install -g @opencli/cli@latest
opencli dingtalk --version

Configuration

Via subcommands

opencli dingtalk config set app_key dingxxxxxxxxxxxx
opencli dingtalk config set app_secret --stdin < secret.txt
  • set app_key: maps to AppKey.
  • set app_secret --stdin: read secret from file to avoid process listings.

Environment variables only

export DINGTALK_APP_KEY=dingxxxxxxxxxxxx
export DINGTALK_APP_SECRET=your_secret_here

OpenCLI reads env first, then ~/.opencli/dingtalk.json.

Get access_token

opencli dingtalk auth token --print
BehaviorNotes
Calls https://oapi.dingtalk.comExchanges app_key + app_secret
Local cache~2h TTL, refreshes ~5 minutes early
--printDebug only; don’t log tokens in production

Command reference (full)

opencli dingtalk --help

config

CommandDescription
opencli dingtalk config set app_key <key>Set AppKey
opencli dingtalk config set app_secret --stdinRead secret from stdin
opencli dingtalk config set app_secret --from-env <ENV>Read secret from env var
opencli dingtalk config get <key>Read one key
opencli dingtalk config listList all (secrets masked)
opencli dingtalk config pathConfig file path

auth

CommandDescription
opencli dingtalk auth token [--print] [--no-cache]Fetch access_token
opencli dingtalk auth token --print

message

CommandDescription
opencli dingtalk message work-notice --userid-list <id1,id2> --msg '<json>'Async work notification; --msg is full JSON body
opencli dingtalk message work-notice --userid-list "10001,10002" --msg '{"msgtype":"text","text":{"content":"Deploy finished"}}'

robot

CommandDescription
opencli dingtalk robot webhook --url <full webhook URL> --secret <signing secret> --text <body>Signed text message
opencli dingtalk robot webhook --url <URL> --secret <SECRET> --markdown '<json>'Markdown (if supported)
opencli dingtalk robot webhook \
  --url "https://oapi.dingtalk.com/robot/send?access_token=XXX" \
  --secret SECRET \
  --text "Build succeeded: main #1024"

approval

CommandDescription
opencli dingtalk approval get --process-instance-id <id>Single instance
opencli dingtalk approval list [--originator <userid>] [--limit N] [--cursor <c>]Paginated list
opencli dingtalk approval get --process-instance-id pi_xxxx

contact

CommandDescription
opencli dingtalk contact user get --userid <id>User detail

http (debugging)

CommandDescription
opencli dingtalk http get <path> [--query k=v]GET with token
opencli dingtalk http post <path> --body '<json>'POST with token

Tooling notes

  • With GitHub Actions, store DINGTALK_APP_KEY / DINGTALK_APP_SECRET as encrypted secrets.
  • Allow egress to oapi.dingtalk.com and any other domains listed in official docs.