> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/api/en/api-reference/zi-liao-ku.md). Agents can also search and read this documentation through its [MCP server](https://docs.maiagent.ai/~gitbook/mcp).

# Databases

### Create SQL Database Connection <a href="#sql-databases-create" id="sql-databases-create"></a>

POST `/api/v1/sql-databases/`

#### Request Body

**Request Parameters**

| Field         | Type           | Required | Description                                                                                                                                                                                      |
| ------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| name          | string         | Yes      | Display name for this database connection                                                                                                                                                        |
| description   | string         | No       | Description of the database and its purpose                                                                                                                                                      |
| databaseType  | object         | Yes      | Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent `postgresql`: PostgreSQL ; `mysql`: MySQL ; `maiagent`: MaiAgent ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl   | string         | No       | Connection string for external databases. Not required for MaiAgent type as it uses the system default.                                                                                          |
| includeTables | object         | No       | Optional list of tables to include. Format: {"tables": \["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files.                                                    |
| isActive      | boolean        | No       | When disabled, this database will not be used in Text-to-SQL queries                                                                                                                             |
| chatbots      | array\[IdName] | No       |                                                                                                                                                                                                  |
| groups        | array\[IdName] | No       |                                                                                                                                                                                                  |

**Example Request Schema**

```typescript
{
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl"?: string // Connection string for external databases. Not required for MaiAgent type as it uses the system default. (Optional)
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "chatbots"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "description": "Example string",
  "databaseType": {},
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true,
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "description": "Example string",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "description": "Example string",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "description": "Example string",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True,
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'description' => 'Example string',
            'databaseType' => new \stdClass(),
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true,
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrlMasked": string
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "status": 
  {
  }
  "deletedAt": string (timestamp)
  "tables": [
    {
      "id": string (uuid)
      "tableName": string // Name of the table in the database
      "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
      "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
      "status": 
      {
      }
      "errorMessage": string // Error details if table creation or deletion failed
      "sourceFile": 
      {
        "id": string (uuid)
        "name": string
        "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
      }
      "columns": [
        {
          "id": string (uuid)
          "columnName": string
          "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
          "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
          "isPrimaryKey"?: boolean // Optional
          "isNullable"?: boolean // Optional
          "createdAt": string (timestamp)
          "updatedAt": string (timestamp)
        }
      ]
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "chatbots": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "description": "Response string",
  "databaseType": {},
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "status": {},
  "deletedAt": "Response string",
  "tables": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "tableName": "Response string",
      "sheetName": "Response string",
      "description": "Response string",
      "status": {},
      "errorMessage": "Response string",
      "sourceFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string",
        "isFromKnowledgeBase": false
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "columnName": "Response string",
          "columnType": "Response string",
          "description": "Response string",
          "isPrimaryKey": false,
          "isNullable": false,
          "createdAt": "Response string",
          "updatedAt": "Response string"
        }
      ],
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string"
  },
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### List SQL Databases <a href="#sql-databases-list" id="sql-databases-list"></a>

GET `/api/v1/sql-databases/`

#### Parameters

| Parameter Name | Required | Type    | Description                                                                                                                                                                                                                                                                                                                                     |
| -------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createdByMe`  | ❌        | string  | "Created by me" filter: when set to true (or 1), returns only items created by the currently signed-in user, narrowing the results within the existing visible scope. If omitted, or set to false or any other value, the filter has no effect. Global (platform-provided) items have no creator and do not appear when this filter is enabled. |
| `databaseType` | ❌        | string  | Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent \`postgresql\`: PostgreSQL ; \`mysql\`: MySQL ; \`maiagent\`: MaiAgent ; \`oracle\`: Oracle ; \`mssql\`: MSSQL ; \`synxdb\`: SynxDB;                                                                                                                                    |
| `isActive`     | ❌        | boolean |                                                                                                                                                                                                                                                                                                                                                 |
| `isExternal`   | ❌        | boolean |                                                                                                                                                                                                                                                                                                                                                 |
| `page`         | ❌        | integer | A page number within the paginated result set.                                                                                                                                                                                                                                                                                                  |
| `pageSize`     | ❌        | integer | Number of results to return per page.                                                                                                                                                                                                                                                                                                           |
| `pagination`   | ❌        | boolean | Set to false to return all databases without pagination (defaults to true).                                                                                                                                                                                                                                                                     |
| `query`        | ❌        | string  |                                                                                                                                                                                                                                                                                                                                                 |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/?createdByMe=example&databaseType=maiagent&isActive=true&isExternal=true&page=1&pageSize=1&pagination=true&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/?createdByMe=example&databaseType=maiagent&isActive=true&isExternal=true&page=1&pageSize=1&pagination=true&query=example", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/?createdByMe=example&databaseType=maiagent&isActive=true&isExternal=true&page=1&pageSize=1&pagination=true&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/?createdByMe=example&databaseType=maiagent&isActive=true&isExternal=true&page=1&pageSize=1&pagination=true&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "name": string // Display name for this database connection
      "description"?: string // Description of the database and its purpose (Optional)
      "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
      {
      }
      "databaseUrlMasked": string
      "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
      "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
      "status": 
      {
      }
      "deletedAt": string (timestamp)
      "tables": [
        {
          "id": string (uuid)
          "tableName": string // Name of the table in the database
        }
      ]
      "tablesCount": integer
      "chatbots": [
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "groups": [
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "createdBy": 
      {
        "id": string (uuid)
        "name": string
      }
      "canUpdate": boolean // Return whether the current user can update this resource.
      "canDelete": boolean // Return whether the current user can delete this resource.
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**Example Response Values**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string",
      "description": "Response string",
      "databaseType": {},
      "databaseUrlMasked": "Response string",
      "includeTables": null,
      "isActive": false,
      "status": {},
      "deletedAt": "Response string",
      "tables": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "tableName": "Response string"
        }
      ],
      "tablesCount": 456,
      "chatbots": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Response string"
        }
      ],
      "groups": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Response string"
        }
      ],
      "createdBy": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string"
      },
      "canUpdate": false,
      "canDelete": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ]
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Get Specific SQL Database <a href="#sql-databases-retrieve" id="sql-databases-retrieve"></a>

GET `/api/v1/sql-databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                  |
| -------------- | -------- | ------ | -------------------------------------------- |
| `id`           | ✅        | string | A UUID string identifying this SQL Database. |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrlMasked": string
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "status": 
  {
  }
  "deletedAt": string (timestamp)
  "tables": [
    {
      "id": string (uuid)
      "tableName": string // Name of the table in the database
      "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
      "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
      "status": 
      {
      }
      "errorMessage": string // Error details if table creation or deletion failed
      "sourceFile": 
      {
        "id": string (uuid)
        "name": string
        "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
      }
      "columns": [
        {
          "id": string (uuid)
          "columnName": string
          "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
          "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
          "isPrimaryKey"?: boolean // Optional
          "isNullable"?: boolean // Optional
          "createdAt": string (timestamp)
          "updatedAt": string (timestamp)
        }
      ]
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "chatbots": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "description": "Response string",
  "databaseType": {},
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "status": {},
  "deletedAt": "Response string",
  "tables": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "tableName": "Response string",
      "sheetName": "Response string",
      "description": "Response string",
      "status": {},
      "errorMessage": "Response string",
      "sourceFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string",
        "isFromKnowledgeBase": false
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "columnName": "Response string",
          "columnType": "Response string",
          "description": "Response string",
          "isPrimaryKey": false,
          "isNullable": false,
          "createdAt": "Response string",
          "updatedAt": "Response string"
        }
      ],
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string"
  },
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Update SQL Database <a href="#sql-databases-update" id="sql-databases-update"></a>

PUT `/api/v1/sql-databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                  |
| -------------- | -------- | ------ | -------------------------------------------- |
| `id`           | ✅        | string | A UUID string identifying this SQL Database. |

#### Request Body

**Request Parameters**

| Field         | Type           | Required | Description                                                                                                                                   |
| ------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| name          | string         | Yes      | Display name for this database connection                                                                                                     |
| description   | string         | No       | Description of the database and its purpose                                                                                                   |
| databaseUrl   | string         | No       | Connection string for external databases. Not required for MaiAgent type as it uses the system default.                                       |
| includeTables | object         | No       | Optional list of tables to include. Format: {"tables": \["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. |
| isActive      | boolean        | No       | When disabled, this database will not be used in Text-to-SQL queries                                                                          |
| chatbots      | array\[IdName] | No       |                                                                                                                                               |
| groups        | array\[IdName] | No       |                                                                                                                                               |

**Example Request Schema**

```typescript
{
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseUrl"?: string // Connection string for external databases. Not required for MaiAgent type as it uses the system default. (Optional)
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "chatbots"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "description": "Example string",
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true,
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.put("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True,
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.put(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'description' => 'Example string',
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true,
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrlMasked": string
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "status": 
  {
  }
  "deletedAt": string (timestamp)
  "tables": [
    {
      "id": string (uuid)
      "tableName": string // Name of the table in the database
      "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
      "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
      "status": 
      {
      }
      "errorMessage": string // Error details if table creation or deletion failed
      "sourceFile": 
      {
        "id": string (uuid)
        "name": string
        "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
      }
      "columns": [
        {
          "id": string (uuid)
          "columnName": string
          "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
          "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
          "isPrimaryKey"?: boolean // Optional
          "isNullable"?: boolean // Optional
          "createdAt": string (timestamp)
          "updatedAt": string (timestamp)
        }
      ]
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "chatbots": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "description": "Response string",
  "databaseType": {},
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "status": {},
  "deletedAt": "Response string",
  "tables": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "tableName": "Response string",
      "sheetName": "Response string",
      "description": "Response string",
      "status": {},
      "errorMessage": "Response string",
      "sourceFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string",
        "isFromKnowledgeBase": false
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "columnName": "Response string",
          "columnType": "Response string",
          "description": "Response string",
          "isPrimaryKey": false,
          "isNullable": false,
          "createdAt": "Response string",
          "updatedAt": "Response string"
        }
      ],
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string"
  },
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Partially Update SQL Database <a href="#sql-databases-partial-update" id="sql-databases-partial-update"></a>

PATCH `/api/v1/sql-databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                  |
| -------------- | -------- | ------ | -------------------------------------------- |
| `id`           | ✅        | string | A UUID string identifying this SQL Database. |

#### Request Body

**Request Parameters**

| Field         | Type           | Required | Description                                                                                                                                   |
| ------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| name          | string         | No       | Display name for this database connection                                                                                                     |
| description   | string         | No       | Description of the database and its purpose                                                                                                   |
| databaseUrl   | string         | No       | Connection string for external databases. Not required for MaiAgent type as it uses the system default.                                       |
| includeTables | object         | No       | Optional list of tables to include. Format: {"tables": \["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. |
| isActive      | boolean        | No       | When disabled, this database will not be used in Text-to-SQL queries                                                                          |
| chatbots      | array\[IdName] | No       |                                                                                                                                               |
| groups        | array\[IdName] | No       |                                                                                                                                               |

**Example Request Schema**

```typescript
{
  "name"?: string // Display name for this database connection (Optional)
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseUrl"?: string // Connection string for external databases. Not required for MaiAgent type as it uses the system default. (Optional)
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "chatbots"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // Optional
    {
      "id": string (uuid)
    }
  ]
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "description": "Example string",
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true,
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true,
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.patch("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "description": "Example string",
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True,
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'description' => 'Example string',
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true,
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name for this database connection
  "description"?: string // Description of the database and its purpose (Optional)
  "databaseType":  // Type of database: PostgreSQL, MySQL, MSSQL, Oracle, SynxDB, or MaiAgent

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrlMasked": string
  "includeTables"?: object // Optional list of tables to include. Format: {"tables": ["table1", "table2"]}. For MaiAgent type, this is auto-populated from uploaded files. (Optional)
  "isActive"?: boolean // When disabled, this database will not be used in Text-to-SQL queries (Optional)
  "status": 
  {
  }
  "deletedAt": string (timestamp)
  "tables": [
    {
      "id": string (uuid)
      "tableName": string // Name of the table in the database
      "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
      "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
      "status": 
      {
      }
      "errorMessage": string // Error details if table creation or deletion failed
      "sourceFile": 
      {
        "id": string (uuid)
        "name": string
        "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
      }
      "columns": [
        {
          "id": string (uuid)
          "columnName": string
          "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
          "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
          "isPrimaryKey"?: boolean // Optional
          "isNullable"?: boolean // Optional
          "createdAt": string (timestamp)
          "updatedAt": string (timestamp)
        }
      ]
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "chatbots": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "description": "Response string",
  "databaseType": {},
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "status": {},
  "deletedAt": "Response string",
  "tables": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "tableName": "Response string",
      "sheetName": "Response string",
      "description": "Response string",
      "status": {},
      "errorMessage": "Response string",
      "sourceFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "Response string",
        "isFromKnowledgeBase": false
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "columnName": "Response string",
          "columnType": "Response string",
          "description": "Response string",
          "isPrimaryKey": false,
          "isNullable": false,
          "createdAt": "Response string",
          "updatedAt": "Response string"
        }
      ],
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string"
    }
  ],
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string"
  },
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Delete SQL Database <a href="#sql-databases-destroy" id="sql-databases-destroy"></a>

DELETE `/api/v1/sql-databases/{id}/`

#### Parameters

| Parameter | Required | Type   | Description                                  |
| --------- | -------- | ------ | -------------------------------------------- |
| `id`      | ✅        | string | A UUID string identifying this SQL Database. |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request payload
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

| Status Code | Description                                                        |
| ----------- | ------------------------------------------------------------------ |
| 204         | No response body                                                   |
| 4XX         | Error response; X-Error-Code carries its code (see "Error codes"). |

***

### Test Database Connection <a href="#sql-databases-test-connection-create" id="sql-databases-test-connection-create"></a>

POST `/api/v1/sql-databases/{id}/test-connection/`

#### Parameters

| Parameter | Required | Type   | Description                                  |
| --------- | -------- | ------ | -------------------------------------------- |
| `id`      | ✅        | string | A UUID string identifying this SQL Database. |

#### Request Body

**Request Parameters**

| Field        | Type                                                              | Required | Description                                                                                                              |
| ------------ | ----------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| databaseType | string (enum: postgresql, mysql, maiagent, oracle, mssql, synxdb) | Yes      | `postgresql`: PostgreSQL ; `mysql`: MySQL ; `maiagent`: MaiAgent ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl  | string                                                            | Yes      |                                                                                                                          |

**Request Schema**

```typescript
{
  "databaseType": string (enum: postgresql, mysql, maiagent, oracle, mssql, synxdb) // * `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  "databaseUrl": string
}
```

**Request Example**

```json
{
  "databaseType": "postgresql",
  "databaseUrl": "example string"
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/test-connection/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "databaseType": "postgresql",
    "databaseUrl": "example string"
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "databaseType": "postgresql",
    "databaseUrl": "example string"
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/test-connection/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/test-connection/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
    "databaseType": "postgresql",
    "databaseUrl": "example string"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/test-connection/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'databaseType' => 'postgresql',
            'databaseUrl' => 'example string'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

**Status code: 200**

**Response Schema**

```typescript
{
  "success"?: boolean // optional
  "message"?: string // optional
}
```

**Response Example**

```json
{
  "success": false,
  "message": "response string"
}
```

**Status code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Upload Files to Database <a href="#sql-databases-upload-files-create" id="sql-databases-upload-files-create"></a>

POST `/api/v1/sql-databases/{id}/upload-files/`

#### Parameters

| Parameter | Required | Type   | Description                                  |
| --------- | -------- | ------ | -------------------------------------------- |
| `id`      | ✅        | string | A UUID string identifying this SQL Database. |

#### Request Body

**Request Parameters**

| Field | Type           | Required | Description |
| ----- | -------------- | -------- | ----------- |
| files | array\[object] | Yes      |             |

**Request Schema**

```typescript
{
  "files": [
    {
      "file": string // File path from presigned URL upload (e.g., media/chatbotfiles/xxx/file.csv)
      "filename": string // Original filename
      "size": integer // File size in bytes
    }
  ]
}
```

**Request Example**

```json
{
  "files": [
    {
      "file": "media/chatbotfiles/xxx/data.csv",
      "filename": "data.csv",
      "size": 1024
    },
    {
      "file": "media/chatbotfiles/xxx/report.xlsx",
      "filename": "report.xlsx",
      "size": 2048
    }
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/upload-files/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "files": [
      {
        "file": "media/chatbotfiles/xxx/data.csv",
        "filename": "data.csv",
        "size": 1024
      },
      {
        "file": "media/chatbotfiles/xxx/report.xlsx",
        "filename": "report.xlsx",
        "size": 2048
      }
    ]
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "files": [
      {
        "file": "media/chatbotfiles/xxx/data.csv",
        "filename": "data.csv",
        "size": 1024
      },
      {
        "file": "media/chatbotfiles/xxx/report.xlsx",
        "filename": "report.xlsx",
        "size": 2048
      }
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/upload-files/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/upload-files/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
    "files": [
        {
            "file": "media/chatbotfiles/xxx/data.csv",
            "filename": "data.csv",
            "size": 1024
        },
        {
            "file": "media/chatbotfiles/xxx/report.xlsx",
            "filename": "report.xlsx",
            "size": 2048
        }
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/550e8400-e29b-41d4-a716-446655440000/upload-files/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'files' => [
                [
                    'file' => 'media/chatbotfiles/xxx/data.csv',
                    'filename' => 'data.csv',
                    'size' => 1024
                ],
                [
                    'file' => 'media/chatbotfiles/xxx/report.xlsx',
                    'filename' => 'report.xlsx',
                    'size' => 2048
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

**Status code: 201**

**Response Schema**

```typescript
{
  "message"?: string // optional
  "filesCount"?: integer // optional
  "fileIds"?: [ // optional
    string (uuid)
  ]
}
```

**Response Example**

```json
{
  "message": "response string",
  "filesCount": 456,
  "fileIds": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

**Status code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Batch Delete SQL Databases <a href="#sql-databases-batch-delete-create" id="sql-databases-batch-delete-create"></a>

POST `/api/v1/sql-databases/batch-delete/`

#### Request Body

**Request Parameters**

| Field | Type           | Required | Description |
| ----- | -------------- | -------- | ----------- |
| ids   | array\[string] | Yes      |             |

**Request Schema**

```typescript
{
  "ids": [
    string (uuid)
  ]
}
```

**Request Example**

```json
{
  "ids": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/batch-delete/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request payload
const data = {
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/batch-delete/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/batch-delete/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request payload
data = {
    "ids": [
        "550e8400-e29b-41d4-a716-446655440000"
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/batch-delete/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'ids' => [
                '550e8400-e29b-41d4-a716-446655440000'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

| Status Code | Description                                                        |
| ----------- | ------------------------------------------------------------------ |
| 204         | No response body                                                   |
| 4XX         | Error response; X-Error-Code carries its code (see "Error codes"). |

***

### List Tables <a href="#sql-databases-tables-list" id="sql-databases-tables-list"></a>

GET `/api/v1/sql-databases/{sqlDatabasePk}/tables/`

#### Parameters

| Parameter       | Required | Type    | Description                                                                                                                                             |
| --------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sqlDatabasePk` | ✅        | string  |                                                                                                                                                         |
| `page`          | ❌        | integer | A page number within the paginated result set.                                                                                                          |
| `pageSize`      | ❌        | integer | Number of results to return per page.                                                                                                                   |
| `query`         | ❌        | string  |                                                                                                                                                         |
| `status`        | ❌        | string  | \`pending\`: Pending ; \`processing\`: Processing ; \`success\`: Success ; \`failed\`: Failed ; \`dropping\`: Dropping ; \`drop\_failed\`: Drop Failed; |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/?page=1&pageSize=1&query=example&status=drop_failed" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/?page=1&pageSize=1&query=example&status=drop_failed", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/?page=1&pageSize=1&query=example&status=drop_failed"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/?page=1&pageSize=1&query=example&status=drop_failed", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

**Status code: 200**

**Response Schema**

```typescript
{
  "count": integer
  "next"?: string (uri) // optional
  "previous"?: string (uri) // optional
  "results": [
    {
      "id": string (uuid)
      "tableName": string // Name of the table in the database
      "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
      "description"?: string // Description of the table and its data for better Text-to-SQL understanding (optional)
      "status": 
      {
      }
      "errorMessage": string // Error details if table creation or deletion failed
      "sourceFile": 
      {
        "id": string (uuid)
        "name": string
        "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
      }
      "columns": [
        {
          "id": string (uuid)
          "columnName": string
          "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (optional)
          "description"?: string // Description of the column for better Text-to-SQL understanding (optional)
          "isPrimaryKey"?: boolean // optional
          "isNullable"?: boolean // optional
          "createdAt": string (timestamp)
          "updatedAt": string (timestamp)
        }
      ]
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**Response Example**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "tableName": "response string",
      "sheetName": "response string",
      "description": "response string",
      "status": {},
      "errorMessage": "response string",
      "sourceFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "response string",
        "isFromKnowledgeBase": false
      },
      "columns": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "columnName": "response string",
          "columnType": "response string",
          "description": "response string",
          "isPrimaryKey": false,
          "isNullable": false,
          "createdAt": "response string",
          "updatedAt": "response string"
        }
      ],
      "createdAt": "response string",
      "updatedAt": "response string"
    }
  ]
}
```

**Status code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Create Table <a href="#sql-databases-tables-create" id="sql-databases-tables-create"></a>

POST `/api/v1/sql-databases/{sqlDatabasePk}/tables/`

#### Parameters

| Parameter       | Required | Type   | Description |
| --------------- | -------- | ------ | ----------- |
| `sqlDatabasePk` | ✅        | string |             |

#### Request Body

**Request Parameters**

| Field       | Type   | Required | Description                                                                |
| ----------- | ------ | -------- | -------------------------------------------------------------------------- |
| tableName   | string | Yes      | Name of the table in the database                                          |
| description | string | No       | Description of the table and its data for better Text-to-SQL understanding |

**Request Schema**

```typescript
{
  "tableName": string // Name of the table in the database
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
}
```

**Example Request Values**

```json
{
  "tableName": "Example string",
  "description": "Example string"
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableName": "Example string",
    "description": "Example string"
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "tableName": "Example string",
    "description": "Example string"
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "tableName": "Example string",
    "description": "Example string"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'tableName' => 'Example string',
            'description' => 'Example string'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "tableName": string // Name of the table in the database
  "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
  "status": 
  {
  }
  "errorMessage": string // Error details if table creation or deletion failed
  "sourceFile": 
  {
    "id": string (uuid)
    "name": string
    "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
  }
  "columns": [
    {
      "id": string (uuid)
      "columnName": string
      "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
      "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
      "isPrimaryKey"?: boolean // Optional
      "isNullable"?: boolean // Optional
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "tableName": "Response string",
  "sheetName": "Response string",
  "description": "Response string",
  "status": {},
  "errorMessage": "Response string",
  "sourceFile": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string",
    "isFromKnowledgeBase": false
  },
  "columns": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "columnName": "Response string",
      "columnType": "Response string",
      "description": "Response string",
      "isPrimaryKey": false,
      "isNullable": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Get Specific Table <a href="#sql-databases-tables-retrieve" id="sql-databases-tables-retrieve"></a>

GET `/api/v1/sql-databases/{sqlDatabasePk}/tables/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                    |
| --------------- | -------- | ------ | ---------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table. |
| `sqlDatabasePk` | ✅        | string |                                                |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "tableName": string // Name of the table in the database
  "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
  "status": 
  {
  }
  "errorMessage": string // Error details if table creation or deletion failed
  "sourceFile": 
  {
    "id": string (uuid)
    "name": string
    "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
  }
  "columns": [
    {
      "id": string (uuid)
      "columnName": string
      "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
      "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
      "isPrimaryKey"?: boolean // Optional
      "isNullable"?: boolean // Optional
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "tableName": "Response string",
  "sheetName": "Response string",
  "description": "Response string",
  "status": {},
  "errorMessage": "Response string",
  "sourceFile": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string",
    "isFromKnowledgeBase": false
  },
  "columns": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "columnName": "Response string",
      "columnType": "Response string",
      "description": "Response string",
      "isPrimaryKey": false,
      "isNullable": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Update Table <a href="#sql-databases-tables-update" id="sql-databases-tables-update"></a>

PUT `/api/v1/sql-databases/{sqlDatabasePk}/tables/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                    |
| --------------- | -------- | ------ | ---------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table. |
| `sqlDatabasePk` | ✅        | string |                                                |

#### Request Body

**Request Parameters**

| Field       | Type   | Required | Description                                                                |
| ----------- | ------ | -------- | -------------------------------------------------------------------------- |
| tableName   | string | Yes      | Name of the table in the database                                          |
| description | string | No       | Description of the table and its data for better Text-to-SQL understanding |

**Example Request Schema**

```typescript
{
  "tableName": string // Name of the table in the database
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
}
```

**Example Request Values**

```json
{
  "tableName": "Example string",
  "description": "Example string"
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableName": "Example string",
    "description": "Example string"
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "tableName": "Example string",
    "description": "Example string"
  };

axios.put("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "tableName": "Example string",
    "description": "Example string"
}

response = requests.put(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'tableName' => 'Example string',
            'description' => 'Example string'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "tableName": string // Name of the table in the database
  "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
  "status": 
  {
  }
  "errorMessage": string // Error details if table creation or deletion failed
  "sourceFile": 
  {
    "id": string (uuid)
    "name": string
    "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
  }
  "columns": [
    {
      "id": string (uuid)
      "columnName": string
      "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
      "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
      "isPrimaryKey"?: boolean // Optional
      "isNullable"?: boolean // Optional
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "tableName": "Response string",
  "sheetName": "Response string",
  "description": "Response string",
  "status": {},
  "errorMessage": "Response string",
  "sourceFile": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string",
    "isFromKnowledgeBase": false
  },
  "columns": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "columnName": "Response string",
      "columnType": "Response string",
      "description": "Response string",
      "isPrimaryKey": false,
      "isNullable": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Partially Update Table <a href="#sql-databases-tables-partial-update" id="sql-databases-tables-partial-update"></a>

PATCH `/api/v1/sql-databases/{sqlDatabasePk}/tables/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                    |
| --------------- | -------- | ------ | ---------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table. |
| `sqlDatabasePk` | ✅        | string |                                                |

#### Request Body

**Request Parameters**

| Field       | Type   | Required | Description                                                                |
| ----------- | ------ | -------- | -------------------------------------------------------------------------- |
| tableName   | string | No       | Name of the table in the database                                          |
| description | string | No       | Description of the table and its data for better Text-to-SQL understanding |

**Example Request Schema**

```typescript
{
  "tableName"?: string // Name of the table in the database (Optional)
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
}
```

**Example Request Values**

```json
{
  "tableName": "Example string",
  "description": "Example string"
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tableName": "Example string",
    "description": "Example string"
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "tableName": "Example string",
    "description": "Example string"
  };

axios.patch("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "tableName": "Example string",
    "description": "Example string"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'tableName' => 'Example string',
            'description' => 'Example string'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "tableName": string // Name of the table in the database
  "sheetName": string // Name of the source worksheet/sheet this table was created from. Empty for tables created before this field was added.
  "description"?: string // Description of the table and its data for better Text-to-SQL understanding (Optional)
  "status": 
  {
  }
  "errorMessage": string // Error details if table creation or deletion failed
  "sourceFile": 
  {
    "id": string (uuid)
    "name": string
    "isFromKnowledgeBase": boolean // Determine if the source file originated from a knowledge base upload.

Returns True if the file was uploaded via knowledge base,
False if uploaded directly to the database.
  }
  "columns": [
    {
      "id": string (uuid)
      "columnName": string
      "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
      "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
      "isPrimaryKey"?: boolean // Optional
      "isNullable"?: boolean // Optional
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "tableName": "Response string",
  "sheetName": "Response string",
  "description": "Response string",
  "status": {},
  "errorMessage": "Response string",
  "sourceFile": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Response string",
    "isFromKnowledgeBase": false
  },
  "columns": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "columnName": "Response string",
      "columnType": "Response string",
      "description": "Response string",
      "isPrimaryKey": false,
      "isNullable": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ],
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Delete Table <a href="#sql-databases-tables-destroy" id="sql-databases-tables-destroy"></a>

DELETE `/api/v1/sql-databases/{sqlDatabasePk}/tables/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                    |
| --------------- | -------- | ------ | ---------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table. |
| `sqlDatabasePk` | ✅        | string |                                                |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request body (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

| Status Code | Description                                                        |
| ----------- | ------------------------------------------------------------------ |
| 204         | No response body                                                   |
| 4XX         | Error response; X-Error-Code carries its code (see "Error codes"). |

***

### Batch Delete Tables <a href="#sql-databases-tables-batch-delete-create" id="sql-databases-tables-batch-delete-create"></a>

POST `/api/v1/sql-databases/{sqlDatabasePk}/tables/batch-delete/`

#### Parameters

| Parameter Name  | Required | Type   | Description |
| --------------- | -------- | ------ | ----------- |
| `sqlDatabasePk` | ✅        | string |             |

#### Request Body

**Request Parameters**

| Field | Type           | Required | Description |
| ----- | -------------- | -------- | ----------- |
| ids   | array\[string] | Yes      |             |

**Example Request Schema**

```typescript
{
  "ids": [
    string (uuid)
  ]
}
```

**Example Request Values**

```json
{
  "ids": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/batch-delete/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/batch-delete/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/batch-delete/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "ids": [
        "550e8400-e29b-41d4-a716-446655440000"
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/batch-delete/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'ids' => [
                '550e8400-e29b-41d4-a716-446655440000'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

| Status Code | Description                                                        |
| ----------- | ------------------------------------------------------------------ |
| 204         | No response body                                                   |
| 4XX         | Error response; X-Error-Code carries its code (see "Error codes"). |

***

### List Columns <a href="#sql-databases-tables-columns-list" id="sql-databases-tables-columns-list"></a>

GET `/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/`

#### Parameters

| Parameter Name  | Required | Type   | Description |
| --------------- | -------- | ------ | ----------- |
| `sqlDatabasePk` | ✅        | string |             |
| `tablePk`       | ✅        | string |             |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
[
  {
    "id": string (uuid)
    "columnName": string
    "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
    "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
    "isPrimaryKey"?: boolean // Optional
    "isNullable"?: boolean // Optional
    "createdAt": string (timestamp)
    "updatedAt": string (timestamp)
  }
]
```

**Example Response Values**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "columnName": "Response string",
    "columnType": "Response string",
    "description": "Response string",
    "isPrimaryKey": false,
    "isNullable": false,
    "createdAt": "Response string",
    "updatedAt": "Response string"
  }
]
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Get Specific Column <a href="#sql-databases-tables-columns-retrieve" id="sql-databases-tables-columns-retrieve"></a>

GET `/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                           |
| --------------- | -------- | ------ | ----------------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table Column. |
| `sqlDatabasePk` | ✅        | string |                                                       |
| `tablePk`       | ✅        | string |                                                       |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "columnName": string
  "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
  "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
  "isPrimaryKey"?: boolean // Optional
  "isNullable"?: boolean // Optional
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "columnName": "Response string",
  "columnType": "Response string",
  "description": "Response string",
  "isPrimaryKey": false,
  "isNullable": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Update Column <a href="#sql-databases-tables-columns-update" id="sql-databases-tables-columns-update"></a>

PUT `/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                           |
| --------------- | -------- | ------ | ----------------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table Column. |
| `sqlDatabasePk` | ✅        | string |                                                       |
| `tablePk`       | ✅        | string |                                                       |

#### Request Body

**Request Parameters**

| Field        | Type    | Required | Description                                                    |
| ------------ | ------- | -------- | -------------------------------------------------------------- |
| columnName   | string  | Yes      |                                                                |
| columnType   | string  | No       | Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP)    |
| description  | string  | No       | Description of the column for better Text-to-SQL understanding |
| isPrimaryKey | boolean | No       |                                                                |
| isNullable   | boolean | No       |                                                                |

**Example Request Schema**

```typescript
{
  "columnName": string
  "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
  "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
  "isPrimaryKey"?: boolean // Optional
  "isNullable"?: boolean // Optional
}
```

**Example Request Values**

```json
{
  "columnName": "Example string",
  "columnType": "Example string",
  "description": "Example string",
  "isPrimaryKey": true,
  "isNullable": true
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "columnName": "Example string",
    "columnType": "Example string",
    "description": "Example string",
    "isPrimaryKey": true,
    "isNullable": true
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "columnName": "Example string",
    "columnType": "Example string",
    "description": "Example string",
    "isPrimaryKey": true,
    "isNullable": true
  };

axios.put("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "columnName": "Example string",
    "columnType": "Example string",
    "description": "Example string",
    "isPrimaryKey": True,
    "isNullable": True
}

response = requests.put(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'columnName' => 'Example string',
            'columnType' => 'Example string',
            'description' => 'Example string',
            'isPrimaryKey' => true,
            'isNullable' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "columnName": string
  "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
  "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
  "isPrimaryKey"?: boolean // Optional
  "isNullable"?: boolean // Optional
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "columnName": "Response string",
  "columnType": "Response string",
  "description": "Response string",
  "isPrimaryKey": false,
  "isNullable": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Partially Update Column <a href="#sql-databases-tables-columns-partial-update" id="sql-databases-tables-columns-partial-update"></a>

PATCH `/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/{id}/`

#### Parameters

| Parameter Name  | Required | Type   | Description                                           |
| --------------- | -------- | ------ | ----------------------------------------------------- |
| `id`            | ✅        | string | A UUID string identifying this Database Table Column. |
| `sqlDatabasePk` | ✅        | string |                                                       |
| `tablePk`       | ✅        | string |                                                       |

#### Request Body

**Request Parameters**

| Field        | Type    | Required | Description                                                    |
| ------------ | ------- | -------- | -------------------------------------------------------------- |
| columnName   | string  | No       |                                                                |
| columnType   | string  | No       | Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP)    |
| description  | string  | No       | Description of the column for better Text-to-SQL understanding |
| isPrimaryKey | boolean | No       |                                                                |
| isNullable   | boolean | No       |                                                                |

**Example Request Schema**

```typescript
{
  "columnName"?: string // Optional
  "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (Optional)
  "description"?: string // Description of the column for better Text-to-SQL understanding (Optional)
  "isPrimaryKey"?: boolean // Optional
  "isNullable"?: boolean // Optional
}
```

**Example Request Values**

```json
{
  "columnName": "Example string",
  "columnType": "Example string",
  "description": "Example string",
  "isPrimaryKey": true,
  "isNullable": true
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API call example (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "columnName": "Example string",
    "columnType": "Example string",
    "description": "Example string",
    "isPrimaryKey": true,
    "isNullable": true
  }'

# Make sure to replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "columnName": "Example string",
    "columnType": "Example string",
    "description": "Example string",
    "isPrimaryKey": true,
    "isNullable": true
  };

axios.patch("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request error:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "columnName": "example string",
    "columnType": "example string",
    "description": "example string",
    "isPrimaryKey": True,
    "isNullable": True
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request error:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/sql-databases/{sqlDatabasePk}/tables/{tablePk}/columns/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'columnName' => 'example string',
            'columnType' => 'example string',
            'description' => 'example string',
            'isPrimaryKey' => true,
            'isNullable' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request error: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response

**Status Code: 200**

**Response Schema Example**

```typescript
{
  "id": string (uuid)
  "columnName": string
  "columnType"?: string // Data type of the column (e.g., VARCHAR, INTEGER, TIMESTAMP) (optional)
  "description"?: string // Description of the column for better Text-to-SQL understanding (optional)
  "isPrimaryKey"?: boolean // Optional
  "isNullable"?: boolean // Optional
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "columnName": "response string",
  "columnType": "response string",
  "description": "response string",
  "isPrimaryKey": false,
  "isNullable": false,
  "createdAt": "response string",
  "updatedAt": "response string"
}
```

**Status Code: 4XX - Error response; X-Error-Code carries its code (see "Error codes").**

***

### Test Database Connection (General) <a href="#database-connection-test-create" id="database-connection-test-create"></a>

POST `/api/v1/database-connection/test/`

#### Request Body

**Request Parameters**

| Field        | Type   | Required | Description                                                                                                                                                      |
| ------------ | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| databaseType | object | Yes      | Database type (excluding the type used internally by MaiAgent) `postgresql`: PostgreSQL ; `mysql`: MySQL ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl  | string | Yes      | Database connection string                                                                                                                                       |

**Example Request Schema**

```typescript
{
  "databaseType":  // Database type (excluding the type used internally by MaiAgent)

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string
}
```

**Example Request Values**

```json
{
  "database_type": "postgresql",
  "database_url": "postgresql://user:password@localhost:5432/dbname"
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/database-connection/test/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "database_type": "postgresql",
    "database_url": "postgresql://user:password@localhost:5432/dbname"
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "database_type": "postgresql",
    "database_url": "postgresql://user:password@localhost:5432/dbname"
  };

axios.post("https://api.maiagent.ai/api/v1/database-connection/test/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/database-connection/test/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "database_type": "postgresql",
    "database_url": "postgresql://user:password@localhost:5432/dbname"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/database-connection/test/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'database_type' => 'postgresql',
            'database_url' => 'postgresql://user:password@localhost:5432/dbname'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "status":  // Connection status

* `success` - success
* `failed` - failed
  {
  }
  "responseTime"?: number (double) // Response time (seconds) (Optional)
  "message"?: string // Success message (Optional)
  "errorMessage"?: string // Error message (Optional)
}
```

**Example Response Values**

```json
{
  "status": "success",
  "response_time": 0.123,
  "message": "Successfully connected to PostgreSQL database"
}
```

**Status Code: 400**

**Example Response Schema**

```typescript
{
  "detail"?: string // Optional
}
```

**Example Response Values**

```json
{
  "status": "success",
  "response_time": 0.123,
  "message": "Successfully connected to PostgreSQL database"
}
```

***

### List Database Connection String Examples <a href="#database-examples-list" id="database-examples-list"></a>

GET `/api/v1/database-examples/`

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/database-examples/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/database-examples/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/database-examples/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/database-examples/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
[
  {
    "databaseType"?:  // Database type option

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB (Optional)
    {
    }
    "databaseTypeExample": string // For example: postgresql://db_user:db_password@db_ip:db_port/db_name
  }
]
```

**Example Response Values**

```json
[
  {
    "databaseType": {},
    "databaseTypeExample": "Response string"
  }
]
```

**Status Code: 401**

**Example Response Schema**

```typescript
{
  "detail"?: string // Optional
}
```

**Example Response Values**

```json
{
  "detail": "Response string"
}
```

***

### Retrieve a Specific Connection String Example <a href="#database-examples-retrieve" id="database-examples-retrieve"></a>

GET `/api/v1/database-examples/{id}/`

#### Parameters

| Parameter | Required | Type   | Description                                                 |
| --------- | -------- | ------ | ----------------------------------------------------------- |
| `id`      | ✅        | string | A UUID string identifying this Database Connection Example. |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# Example API call (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/database-examples/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/database-examples/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/database-examples/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/database-examples/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "databaseType"?:  // Database type option

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB (Optional)
  {
  }
  "databaseTypeExample": string // For example: postgresql://db_user:db_password@db_ip:db_port/db_name
}
```

**Example Response Values**

```json
{
  "databaseType": {},
  "databaseTypeExample": "Response string"
}
```

***

### List Database Configurations of an AI Assistant <a href="#chatbots-databases-list" id="chatbots-databases-list"></a>

GET `/api/v1/chatbots/{chatbotPk}/databases/`

#### Parameters

| Parameter Name | Required | Type    | Description                                    |
| -------------- | -------- | ------- | ---------------------------------------------- |
| `chatbotPk`    | ✅        | string  | A UUID string identifying this Chatbot ID      |
| `page`         | ❌        | integer | A page number within the paginated result set. |
| `pageSize`     | ❌        | integer | Number of results to return per page.          |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/?page=1&pageSize=1", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "count": integer
  "next"?: string (uri) // Optional
  "previous"?: string (uri) // Optional
  "results": [
    {
      "id": string (uuid)
      "name": string // Display name, for example: Main Business DB, Analytics DB.
      "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
      {
      }
      "databaseUrl": string // Database connection string.
      "databaseUrlMasked": string
      "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
      "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**Example Response Values**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Response string",
      "databaseType": {},
      "databaseUrl": "Response string",
      "databaseUrlMasked": "Response string",
      "includeTables": null,
      "isActive": false,
      "createdAt": "Response string",
      "updatedAt": "Response string"
    }
  ]
}
```

***

### Add Database Configuration to an AI Assistant <a href="#chatbots-databases-create" id="chatbots-databases-create"></a>

POST `/api/v1/chatbots/{chatbotPk}/databases/`

#### Parameters

| Parameter Name | Required | Type   | Description                               |
| -------------- | -------- | ------ | ----------------------------------------- |
| `chatbotPk`    | ✅        | string | A UUID string identifying this Chatbot ID |

#### Request Body

**Request Parameters**

| Field         | Type    | Required | Description                                                                                                                                                                                    |
| ------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name          | string  | Yes      | Display name, for example: Main Business DB, Analytics DB.                                                                                                                                     |
| databaseType  | object  | Yes      | Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent. `postgresql`: PostgreSQL ; `mysql`: MySQL ; `maiagent`: MaiAgent ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl   | string  | Yes      | Database connection string.                                                                                                                                                                    |
| includeTables | object  | No       | Tables to query, formatted as {"tables": \["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed.                                 |
| isActive      | boolean | No       | When inactive, this database is not used for Text-to-SQL queries.                                                                                                                              |

**Example Request Schema**

```typescript
{
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "databaseType": {},
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  };

axios.post("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True
}

response = requests.post(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'databaseType' => new \stdClass(),
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 201**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "databaseUrlMasked": string
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "databaseType": {},
  "databaseUrl": "Response string",
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

***

### Get Specific Database Configuration <a href="#chatbots-databases-retrieve" id="chatbots-databases-retrieve"></a>

GET `/api/v1/chatbots/{chatbotPk}/databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                                    |
| -------------- | -------- | ------ | -------------------------------------------------------------- |
| `chatbotPk`    | ✅        | string | A UUID string identifying this Chatbot ID                      |
| `id`           | ✅        | string | A UUID string identifying this Chatbot Database Configuration. |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "databaseUrlMasked": string
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "databaseType": {},
  "databaseUrl": "Response string",
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

***

### Update Database Configuration <a href="#chatbots-databases-update" id="chatbots-databases-update"></a>

PUT `/api/v1/chatbots/{chatbotPk}/databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                                    |
| -------------- | -------- | ------ | -------------------------------------------------------------- |
| `chatbotPk`    | ✅        | string | A UUID string identifying this Chatbot ID                      |
| `id`           | ✅        | string | A UUID string identifying this Chatbot Database Configuration. |

#### Request Body

**Request Parameters**

| Field         | Type    | Required | Description                                                                                                                                                                                    |
| ------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name          | string  | Yes      | Display name, for example: Main Business DB, Analytics DB.                                                                                                                                     |
| databaseType  | object  | Yes      | Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent. `postgresql`: PostgreSQL ; `mysql`: MySQL ; `maiagent`: MaiAgent ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl   | string  | Yes      | Database connection string.                                                                                                                                                                    |
| includeTables | object  | No       | Tables to query, formatted as {"tables": \["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed.                                 |
| isActive      | boolean | No       | When inactive, this database is not used for Text-to-SQL queries.                                                                                                                              |

**Example Request Schema**

```typescript
{
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "databaseType": {},
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  };

axios.put("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True
}

response = requests.put(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'databaseType' => new \stdClass(),
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "databaseUrlMasked": string
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "databaseType": {},
  "databaseUrl": "Response string",
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

***

### Partially Update Database Configuration <a href="#chatbots-databases-partial-update" id="chatbots-databases-partial-update"></a>

PATCH `/api/v1/chatbots/{chatbotPk}/databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                                    |
| -------------- | -------- | ------ | -------------------------------------------------------------- |
| `chatbotPk`    | ✅        | string | A UUID string identifying this Chatbot ID                      |
| `id`           | ✅        | string | A UUID string identifying this Chatbot Database Configuration. |

#### Request Body

**Request Parameters**

| Field         | Type    | Required | Description                                                                                                                                                                                    |
| ------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name          | string  | No       | Display name, for example: Main Business DB, Analytics DB.                                                                                                                                     |
| databaseType  | object  | No       | Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent. `postgresql`: PostgreSQL ; `mysql`: MySQL ; `maiagent`: MaiAgent ; `oracle`: Oracle ; `mssql`: MSSQL ; `synxdb`: SynxDB; |
| databaseUrl   | string  | No       | Database connection string.                                                                                                                                                                    |
| includeTables | object  | No       | Tables to query, formatted as {"tables": \["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed.                                 |
| isActive      | boolean | No       | When inactive, this database is not used for Text-to-SQL queries.                                                                                                                              |

**Example Request Schema**

```typescript
{
  "name"?: string // Display name, for example: Main Business DB, Analytics DB. (Optional)
  "databaseType"?:  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB (Optional)
  {
  }
  "databaseUrl"?: string // Database connection string. (Optional)
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
}
```

**Example Request Values**

```json
{
  "name": "Example name",
  "databaseType": {},
  "databaseUrl": "Example string",
  "includeTables": null,
  "isActive": true
}
```

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  }'

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// Request body (payload)
const data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": null,
    "isActive": true
  };

axios.patch("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# Request body (payload)
data = {
    "name": "Example name",
    "databaseType": {},
    "databaseUrl": "Example string",
    "includeTables": None,
    "isActive": True
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'Example name',
            'databaseType' => new \stdClass(),
            'databaseUrl' => 'Example string',
            'includeTables' => null,
            'isActive' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

**Status Code: 200**

**Example Response Schema**

```typescript
{
  "id": string (uuid)
  "name": string // Display name, for example: Main Business DB, Analytics DB.
  "databaseType":  // Database type: MySQL, PostgreSQL, MSSQL, Oracle, SynxDB, or MaiAgent.

* `postgresql` - PostgreSQL
* `mysql` - MySQL
* `maiagent` - MaiAgent
* `oracle` - Oracle
* `mssql` - MSSQL
* `synxdb` - SynxDB
  {
  }
  "databaseUrl": string // Database connection string.
  "databaseUrlMasked": string
  "includeTables"?: object // Tables to query, formatted as {"tables": ["table1", "table2"]}. The MaiAgent type reads them from uploaded files automatically, so no manual setup is needed. (Optional)
  "isActive"?: boolean // When inactive, this database is not used for Text-to-SQL queries. (Optional)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**Example Response Values**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Response string",
  "databaseType": {},
  "databaseUrl": "Response string",
  "databaseUrlMasked": "Response string",
  "includeTables": null,
  "isActive": false,
  "createdAt": "Response string",
  "updatedAt": "Response string"
}
```

***

### Delete Database Configuration <a href="#chatbots-databases-destroy" id="chatbots-databases-destroy"></a>

DELETE `/api/v1/chatbots/{chatbotPk}/databases/{id}/`

#### Parameters

| Parameter Name | Required | Type   | Description                                                    |
| -------------- | -------- | ------ | -------------------------------------------------------------- |
| `chatbotPk`    | ✅        | string | A UUID string identifying this Chatbot ID                      |
| `id`           | ✅        | string | A UUID string identifying this Chatbot Database Configuration. |

#### Code Examples

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API Call Example (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# Replace YOUR_API_KEY and verify the request data before running.
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// Set request headers
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// Request body (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('Response received successfully:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('Request failed:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("Response received successfully:")
    print(response.json())
except Exception as e:
    print("Request failed:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/chatbots/550e8400-e29b-41d4-a716-446655440000/databases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "Response received successfully:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'Request failed: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### Response Body

| Status Code | Description      |
| ----------- | ---------------- |
| 204         | No response body |

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/api/en/api-reference/zi-liao-ku.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
