SuperAPI AI Directory

feishu-bitable

Office & productivity

View repository

Updated 10-16 05:20

About this skill

Feishu Bitable API Operations

Provide AI large models with complete capabilities for handling Feishu Bitable, supporting operations on data tables, records, fields, and materials.

Environment Check

"node": ">=20.20.1"

⚠️ Important: About Code Obfuscation

This skill's scripts/ All JavaScript files under the directory have been obfuscated.

AI Code of Conduct

✅ Can execute: directly call and execute these scripts, use --parameter-file-path to pass parameters

❌ Do not read: do not read or analyze scripts/ under the directory .js file contents, reasons:

  • Obfuscated code has extremely poor readability and no practical meaning
  • Avoid wasting tokens and time
  • All feature descriptions are fully described in this document and the references/ directory

When encountering problems

  • Refer to references/ documents under the directory
  • Check the error messages and error codes output by the scripts
  • Do not attempt to read obfuscated code

🎯 Trigger Mapping: User Says → AI Does

User input trigger words AI execution action Corresponding script
"View records"/"Get records"/"List records" Run record/get.js query record list scripts/record/get.js
"Add record"/"Create record"/"Insert record" Run record/create.js create a single record scripts/record/create.js
"Modify record"/"Update record"/"Edit record" Run record/update.js update a single record scripts/record/update.js
"Delete record"/"Remove record" Run record/delete.js delete a single record scripts/record/delete.js
"Batch add records"/"Add multiple records" Run record/batch-create.js batch create records scripts/record/batch-create.js
"Batch modify records"/"Update multiple records" Run record/batch-update.js batch update records scripts/record/batch-update.js
"Batch delete records"/"Clear records" Run record/batch-delete.js batch delete records scripts/record/batch-delete.js
"View tables"/"Data table list" Run table/list.js list all data tables scripts/table/list.js
"Create table"/"Add data table" Run table/create-single.js create a single data table scripts/table/create-single.js
"Modify table name"/"Rename table" Run table/update.js update data table name scripts/table/update.js
"Delete table"/"Remove data table" Run table/delete-one.js delete a single data table scripts/table/delete-one.js
"View fields"/"Column information" Run field/list.js list all fields scripts/field/list.js
"Add field"/"New column" Run field/create.js create field scripts/field/create.js
"Modify field"/"Modify column" Run field/update.js update field scripts/field/update.js
"Delete Field"/"Remove Column" Run field/delete.js Delete Field scripts/field/delete.js
"Upload File"/"Upload Image"/"Upload Attachment" Run media/upload.js Upload Media scripts/media/upload.js
"Get Download Link"/"Get Direct Link" Run media/file-token-to-url.js Get File URL scripts/media/file-token-to-url.js

Decision Process

用户请求涉及飞书多维表格?
    │
    ├─ 是 → 检查具体操作类型
    │       │
    │       ├─ 需要访问凭证?
    │       │   └─ 运行 get-tenant-access-token.js
    │       │
    │       ├─ 需要从URL解析信息?
    │       │   └─ 运行 parse-bitable-url.js
    │       │
    │       └─ 执行具体操作
    │           ├─ 数据表操作 → table/ 脚本
    │           ├─ 记录操作 → record/ 脚本
    │           ├─ 字段操作 → field/ 脚本
    │           └─ 素材操作 → media/ 脚本
    │
    └─ 否 → 不使用此 Skill

How to Use This Skill

Feature Overview

This Skill provides complete Feishu Bitable API operation capabilities:

Feature Modules Supported Operations
Data Table Management Create, update, delete data tables (supports batch operations)
Record Operations Create, delete, update, and query records, supports batch operations (up to 1000 at a time)
Field Management Create, update, delete fields, list all fields
Media Upload Upload files, images, and other media, get temporary download links

Output Format

After execution completes, the Skill outputs:

  • Success: Returns operation result data (JSON format), including the complete API response
  • Failure: Returns error information, including error codes and suggested solutions

Prerequisites

  1. Valid tenant_access_token: All API operations require
  2. app_token: Identifies the Bitable to operate on
  3. table_id: Identifies the data table to operate on (required for some operations)

Parameter Passing Method

Note: All scripts in this Skill use --parameter-file-path parameter passing configuration, and must be called via a parameter file.

AI Invocation Specification: This Skill is designed specifically for AI. AI automatically handles the creation and cleanup of temporary files. Human users only need to describe their needs in natural language.

AI Automatic Temporary File Handling Process

When AI invokes this Skill, it must follow the process below to automatically manage temporary files:

import { createTempParamsFile, cleanupTempFile } from "./scripts/utils";
import { execSync } from "child_process";

// 1. 创建临时参数文件(自动存放在系统临时目录)
const tempFile = createTempParamsFile(
  {
    tenant_access_token: "xxx",
    app_token: "xxx",
    table_id: "xxx"
    // ... 其他参数
  },
  "operation-name"
);

try {
  // 2. 执行脚本
  const result = execSync(`node scripts/xxx.js --parameter-file-path "${tempFile}"`, { encoding: "utf-8" });
  const data = JSON.parse(result);

  // 3. 处理结果并返回给用户
  return formatResultForUser(data);
} finally {
  // 4. 确保清理临时文件(无论成功或失败)
  cleanupTempFile(tempFile);
}

Key Principles:

  • ✅ Temporary files must be created in the system temporary directory (os.tmpdir())
  • ✅ Clean up temporary files immediately after script execution completes
  • ✅ Use try...finally to ensure cleanup even if an error occurs
  • ❌ Do not create parameter files in the skill directory or user working directory

Standard Usage Process

Step 1: Obtain Access Credentials

node scripts/get-tenant-access-token.js --parameter-file-path params.json

Parameter File Example (params.json):

{
  "appId": "cli_xxx",
  "appSecret": "xxx"
}

For detailed credential management rules, see Authentication and Credential Management Guide。

Step 2: Parse the Bitable URL

Extract from the URL app_token and table_id:

node scripts/parse-bitable-url.js --parameter-file-path params.json

Step 3: Execute Specific Operations

Select the corresponding script based on your needs:

# 查询记录
node scripts/record/get.js --parameter-file-path "params.json"

# 创建记录
node scripts/record/create.js --parameter-file-path "params.json"

# 批量创建记录
node scripts/record/batch-create.js --parameter-file-path "params.json"

Core Concepts

Concept Description
Bitable A ByteDance product that combines the flexibility of spreadsheets with the structured characteristics of databases
Table A single table within a Bitable, similar to an Excel worksheet
Record A row of data in a data table
Field The header of a column in the data table, used to set the data type of that column
Media Uploaded files, images, videos, etc.

API Quick Reference

Basic Operations

Action Script Path Description
Get access token get-tenant-access-token.js Get tenant_access_token
Parse a Feishu Bitable URL parse-bitable-url.js Extract from the URL app_token、table_id、view_id

Data Table Operations

Action Script Path Description
Create a data table create-single.js Supports specifying the name, view, and fields
Create multiple data tables batch-create.js Only the data table name can be specified
Update data table name update.js Update the name of the specified data table
List data tables list.js Get the ID, version number, and name of all data tables
Delete a data table delete-one.js Via app_token and table_id delete
Delete multiple data tables batch-delete.js Batch delete multiple data tables

For detailed parameters, see the table reference documentation directory.

Record Operations

Action Script Path Description
Create record create.js Create a record in the data table
Update record update.js Update a record in the data table
Query records get.js Up to 500 rows per query, supports pagination
Delete record delete.js Delete a record in the data table
Create multiple records batch-create.js Up to 1,000 per request
Update multiple records batch-update.js Up to 1,000 per request
Batch get records batch-get.js Query by record ID, up to 100
Delete multiple records batch-delete.js Batch delete multiple records

For detailed parameters, see the record reference documentation directory.

Field Operations

Action Script Path Description
Create field create.js Create a field in the data table
Update field update.js Full update of the field (property will be overwritten)
List fields list.js Get all fields in the data table
Delete field delete.js Delete a field in the data table

For detailed parameters, see the field reference documentation directory.

Media/File Operations

Action Script Path Description
Media upload upload.js Upload files, images, videos, and other media
Get direct link file-token-to-url.js file_token convert to a temporary download link (valid for 24 hours)

For detailed parameters, see the media reference documentation directory.

File and Directory Usage Instructions

Item Description
Document location references/ documents in the directory, with specific API call commands or script execution methods
Script location scripts/ Node.js scripts in the directory can be used directly
Temporary files System temporary directory (%TEMP% or /tmp), automatically deleted after the operation is complete
Parameter file System temporary directory, referenced using an absolute path
Upload record System temporary directory (feishu-bitable-upload-records.json)

Best practices for temporary file management

All temporary files of this skill (parameter files, upload records) are stored in the system temporary directory to avoid polluting the user's home directory and the skill directory:

Windows example:

C:\Users\xxx\AppData\Local\Temp\feishu-create-record-1740374400000-a7x9k2.json
C:\Users\xxx\AppData\Local\Temp\feishu-bitable-upload-records.json

Linux/Mac example:

/tmp/feishu-create-record-1740374400000-a7x9k2.json
/tmp/feishu-bitable-upload-records.json

Utility function usage example

import { createTempParamsFile, cleanupTempFile, cleanupAllTempFiles } from './utils';

// 1. 创建临时参数文件(自动存放在系统临时目录)
const params = {
  tenant_access_token: 'xxx',
  app_token: 'xxx',
  table_id: 'xxx',
  fields: { ... }
};
const tempFilePath = createTempParamsFile(params, 'create-record');

// 2. 执行脚本
const result = await executeScript(tempFilePath);

// 3. 立即清理临时文件
cleanupTempFile(tempFilePath);

// 4. 清理所有过期的临时文件(24小时前的)
cleanupAllTempFiles();

Temporary file naming convention:

  • Format:feishu-{operation}-{timestamp}-{random}.json
  • Example:feishu-batch-create-1740374400000-a7x9k2.json

Cleanup strategy:

  • Immediately attempt to delete the parameter file whether it succeeds or fails
  • Deletion failure does not affect the main process
  • The system temporary directory is automatically cleaned up periodically
  • Run cleanupAllTempFiles() to batch clean up expired files (older than 24 hours)

AI processing example

User says: "Help me add a record in the Feishu spreadsheet https://xxx.feishu.cn/wiki/xxx with the task name 'Complete Report' and progress 50%"

AI execution steps:

Step Execution action Script/Command
1 Check tenant_access_token If not present, run get-tenant-access-token.js
2 Parse the URL to get app_token and table_id Run parse-bitable-url.js
3 Create a temporary parameter file Run createTempParamsFile(), stored in the system temporary directory
4 Create record Run record/create.js
5 Clean up the temporary parameter file Run cleanupTempFile()
6 Return result Return to the user: "Record created successfully! Record ID: recxxx"

User perception: There is no need to know about the existence of temporary files at all; only natural language interaction is needed.

Error handling

Error scenario Error manifestation Handling method
Missing access credential API returns a 401/403 error Run get-tenant-access-token.js to obtain the credential
Access credential expired API returns error code: 99991663, error message: Invalid access token for authorization Run get-tenant-access-token.js to obtain the credential
URL parsing failed Unable to extract app_token/table_id Check whether the URL format is correct, or provide the parameters manually
Record does not exist API returns a 404 error Check whether record_id is correct, or first run record/get.js to query
Field type mismatch API returns a 400 error Run field/list.js to view the field type, adjust the parameters, and retry
Text field format error TextFieldConvFail Error Text fields use string format, not rich text array format
Field update missing parameter field validation failed When updating a field, you must provide type parameter
Invalid file token format Cannot read properties Use file_tokens(array) instead of file_token(string)
Batch operation limit exceeded API returns 422 error Reduce the number of operations per request (up to 1000 records, up to 100 for batch retrieval)
Temporary file creation failed Insufficient disk space or permission issue Check system temporary directory permissions and disk space
Network timeout Request not responding Check network connection and try again later

Common error details

1. Text field format error (TextFieldConvFail)

Error message:the value of 'Multiline' must be a string

Cause: When creating/updating a record, the text field used the rich text array format returned by queries

Solution:

  • ❌ Incorrect:"字段名": [{"text": "内容", "type": "text"}]
  • ✅ Correct:"字段名": "内容"

2. Field update missing type parameter

Error message:field validation failed - type is required

Cause: When updating a field, type parameter was not provided

Solution: When updating a field, you must include type, such as "type": 1(1=text, 2=number)

3. Error in parameters for getting file download link

Error message:Cannot read properties of undefined (reading 'map')

Cause: Used file_token instead of file_tokens

Solution:

  • ❌ Incorrect:"file_token": "xxx"
  • ✅ Correct:"file_tokens": ["xxx"]

Reference documentation

Documentation Description
Authentication and credential management guide Detailed credential management instructions, including obtaining App ID/App Secret and the automatic tenant_access_token retrieval process
Get access token API Specific API call instructions and script usage for obtaining tenant_access_token
Feishu URL parsing tool Instructions for using the tool that extracts app_token, table_id, and view_id from Feishu Bitable URLs
Common errors and solutions Common API call error codes and troubleshooting methods
Parameter configuration examples and best practices Parameter configuration examples for various operation scenarios