Create Database Table
Last updated:
Create Database Table
Supports creating new database tables and their fields for the Bot via this API.
Request Method
POST
Endpoint
https://api.gptbots.ai/v1/database/create-table
Authentication
For details, refer to the authentication method description in API Overview.
Request
Request Example
curl -X POST https://api.gptbots.ai/v1/database/create-table \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"name": "test_api", // Table name (required)
"description": "Test all database APIs", // Description of the table (required)
"fields": [
{
"name": "id", // Field name
"description": "id", // Field description
"type": "TEXT", // Data type
"required": true, // Required
"unique": true // Unique
},
{
"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.gptbots.ai/v1/database/create-table \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"name": "test_api", // Table name (required)
"description": "Test all database APIs", // Description of the table (required)
"fields": [
{
"name": "id", // Field name
"description": "id", // Field description
"type": "TEXT", // Data type
"required": true, // Required
"unique": true // Unique
},
{
"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
}
]
}'
This code block in the floating window
Request Headers
Field | Type | Description |
---|---|---|
Authorization | Bearer ${token} | Use Authorization: Bearer ${token} for authentication. Obtain the token from the API key page. |
Content-Type | application/json | Data type, set to application/json. |
Request Body
Field | Type | Required | Description |
---|---|---|---|
name | string | Yes | Table name: 32 characters, a~z/numbers and underscores, starting with a letter. |
description | string | Yes | Table description: 128 characters, to help LLM understand the data structure of the table. |
fields | array | Yes | Array of table fields. |
fields[].name | string | Yes | Field name: 32 characters, a~z/numbers and underscores. |
fields[].description | string | Yes | Field description: 128 characters, to help LLM understand the data structure of the table. |
fields[].type | string | Yes | Data type: TEXT/INT/FLOAT/DATETIME/BOOLEAN. |
fields[].required | boolean | No | Required: true/false. |
fields[].unique | boolean | No | Unique: true |