Send messages, manage group chats, and configure group features via the IM API.
Base URL: https://open.feishu.cn/open-apis/im/v1
Authentication and Token Acquisition
From feishu_skills root directory, execute the shared script:
TOKEN="$(./scripts/get_feishu_token.sh)"
Request headers uniformly use Authorization: Bearer ${TOKEN}。
If the business API returns an invalid token, expired token, or 401, force a refresh and retry the original request only once:
TOKEN="$(./scripts/get_feishu_token.sh --force-refresh)"
Environment Variables:
FEISHU_APP_IDFEISHU_APP_SECRET
Local Cache: ./.feishu_token_cache.json(reused directly if not expired, refreshed by default 5 minutes in advance)
Message Operations
| API | Endpoint | Description |
|---|---|---|
| Send Message | POST /messages?receive_id_type=open_id |
Supports text/card/image/file |
| Batch Send | POST /messages/batch_send |
Up to 200 people |
| Reply to Message | POST /messages/{message_id}/reply |
- |
| Recall Message | DELETE /messages/{message_id} |
Within 24 hours |
| Urge Message | PATCH /messages/{message_id}/urgent_app |
- |
| Pin Message | POST /pins |
- |
| Add Reaction | POST /messages/{message_id}/reactions |
- |
Send Text Message:
{
"receive_id": "ou_xxx",
"msg_type": "text",
"content": "{\"text\":\"Hello\"}"
}
⚠️ content must be stringified JSON.
receive_id_type: open_id / user_id / email / chat_id
Interactive Card
Send Card:
{
"receive_id": "ou_xxx",
"msg_type": "interactive",
"content": "<card_json_string>"
}
Card Structure:
{
"config": {"wide_screen_mode": true},
"header": {
"title": {"tag": "plain_text", "content": "标题"},
"template": "blue"
},
"elements": [
{"tag": "div", "text": {"tag": "lark_md", "content": "**加粗**"}},
{"tag": "action", "actions": [
{"tag": "button", "text": {"tag": "plain_text", "content": "确认"}, "type": "primary"}
]}
]
}
Common Elements:
div: text block (supportslark_md/plain_text)hr: divideraction: button groupimg: imagenote: note
Group Chat Management
| API | Endpoint | Description |
|---|---|---|
| Create Group Chat | POST /chats |
- |
| Get Group Info | GET /chats/{chat_id} |
- |
| Update Group Info | PUT /chats/{chat_id} |
Modify group name/description/avatar |
| Disband Group Chat | DELETE /chats/{chat_id} |
- |
| Search Group Chats | GET /chats/search |
- |
Create Group Chat:
{
"name": "项目群",
"description": "项目讨论",
"user_id_list": ["ou_xxx", "ou_yyy"]
}
Group Member Management
| API | Endpoint | Description |
|---|---|---|
| Get Member List | GET /chats/{chat_id}/members |
- |
| Add Members | POST /chats/{chat_id}/members |
Up to 50 people/time |
| Remove Members | DELETE /chats/{chat_id}/members |
- |
| Transfer Group Owner | PUT /chats/{chat_id}/owner |
- |
Group Feature Configuration
| API | Endpoint | Description |
|---|---|---|
| Group Announcement | PATCH /chats/{chat_id}/announcement |
- |
| Group Pin | POST /chats/{chat_id}/top_notice/put_top_notice |
- |
| Group Menu | POST /chats/{chat_id}/menu_tree |
- |
| Group Tab | POST /chats/{chat_id}/chat_tabs |
- |
Set Group Announcement:
{
"content": "群公告内容",
"i18n_contents": {
"zh_cn": "中文公告",
"en_us": "English Announcement"
}
}
Best Practices
- Prioritize batch sending(reduces API calls)
- Card content must be stringified
- Group member operations up to 50 people/time
- Message recall limited to within 24 hours