สร้างตารางฐานข้อมูล
สร้างตารางฐานข้อมูล
รองรับการสร้างตารางฐานข้อมูลใหม่และฟิลด์ต่าง ๆ สำหรับ Agent ผ่าน API นี้
วิธีการร้องขอ
POST
Endpoint
https://api-${endpoint}.gptbots.ai/v1/database/create-table
การยืนยันตัวตน
โปรดดูรายละเอียดวิธีการยืนยันตัวตนใน API Overview
ตัวอย่างการร้องขอ
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": "Test all database APIs",
"fields": [
{
"name": "id",
"description": "id",
"type": "TEXT",
"required": true,
"unique": true
},
{
"name": "boolean",
"description": "boolean",
"type": "BOOLEAN",
"required": true,
"unique": false
},
{
"name": "int",
"description": "int",
"type": "INT",
"required": true,
"unique": true
},
{
"name": "datetime",
"description": "datetime",
"type": "DATETIME",
"required": true,
"unique": false
},
{
"name": "float",
"description": "float",
"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": "Test all database APIs",
"fields": [
{
"name": "id",
"description": "id",
"type": "TEXT",
"required": true,
"unique": true
},
{
"name": "boolean",
"description": "boolean",
"type": "BOOLEAN",
"required": true,
"unique": false
},
{
"name": "int",
"description": "int",
"type": "INT",
"required": true,
"unique": true
},
{
"name": "datetime",
"description": "datetime",
"type": "DATETIME",
"required": true,
"unique": false
},
{
"name": "float",
"description": "float",
"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 กรุณาติดต่อผู้ให้บริการเพื่อขอเพิ่มขีดจำกัด |
| 40127 | การยืนยันตัวตนของนักพัฒนาไม่สำเร็จ |
| 40353 | ฟีเจอร์นี้ใช้ได้เฉพาะหลังอัปเกรดแพ็กเกจ |
| 403100 | ชื่อตารางไม่ถูกต้อง |
| 403103 | ชื่อฟิลด์ไม่ถูกต้อง |
| 50000 | ข้อผิดพลาดภายในระบบ |
