npx skills add https://github.com/vm0-ai/vm0-skills --skill lark完整的企业级 Lark/飞书集成方案,涵盖消息通讯、群组管理、通讯录和日历功能。
设置以下环境变量:
export LARK_APP_ID=cli_xxxxx
export LARK_APP_SECRET=xxxxx
从以下地址获取您的凭证:https://open.larkoffice.com/
在您的 Lark 应用中启用以下 API 权限范围:
im:message - 发送和读取消息im:chat - 管理群聊contact:user.base:readonly - 读取通讯录calendar:calendar - 管理日历广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Lark 使用租户访问令牌,该令牌在 2 小时后过期。使用此辅助函数获取或刷新令牌:
# 获取或刷新令牌(缓存到 /tmp/lark_token.json)
get_lark_token() {
local token_file="/tmp/lark_token.json"
local current_time=$(date +%s)
# 检查缓存的令牌是否仍然有效
if [ -f "$token_file" ]; then
local expire_time=$(jq -r '.expire_time // 0' "$token_file" 2>/dev/null || echo "0")
if [ "$current_time" -lt "$expire_time" ]; then
jq -r '.tenant_access_token' "$token_file"
return 0
fi
fi
# 获取新令牌
local response=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\": \"${LARK_APP_ID}\", \"app_secret\": \"${LARK_APP_SECRET}\"}")
local code=$(echo "$response" | jq -r '.code // -1')
if [ "$code" != "0" ]; then
echo "Error: $(echo "$response" | jq -r '.msg')" >&2
return 1
fi
local expire=$(echo "$response" | jq -r '.expire')
local expire_time=$((current_time + expire - 300))
echo "$response" | jq ". + {expire_time: $expire_time}" > "$token_file"
jq -r '.tenant_access_token' "$token_file"
}
# 在命令中使用
TOKEN=$(get_lark_token)
或者直接获取令牌(无缓存):
TOKEN=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\": \"$(printenv LARK_APP_ID)\", \"app_secret\": \"$(printenv LARK_APP_SECRET)\"}" | jq -r '.tenant_access_token')
获取并显示租户访问令牌:
写入 /tmp/lark_request.json:
{
"app_id": "${LARK_APP_ID}",
"app_secret": "${LARK_APP_SECRET}"
}
curl -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"receive_id": "ou_xxx",
"msg_type": "text",
"content": "{\"text\": \"Hello World\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "text",
"content": "{\"text\": \"Group message\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"receive_id": "ou_xxx",
"msg_type": "post",
"content": "{\"zh_cn\": {\"title\": \"Title\", \"content\": [[{\"tag\": \"text\", \"text\": \"Content\"}]]}}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "interactive",
"content": "{\"header\": {\"title\": {\"tag\": \"plain_text\", \"content\": \"Alert\"}}, \"elements\": [{\"tag\": \"div\", \"text\": {\"tag\": \"plain_text\", \"content\": \"Message\"}}]}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"msg_type": "text",
"content": "{\"text\": \"Reply content\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages/om_xxx/reply" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/messages?container_id_type=chat&container_id=oc_xxx&page_size=20" \
-H "Authorization: Bearer ${TOKEN}"
写入 /tmp/lark_request.json:
{
"name": "Project Team",
"description": "Project discussion group",
"user_id_list": ["ou_xxx", "ou_yyy"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/chats" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx" \
-H "Authorization: Bearer ${TOKEN}"
写入 /tmp/lark_request.json:
{
"id_list": ["ou_xxx", "ou_yyy"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx/members?member_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"id_list": ["ou_xxx"]
}
TOKEN=$(get_lark_token)
curl -X DELETE "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx/members?member_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/ou_xxx?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}"
写入 /tmp/lark_request.json:
{
"query": "John"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/contact/v3/users/search?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/departments?parent_department_id=0" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/find_by_department?department_id=od_xxx&user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/calendar/v4/calendars" \
-H "Authorization: Bearer ${TOKEN}"
写入 /tmp/lark_request.json:
{
"summary": "Project Calendar",
"description": "Calendar for project events"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
注意:将 <calendar_id> 替换为从"列出日历"API 获取的实际日历 ID。
TOKEN=$(get_lark_token)
# 将 ISO 8601 转换为 Unix 时间戳
START_TS=$(date -d "2025-01-15T10:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T10:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-15T11:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T11:00:00+08:00" +%s)
# 写入带时间戳的请求
cat > /tmp/lark_request.json <<EOF
{
"summary": "Team Meeting",
"description": "Weekly sync",
"start_time": {"timestamp": "${START_TS}"},
"end_time": {"timestamp": "${END_TS}"}
}
EOF
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
# 转换日期范围
START_TS=$(date -d "2025-01-01T00:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-01T00:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-31T23:59:59+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-31T23:59:59+08:00" +%s)
curl -X GET "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events?start_time=${START_TS}&end_time=${END_TS}" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/bot/v3/info" \
-H "Authorization: Bearer ${TOKEN}"
写入 /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "interactive",
"content": "{\"header\": {\"title\": {\"tag\": \"plain_text\", \"content\": \"System Alert\"}, \"template\": \"red\"}, \"elements\": [{\"tag\": \"div\", \"text\": {\"tag\": \"lark_md\", \"content\": \"**Error:** Service down\"}}]}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
写入 /tmp/lark_request.json:
{
"name": "Q1 Project",
"description": "Q1 project discussion",
"user_id_list": ["ou_abc", "ou_def", "ou_ghi"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
# 获取根部门
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/departments?parent_department_id=0" \
-H "Authorization: Bearer ${TOKEN}" | jq '.data.items[] | {id: .department_id, name: .name}'
# 获取部门成员
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/find_by_department?department_id=od_xxx&user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" | jq '.data.items[] | {id: .user_id, name: .name}'
TOKEN=$(get_lark_token)
START_TS=$(date -d "2025-01-20T09:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-20T09:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-20T10:30:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-20T10:30:00+08:00" +%s)
# 写入带时间戳的请求
cat > /tmp/lark_request.json <<EOF
{
"summary": "Sprint Planning",
"description": "Sprint 5 planning session",
"start_time": {"timestamp": "${START_TS}"},
"end_time": {"timestamp": "${END_TS}"}
}
EOF
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
| 类型 | msg_type | content 格式 |
|---|---|---|
| 文本 | text | {"text": "message"} |
| 富文本 | post | {"zh_cn": {"title": "...", "content": [...]}} |
| 图片 | image | {"image_key": "img_xxx"} |
| 卡片 | interactive | {"header": {...}, "elements": [...]} |
| ID 类型 | 描述 | 示例 |
|---|---|---|
open_id | 用户开放 ID(默认) | ou_xxx |
user_id | 用户 ID | abc123 |
union_id | 跨应用统一 ID | on_xxx |
email | 用户邮箱地址 | user@example.com |
chat_id | 群聊 ID | oc_xxx |
令牌管理:令牌在 2 小时后过期。使用 get_lark_token 辅助函数进行自动缓存和刷新。
速率限制:Lark 对每个应用有速率限制。进行批量操作时请添加延迟,以避免触发限制。
ID 类型:对于大多数用户操作,使用 open_id。针对群聊时,使用 chat_id。
卡片构建器:使用 Lark 卡片构建器设计复杂的交互式卡片:https://open.larkoffice.com/tool/cardbuilder
错误处理:检查响应中的 code 字段。0 表示成功,非零表示错误。
内容转义:消息内容作为字符串传递时必须进行 JSON 转义。使用 jq 构建复杂的负载:
CONTENT=$(jq -n --arg text "Hello" '{text: $text}')
curl ... -d "{\"content\": \"$(echo $CONTENT | jq -c .)\"}"
日期转换:日历事件需要 Unix 时间戳。根据您的操作系统使用带有适当标志的 date 命令:
date -d "2025-01-15T10:00:00+08:00" +%sdate -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T10:00:00+08:00" +%s每周安装量
173
代码仓库
GitHub 星标数
47
首次出现
2026年1月24日
安全审计
安装于
opencode145
gemini-cli141
codex140
openclaw137
github-copilot137
cursor136
Complete Lark/Feishu integration for enterprise collaboration, including messaging, group management, contacts, and calendar.
Set the following environment variables:
export LARK_APP_ID=cli_xxxxx
export LARK_APP_SECRET=xxxxx
Get your credentials from: https://open.larkoffice.com/
Enable these API scopes in your Lark app:
im:message - Send and read messagesim:chat - Manage group chatscontact:user.base:readonly - Read contactscalendar:calendar - Manage calendarsLark uses tenant access tokens that expire after 2 hours. Use this helper to get or refresh the token:
# Get or refresh token (cached to /tmp/lark_token.json)
get_lark_token() {
local token_file="/tmp/lark_token.json"
local current_time=$(date +%s)
# Check if cached token is still valid
if [ -f "$token_file" ]; then
local expire_time=$(jq -r '.expire_time // 0' "$token_file" 2>/dev/null || echo "0")
if [ "$current_time" -lt "$expire_time" ]; then
jq -r '.tenant_access_token' "$token_file"
return 0
fi
fi
# Get new token
local response=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\": \"${LARK_APP_ID}\", \"app_secret\": \"${LARK_APP_SECRET}\"}")
local code=$(echo "$response" | jq -r '.code // -1')
if [ "$code" != "0" ]; then
echo "Error: $(echo "$response" | jq -r '.msg')" >&2
return 1
fi
local expire=$(echo "$response" | jq -r '.expire')
local expire_time=$((current_time + expire - 300))
echo "$response" | jq ". + {expire_time: $expire_time}" > "$token_file"
jq -r '.tenant_access_token' "$token_file"
}
# Usage in commands
TOKEN=$(get_lark_token)
Or get token directly without caching:
TOKEN=$(curl -s -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d "{\"app_id\": \"$(printenv LARK_APP_ID)\", \"app_secret\": \"$(printenv LARK_APP_SECRET)\"}" | jq -r '.tenant_access_token')
Get and display tenant access token:
Write to /tmp/lark_request.json:
{
"app_id": "${LARK_APP_ID}",
"app_secret": "${LARK_APP_SECRET}"
}
curl -X POST "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"receive_id": "ou_xxx",
"msg_type": "text",
"content": "{\"text\": \"Hello World\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "text",
"content": "{\"text\": \"Group message\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"receive_id": "ou_xxx",
"msg_type": "post",
"content": "{\"zh_cn\": {\"title\": \"Title\", \"content\": [[{\"tag\": \"text\", \"text\": \"Content\"}]]}}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "interactive",
"content": "{\"header\": {\"title\": {\"tag\": \"plain_text\", \"content\": \"Alert\"}}, \"elements\": [{\"tag\": \"div\", \"text\": {\"tag\": \"plain_text\", \"content\": \"Message\"}}]}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"msg_type": "text",
"content": "{\"text\": \"Reply content\"}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages/om_xxx/reply" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/messages?container_id_type=chat&container_id=oc_xxx&page_size=20" \
-H "Authorization: Bearer ${TOKEN}"
Write to /tmp/lark_request.json:
{
"name": "Project Team",
"description": "Project discussion group",
"user_id_list": ["ou_xxx", "ou_yyy"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/chats" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx" \
-H "Authorization: Bearer ${TOKEN}"
Write to /tmp/lark_request.json:
{
"id_list": ["ou_xxx", "ou_yyy"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx/members?member_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"id_list": ["ou_xxx"]
}
TOKEN=$(get_lark_token)
curl -X DELETE "https://open.feishu.cn/open-apis/im/v1/chats/oc_xxx/members?member_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/ou_xxx?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}"
Write to /tmp/lark_request.json:
{
"query": "John"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/contact/v3/users/search?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/departments?parent_department_id=0" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/find_by_department?department_id=od_xxx&user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/calendar/v4/calendars" \
-H "Authorization: Bearer ${TOKEN}"
Write to /tmp/lark_request.json:
{
"summary": "Project Calendar",
"description": "Calendar for project events"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Note: Replace <calendar_id> with an actual calendar ID from List Calendars API.
TOKEN=$(get_lark_token)
# Convert ISO 8601 to Unix timestamp
START_TS=$(date -d "2025-01-15T10:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T10:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-15T11:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T11:00:00+08:00" +%s)
# Write request with timestamps
cat > /tmp/lark_request.json <<EOF
{
"summary": "Team Meeting",
"description": "Weekly sync",
"start_time": {"timestamp": "${START_TS}"},
"end_time": {"timestamp": "${END_TS}"}
}
EOF
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
# Convert date range
START_TS=$(date -d "2025-01-01T00:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-01T00:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-31T23:59:59+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-31T23:59:59+08:00" +%s)
curl -X GET "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events?start_time=${START_TS}&end_time=${END_TS}" \
-H "Authorization: Bearer ${TOKEN}"
TOKEN=$(get_lark_token)
curl -X GET "https://open.feishu.cn/open-apis/bot/v3/info" \
-H "Authorization: Bearer ${TOKEN}"
Write to /tmp/lark_request.json:
{
"receive_id": "oc_xxx",
"msg_type": "interactive",
"content": "{\"header\": {\"title\": {\"tag\": \"plain_text\", \"content\": \"System Alert\"}, \"template\": \"red\"}, \"elements\": [{\"tag\": \"div\", \"text\": {\"tag\": \"lark_md\", \"content\": \"**Error:** Service down\"}}]}"
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
Write to /tmp/lark_request.json:
{
"name": "Q1 Project",
"description": "Q1 project discussion",
"user_id_list": ["ou_abc", "ou_def", "ou_ghi"]
}
TOKEN=$(get_lark_token)
curl -X POST "https://open.feishu.cn/open-apis/im/v1/chats?user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
TOKEN=$(get_lark_token)
# Get root departments
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/departments?parent_department_id=0" \
-H "Authorization: Bearer ${TOKEN}" | jq '.data.items[] | {id: .department_id, name: .name}'
# Get members in a department
curl -X GET "https://open.feishu.cn/open-apis/contact/v3/users/find_by_department?department_id=od_xxx&user_id_type=open_id" \
-H "Authorization: Bearer ${TOKEN}" | jq '.data.items[] | {id: .user_id, name: .name}'
TOKEN=$(get_lark_token)
START_TS=$(date -d "2025-01-20T09:00:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-20T09:00:00+08:00" +%s)
END_TS=$(date -d "2025-01-20T10:30:00+08:00" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-20T10:30:00+08:00" +%s)
# Write request with timestamps
cat > /tmp/lark_request.json <<EOF
{
"summary": "Sprint Planning",
"description": "Sprint 5 planning session",
"start_time": {"timestamp": "${START_TS}"},
"end_time": {"timestamp": "${END_TS}"}
}
EOF
curl -X POST "https://open.feishu.cn/open-apis/calendar/v4/calendars/<calendar_id>/events" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d @/tmp/lark_request.json
| Type | msg_type | content Format |
|---|---|---|
| Text | text | {"text": "message"} |
| Rich Text | post | {"zh_cn": {"title": "...", "content": [...]}} |
| Image | image | {"image_key": "img_xxx"} |
| Card | interactive |
| ID Type | Description | Example |
|---|---|---|
open_id | User open ID (default) | ou_xxx |
user_id | User ID | abc123 |
union_id | Union ID across apps | on_xxx |
email |
Token Management : Tokens expire after 2 hours. Use the get_lark_token helper function for automatic caching and refresh.
Rate Limits : Lark has rate limits per app. Add delays for bulk operations to avoid hitting limits.
ID Types : Use open_id for most user operations. Use chat_id when targeting group chats.
Card Builder : Design complex interactive cards using Lark Card Builder: https://open.larkoffice.com/tool/cardbuilder
Error Handling : Check the code field in responses. 0 means success, non-zero indicates an error.
Content Escaping : Message content must be JSON-escaped when passed as string. Use jq to build complex payloads:
Weekly Installs
173
Repository
GitHub Stars
47
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode145
gemini-cli141
codex140
openclaw137
github-copilot137
cursor136
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
33,600 周安装
{"header": {...}, "elements": [...]} |
| User email address |
user@example.com |
chat_id | Group chat ID | oc_xxx |
CONTENT=$(jq -n --arg text "Hello" '{text: $text}')
curl ... -d "{\"content\": \"$(echo $CONTENT | jq -c .)\"}"
Date Conversion : Calendar events require Unix timestamps. Use date command with appropriate flags for your OS:
date -d "2025-01-15T10:00:00+08:00" +%sdate -j -f "%Y-%m-%dT%H:%M:%S%z" "2025-01-15T10:00:00+08:00" +%s