# Client API: Deployment servers: Databases

> The 16 Client API operations for databases.

Source: https://www.coritan.com/docs/api/reference/client/deployment-servers/servers-databases/

Part of [Deployment servers](/docs/api/reference/client/deployment-servers/).

## Operations

| Method | Path | Summary |
| --- | --- | --- |
| GET | [`/api/v1/client/servers/{uuid}/databases`](#op-get-api-v1-client-servers-uuid-databases) | List databases for a server |
| POST | [`/api/v1/client/servers/{uuid}/databases`](#op-post-api-v1-client-servers-uuid-databases) | Create a new database |
| POST | [`/api/v1/client/servers/{uuid}/databases/{database_id}/query`](#op-post-api-v1-client-servers-uuid-databases-database-id-query) | Run a script of SQL statements, one block of results per statement |
| GET | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables`](#op-get-api-v1-client-servers-uuid-databases-database-id-tables) | The database's tables with their row estimates and sizes |
| DELETE | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}`](#op-delete-api-v1-client-servers-uuid-databases-database-id-tables-table) | Delete a table and its rows |
| GET | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/columns`](#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-columns) | One table's columns and its key |
| GET | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/export.csv`](#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-export-csv) | A table as a CSV file |
| GET | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`](#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-rows) | A page of a table's rows, searched and sorted |
| POST | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`](#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-rows) | Add one row |
| PATCH | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`](#op-patch-api-v1-client-servers-uuid-databases-database-id-tables-table-rows) | Change one row, named by its key |
| POST | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows/delete`](#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-rows-delete) | Delete one row, named by its key |
| POST | [`/api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/truncate`](#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-truncate) | Delete every row of a table and keep the table |
| DELETE | [`/api/v1/client/servers/{uuid}/databases/{db_id}`](#op-delete-api-v1-client-servers-uuid-databases-db-id) | Delete a database |
| GET | [`/api/v1/client/servers/{uuid}/databases/{db_id}/credentials`](#op-get-api-v1-client-servers-uuid-databases-db-id-credentials) | Reveal the stored password for a database on this server |
| POST | [`/api/v1/client/servers/{uuid}/databases/{db_id}/retry`](#op-post-api-v1-client-servers-uuid-databases-db-id-retry) | Retry a failed or stuck database operation |
| POST | [`/api/v1/client/servers/{uuid}/databases/{db_id}/rotate-password`](#op-post-api-v1-client-servers-uuid-databases-db-id-rotate-password) | Rotate database password |

### List databases for a server {#op-get-api-v1-client-servers-uuid-databases}

`GET /api/v1/client/servers/{uuid}/databases`

List databases for a server.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

A `200` response is a list; each item has these fields:

| Field | Type |
| --- | --- |
| `[].id` | integer |
| `[].uuid` | string or null |
| `[].server_id` | integer or null |
| `[].database_host_id` | integer |
| `[].name` | string |
| `[].username` | string |
| `[].password` | string or null |
| `[].remote` | string or null |
| `[].remote_connect_string` | string or null |
| `[].max_connections` | integer |
| `[].host` | string or null |
| `[].port` | integer or null |
| `[].host_name` | string or null |
| `[].uri` | string or null |
| `[].jdbc` | string or null |
| `[].status` | string |
| `[].status_message` | string or null |
| `[].last_error` | string or null |
| `[].operation` | string or null |
| `[].busy` | boolean |
| `[].colocated` | boolean or null |
| `[].db_name` | string or null |
| `[].created_at` | string (date-time) or null |
| `[].updated_at` | string (date-time) or null |

### Create a new database {#op-post-api-v1-client-servers-uuid-databases}

`POST /api/v1/client/servers/{uuid}/databases`

Create a new database.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `Idempotency-Key` | header | string or null | no |

#### Request body

`application/json` (required)

| Field | Type | Required |
| --- | --- | --- |
| `database_host_id` | integer or null | no |
| `name_suffix` | string | no |
| `remote` | string | no |
| `idempotency_key` | string or null | no |

#### Responses

| Status | Meaning |
| --- | --- |
| `201` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

Fields of a `201` response:

| Field | Type |
| --- | --- |
| `id` | integer |
| `uuid` | string or null |
| `server_id` | integer or null |
| `database_host_id` | integer |
| `name` | string |
| `username` | string |
| `password` | string or null |
| `remote` | string or null |
| `remote_connect_string` | string or null |
| `max_connections` | integer |
| `host` | string or null |
| `port` | integer or null |
| `host_name` | string or null |
| `uri` | string or null |
| `jdbc` | string or null |
| `status` | string |
| `status_message` | string or null |
| `last_error` | string or null |
| `operation` | string or null |
| `busy` | boolean |
| `colocated` | boolean or null |
| `db_name` | string or null |
| `created_at` | string (date-time) or null |
| `updated_at` | string (date-time) or null |

### Run a script of SQL statements, one block of results per statement {#op-post-api-v1-client-servers-uuid-databases-database-id-query}

`POST /api/v1/client/servers/{uuid}/databases/{database_id}/query`

Run a script of SQL statements, one block of results per statement.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |

#### Request body

`application/json` (required)

| Field | Type | Required |
| --- | --- | --- |
| `sql` | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### The database's tables with their row estimates and sizes {#op-get-api-v1-client-servers-uuid-databases-database-id-tables}

`GET /api/v1/client/servers/{uuid}/databases/{database_id}/tables`

The database's tables with their row estimates and sizes.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Delete a table and its rows {#op-delete-api-v1-client-servers-uuid-databases-database-id-tables-table}

`DELETE /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}`

Delete a table and its rows.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### One table's columns and its key {#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-columns}

`GET /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/columns`

One table's columns and its key.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### A table as a CSV file {#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-export-csv}

`GET /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/export.csv`

A table as a CSV file.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### A page of a table's rows, searched and sorted {#op-get-api-v1-client-servers-uuid-databases-database-id-tables-table-rows}

`GET /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`

A page of a table's rows, searched and sorted.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `uuid` | path | string | yes |  |
| `database_id` | path | integer | yes |  |
| `table` | path | string | yes |  |
| `limit` | query | integer | no | Default: `50`. |
| `offset` | query | integer | no | Default: `0`. |
| `search` | query | string | no |  |
| `sort` | query | string or null | no |  |
| `direction` | query | string | no | Default: `asc`. |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Add one row {#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-rows}

`POST /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`

Add one row.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Request body

`application/json` (required)

| Field | Type | Required |
| --- | --- | --- |
| `values` | Values | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `201` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Change one row, named by its key {#op-patch-api-v1-client-servers-uuid-databases-database-id-tables-table-rows}

`PATCH /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows`

Change one row, named by its key.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Request body

`application/json` (required)

| Field | Type | Required |
| --- | --- | --- |
| `key` | Key | yes |
| `values` | Values | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Delete one row, named by its key {#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-rows-delete}

`POST /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/rows/delete`

Delete one row, named by its key.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Request body

`application/json` (required)

| Field | Type | Required |
| --- | --- | --- |
| `key` | Key | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Delete every row of a table and keep the table {#op-post-api-v1-client-servers-uuid-databases-database-id-tables-table-truncate}

`POST /api/v1/client/servers/{uuid}/databases/{database_id}/tables/{table}/truncate`

Delete every row of a table and keep the table.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `database_id` | path | integer | yes |
| `table` | path | string | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Delete a database {#op-delete-api-v1-client-servers-uuid-databases-db-id}

`DELETE /api/v1/client/servers/{uuid}/databases/{db_id}`

Delete a database.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `db_id` | path | integer | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Reveal the stored password for a database on this server {#op-get-api-v1-client-servers-uuid-databases-db-id-credentials}

`GET /api/v1/client/servers/{uuid}/databases/{db_id}/credentials`

Reveal the stored password for a database on this server.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `db_id` | path | integer | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

Fields of a `200` response:

| Field | Type |
| --- | --- |
| `id` | integer |
| `uuid` | string or null |
| `server_id` | integer or null |
| `database_host_id` | integer |
| `name` | string |
| `username` | string |
| `password` | string or null |
| `remote` | string or null |
| `remote_connect_string` | string or null |
| `max_connections` | integer |
| `host` | string or null |
| `port` | integer or null |
| `host_name` | string or null |
| `uri` | string or null |
| `jdbc` | string or null |
| `status` | string |
| `status_message` | string or null |
| `last_error` | string or null |
| `operation` | string or null |
| `busy` | boolean |
| `colocated` | boolean or null |
| `db_name` | string or null |
| `created_at` | string (date-time) or null |
| `updated_at` | string (date-time) or null |

### Retry a failed or stuck database operation {#op-post-api-v1-client-servers-uuid-databases-db-id-retry}

`POST /api/v1/client/servers/{uuid}/databases/{db_id}/retry`

Retry a failed or stuck database operation.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `db_id` | path | integer | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |

### Rotate database password {#op-post-api-v1-client-servers-uuid-databases-db-id-rotate-password}

`POST /api/v1/client/servers/{uuid}/databases/{db_id}/rotate-password`

Rotate database password.

Authentication: an access token, sent as `Authorization: Bearer <token>`.

#### Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| `uuid` | path | string | yes |
| `db_id` | path | integer | yes |

#### Responses

| Status | Meaning |
| --- | --- |
| `200` | Success. |
| `422` | The request is not valid. `detail` lists each problem. |
