SuperAPI AI Directory

feishu-drive

General & other

View repository

Updated 10-15 19:54

About this skill

Feishu Drive File Management

Manage files and folders via the Drive API.

Base URL: https://open.feishu.cn/open-apis/drive/v1

Authentication and Token Retrieval

From the feishu_skills root directory, run the shared script:

TOKEN="$(./scripts/get_feishu_token.sh)"

Request headers uniformly use Authorization: Bearer ${TOKEN}。

If a business API returns token invalid, expired, or 401, force a refresh and retry the original request only once:

TOKEN="$(./scripts/get_feishu_token.sh --force-refresh)"

Environment Variables:

  • FEISHU_APP_ID
  • FEISHU_APP_SECRET

Local Cache: ./.feishu_token_cache.json(reused directly if not expired, refreshed 5 minutes early by default)


Quick Start (Required Reading)

To avoid files ending up in a "private black box":

  1. Create an anchor folder(e.g., AI-Workspace)
  2. Authorize the bot: In the folder's [Collaboration] settings, add the app with [Manage] permission
  3. Get the Token: Copy the Token from the folder URL
  4. Test: Call batch_query to query that Token

⚠️ Folders created via the API are visible only to the bot by default; collaborators must be added manually.


Folder Operations

API Endpoint Method Request Body Example Description
Create Folder /folders POST {"name":"文件夹名","folder_token":"root"} Create a new folder
Get Folder Metadata /folders/{folder_token}/meta GET - Query folder details
Get Metadata (Batch) /metas/batch_query POST {"request_list":[{"token":"fldxxx","type":"folder"}]} Batch query files/folders
Get Folder Contents /folders/{folder_token}/children GET - Query the file list in a folder
Move Folder /folders/{folder_token}/move POST {"target_token":"fldxxx"} Move a folder
Copy Folder /folders/{folder_token}/copy POST {"target_token":"fldxxx"} Copy a folder
Delete Folder /folders/{folder_token} DELETE - Delete an empty folder

File Upload

API Endpoint Method Request Body Description
Small File Upload /files/upload_all POST multipart/form-data One-time upload (<20MB)
Large File Pre-upload /files/upload_prepare POST {"file_name":"big.zip","size":104857600} Initialize multipart upload
Multipart Upload /files/upload_part POST multipart/form-data Upload a single part
Complete Multipart Upload /files/upload_finish POST {"upload_id":"xxx","block_num":10} Complete the upload

Small File Upload:

POST /files/upload_all
Content-Type: multipart/form-data

file_name=test.txt
parent_type=explorer
parent_node=fldXXX
file=<binary>

File Download

API Endpoint Method Description
Download File /files/{file_token}/download GET Returns the file binary stream
Get File Metadata /files/{file_token}/meta GET Query file details
Get File List /files GET Parameters:folder_token parent folder

File Operations

API Endpoint Method Request Body Example Description
Move File /files/{file_token}/move POST {"type":"explorer","folder_token":"fldXXX"} Move a file
Copy File /files/{file_token}/copy POST {"type":"explorer","folder_token":"fldXXX","name":"副本.txt"} Copy a file
Delete File /files/{file_token} DELETE - Delete a file
Create Shortcut /shortcuts POST {"target_token":"filexxx","parent_token":"fldxxx"} Create a file shortcut
Get File Statistics /files/{file_token}/statistics GET - Query file access statistics

Search

API Endpoint Method Request body example Description
Search files /files/search POST {"search_key":"关键词","owner_ids":["ou_xxx"]} Full-text search
Search V2 /files/search_v2 POST Same as above New search interface

Permission management

API Endpoint Method Request body example Description
Add collaborator /permissions/{token}/members POST {"member_type":"user","member_id":"ou_xxx","perm":"full_access"} Add permission
Remove collaborator /permissions/{token}/members/{member_id} DELETE - Remove permission
Get collaborators /permissions/{token}/members GET - Query permission list
Update collaborator /permissions/{token}/members/{member_id}/patch PATCH {"perm":"edit"} Modify permission
Transfer owner /permissions/{token}/transfer_owner POST {"member_type":"user","member_id":"ou_xxx"} Transfer ownership
Get permission settings /permissions/{token}/public GET - Query public access settings
Update permission settings /permissions/{token}/public PATCH {"external_access":false} Modify public access

Permission type: view(View) / edit(Edit) / full_access(Full access)


File version management

API Endpoint Method Request body example Description
Get version list /files/{file_token}/versions GET - Query file history versions
Get version details /files/{file_token}/versions/{version_id} GET - Query specified version information
Delete version /files/{file_token}/versions/{version_id} DELETE - Delete historical version

File comments

API Endpoint Method Request body example Description
Get full-text comments /files/{file_token}/comments GET - Query all file comments
Get reply list /files/{file_token}/comments/{comment_id}/replies GET - Query comment replies
Add full-text comment /files/{file_token}/comments POST {"content":{"text":"评论内容"}} Add comment
Reply to comment /files/{file_token}/comments/{comment_id}/replies POST {"content":{"text":"回复内容"}} Reply to comment
Resolve/Reopen comment /files/{file_token}/comments/{comment_id} PATCH {"is_solved":true} Mark comment status

Subscription management

API Endpoint Method Request body example Description
Subscribe to file /files/{file_token}/subscriptions POST {"subscription_type":"file_edit"} Subscribe to file change notifications
Get subscription status /files/{file_token}/subscriptions/{subscription_id} GET - Query subscription status
Unsubscribe /files/{file_token}/subscriptions/{subscription_id} DELETE - Unsubscribe

Subscription type: file_edit(File edits) / file_comment(Comments) / file_share(Shares)


Best practices

  1. Add collaborators immediately after creating a folder(to avoid invisibility)
  2. Use chunked upload for large files(>20MB)
  3. Permission inheritance: After a parent folder is authorized, child folders automatically inherit
  4. Version management: Periodically clean up historical versions to save space
  5. Subscription notifications: Subscribe to change notifications for key files and respond promptly