logo
開發者文件
搜尋
創建資料庫表格

創建資料庫表格

支援透過此 API 為 Agent 創建新的資料庫表格及其欄位。

請求方法

POST

端點

https://api-${endpoint}.gptbots.ai/v1/database/create-table

認證

您可以在 API 概述 中找到詳細的認證方法說明。

請求

請求範例

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/create-table' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "name": "test_api", "description": "測試所有資料庫 API", "fields": [ { "name": "id", "description": "id", "type": "TEXT", "required": true, "unique": true }, { "name": "boolean", "description": "布林型別", "type": "BOOLEAN", "required": true, "unique": false }, { "name": "int", "description": "整數", "type": "INT", "required": true, "unique": true }, { "name": "datetime", "description": "日期時間", "type": "DATETIME", "required": true, "unique": false }, { "name": "float", "description": "浮點數", "type": "FLOAT", "required": false, "unique": false } ] }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/create-table' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "name": "test_api",
    "description": "測試所有資料庫 API",
    "fields": [
        {
            "name": "id",
            "description": "id",
            "type": "TEXT",
            "required": true,
            "unique": true
        },
        {
            "name": "boolean",
            "description": "布林型別",
            "type": "BOOLEAN",
            "required": true,
            "unique": false
        },
        {
            "name": "int",
            "description": "整數",
            "type": "INT",
            "required": true,
            "unique": true
        },
        {
            "name": "datetime",
            "description": "日期時間",
            "type": "DATETIME",
            "required": true,
            "unique": false
        },
        {
            "name": "float",
            "description": "浮點數",
            "type": "FLOAT",
            "required": false,
            "unique": false
        }
    ]
}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 描述
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 進行認證。API Key 可從 API Key 頁面獲取。
Content-Type application/json 資料類型,設置為 application/json。

請求參數

欄位 類型 是否必填 描述
name string 表格名稱:64 字元,僅限 a~z/數字及底線,且以字母開頭。
description string 表格描述:128 字元,用於幫助 LLM(大型語言模型)瞭解表格的資料結構。
fields array 表格欄位的陣列。
fields[].name string 欄位名稱:64 字元,僅限 a~z/數字及底線。
fields[].description string 欄位描述:128 字元,用於幫助 LLM(大型語言模型)瞭解欄位的資料結構。
fields[].type string 資料類型:TEXT/INT/FLOAT/DATETIME/BOOLEAN。
fields[].required boolean 是否必填:true/false。
fields[].unique boolean 唯一性:true。

回應

回應範例

"673e9c7a9f7bc178002dbce8"
                      
                      "673e9c7a9f7bc178002dbce8"

                    
此代碼塊在浮窗中顯示

此為資料表的唯一識別碼範例。

成功回應

欄位 類型 描述
code int 訊息類型代碼。
message string 訊息描述。
data object 回應內容,資料表的唯一識別碼。

失敗回應

欄位 類型 描述
code int 錯誤代碼。
message string 錯誤詳情。

錯誤代碼

錯誤代碼 訊息
40000 無效的參數
40008 Agent RPM(每分鐘請求數 Requests Per Minute)請求超出限制。請聯繫服務提供商以提高限制。
40127 開發者認證失敗
40353 此功能僅在升級方案後可用
403100 無效的表格名稱
403103 無效的欄位名稱
50000 系統內部錯誤