# Database

The "Database" section facilitates the management of databases, offering endpoints for creating, deleting, updating, and retrieving database information.

Databases are only created with the Kraud.Cloud provider. Currently only Maria, Mongo, Postgres, Redis can be created.

## Create database

<mark style="color:green;">`POST`</mark> `{{BASE_URL}}/api/databases`

Database Creation. Currently, only ( Mongo, Maria, Postgres, Redis ) can be created.

#### Path Parameters

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| team<mark style="color:red;">\*</mark>    | String | Team ID     |
| project<mark style="color:red;">\*</mark> | String | Project ID  |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| database<mark style="color:red;">\*</mark> | Object |             |

{% tabs %}
{% tab title="201: Created " %}

```json
{
    "region": {
        "datacenter": {
            "name": "berlin",
            "displayName": "Berlin"
        },
        "physicalLocation": "Germany"
    },
    "image": {
        "version": {
            "name": "4_2_23",
            "displayName": "version 4.2.23"
        },
        "distribution": "MongoDB"
    },
    "attestationId": "",
    "port": "27017",
    "status": 0,
    "_id": "6548ef92d7be320564945169",
    "name": "kraud-cloud-mongodb-1vcpu-1gb-berlin-01",
    "provider": "6548a383e2442d14b6bf968c",
    "size": "6548a383e2442d14b6bf9728",
    "price": "6548a383e2442d14b6bf96dc",
    "owner": {
        "_id": "6548a41138406c14db33b606",
        "name": "John Doe"
    },
    "project": "6548a41f38406c14db33b62c",
    "team": "6548a41f38406c14db33b61e",
    "ipConfigurations": [],
    "createdAt": "2023-11-06T13:52:18.353Z",
    "updatedAt": "2023-11-06T13:52:18.353Z"
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>Request payload</summary>

```json
{
    "team": "6548a41f38406c14db33b61e",
    "project": "6548a41f38406c14db33b62c",
    "name": "kraud-cloud-mongodb-1vcpu-1gb-berlin-01",
    "provider": "6548a383e2442d14b6bf968c",
    "cloudProvider": "6548a383e2442d14b6bf9685",
    "type": "mongo",
    "size": "6548a383e2442d14b6bf9728",
    "price": "6548a383e2442d14b6bf96dc",
    "region": {
        "physicalLocation": "Germany",
        "datacenter": {
            "name": "berlin",
            "displayName": "Berlin"
        }
    },
    "image": {
        "distribution": "MongoDB",
        "version": {
            "name": "4_2_23",
            "displayName": "version 4.2.23"
        }
    }
}
```

</details>

***

## Get databases

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/teams/{team}/projects/{project}/databases`

Get all active databases for a specific project.

#### Path Parameters

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| team<mark style="color:red;">\*</mark>    | String | Team ID     |
| project<mark style="color:red;">\*</mark> | String | Project ID  |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
[
    {
        "_id": "6548ef92d7be320564945169",
        "region": {
            "datacenter": {
                "name": "berlin",
                "displayName": "Berlin"
            },
            "physicalLocation": "Germany"
        },
        "image": {
            "version": {
                "name": "4_2_23",
                "displayName": "version 4.2.23"
            },
            "distribution": "MongoDB"
        },
        "attestationId": "35355142-bffe-426a-8193-947c30ba57ec",
        "port": "27017",
        "status": 1,
        "name": "kraud-cloud-mongodb-1vcpu-1gb-berlin-01",
        "provider": {
            "_id": "6548a383e2442d14b6bf968c",
            "type": "db",
            "isDisabled": false,
            "cloudProvider": {
                "_id": "6548a383e2442d14b6bf9685",
                "name": "Kraud.Cloud",
                "isDisabled": false
            }
        },
        "size": {
            "_id": "6548a383e2442d14b6bf9728",
            "provider": "6548a383e2442d14b6bf968c",
            "location": "berlin",
            "name": "Standart_berlin_1_1_15",
            "vCPUs": 1,
            "memoryGB": 1,
            "spaceGB": 15,
            "group": 0
        },
        "price": {
            "_id": "6548a383e2442d14b6bf96dc",
            "provider": "6548a383e2442d14b6bf968c",
            "locationName": "berlin",
            "sizeName": "Standart_berlin_1_1_15",
            "imageName": "MongoDB",
            "pricePerHour": 0.0223,
            "pricePerMonth": 15,
            "currencyCode": "EUR",
            "createdAt": "2023-11-06T08:27:47.129Z",
            "updatedAt": "2023-11-06T08:27:47.129Z"
        },
        "owner": "6548a41138406c14db33b606",
        "project": "6548a41f38406c14db33b62c",
        "team": "6548a41f38406c14db33b61e",
        "ipConfigurations": [
            {
                "_id": "6548efa1d7be32056494518b",
                "type": "public",
                "method": "Dynamic",
                "version": "IPv4",
                "address": "185.112.181.100"
            }
        ],
        "createdAt": "2023-11-06T13:52:18.353Z",
        "updatedAt": "2023-11-06T13:52:33.477Z",
        "attestation": null
    }
]
```

{% endtab %}
{% endtabs %}

## Get database by ID

<mark style="color:blue;">`GET`</mark> `{{BASE_URL}}/api/databases/{id}`

Get a specific database by unique id.

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | Database ID |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "_id": "6548ef92d7be320564945169",
    "region": {
        "datacenter": {
            "name": "berlin",
            "displayName": "Berlin"
        },
        "physicalLocation": "Germany"
    },
    "image": {
        "version": {
            "name": "4_2_23",
            "displayName": "version 4.2.23"
        },
        "distribution": "MongoDB"
    },
    "attestationId": "35355142-bffe-426a-8193-947c30ba57ec",
    "port": "27017",
    "status": 2,
    "name": "kraud-cloud-mongodb-1vcpu-1gb-berlin-01",
    "provider": {
        "_id": "6548a383e2442d14b6bf968c",
        "type": "db",
        "isDisabled": false,
        "cloudProvider": {
            "_id": "6548a383e2442d14b6bf9685",
            "name": "Kraud.Cloud",
            "isDisabled": false
        }
    },
    "size": {
        "_id": "6548a383e2442d14b6bf9728",
        "provider": "6548a383e2442d14b6bf968c",
        "location": "berlin",
        "name": "Standart_berlin_1_1_15",
        "vCPUs": 1,
        "memoryGB": 1,
        "spaceGB": 15,
        "group": 0
    },
    "price": {
        "_id": "6548a383e2442d14b6bf96dc",
        "provider": "6548a383e2442d14b6bf968c",
        "locationName": "berlin",
        "sizeName": "Standart_berlin_1_1_15",
        "imageName": "MongoDB",
        "pricePerHour": 0.0223,
        "pricePerMonth": 15,
        "currencyCode": "EUR",
        "createdAt": "2023-11-06T08:27:47.129Z",
        "updatedAt": "2023-11-06T08:27:47.129Z"
    },
    "owner": "6548a41138406c14db33b606",
    "project": {
        "_id": "6548a41f38406c14db33b62c",
        "name": "first-project",
        "description": "Update your project information under Settings",
        "environment": "Development",
        "purpose": "Just trying out Enclaive",
        "isDefault": false,
        "icon": 1,
        "owner": "6548a41138406c14db33b606",
        "team": "6548a41f38406c14db33b61e",
        "createdAt": "2023-11-06T08:30:23.552Z",
        "updatedAt": "2023-11-06T08:30:23.552Z"
    },
    "team": {
        "_id": "6548a41f38406c14db33b61e",
        "name": "My Team",
        "email": "john.doe@mail.com",
        "members": [
            {
                "user": "6548a41138406c14db33b606",
                "role": 0
            }
        ],
        "createdAt": "2023-11-06T08:30:23.529Z",
        "updatedAt": "2023-11-06T12:56:06.337Z",
        "billingSettings": "6548e2660919dc0442dc2ec7"
    },
    "ipConfigurations": [
        {
            "_id": "6548efa1d7be32056494518b",
            "type": "public",
            "method": "Dynamic",
            "version": "IPv4",
            "address": "185.112.181.100"
        }
    ],
    "createdAt": "2023-11-06T13:52:18.353Z",
    "updatedAt": "2023-11-06T13:52:33.477Z",
    "attestation": null
}
```

{% endtab %}
{% endtabs %}

## Delete database by ID

<mark style="color:red;">`DELETE`</mark> `{{BASE_URL}}/api/databases/{id}`

Delete a specific application by unique id.

#### Path Parameters

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | String | Database ID |

#### Headers

| Name                                            | Type   | Description  |
| ----------------------------------------------- | ------ | ------------ |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer Token |

{% tabs %}
{% tab title="200: OK " %}

```json
{"message":"Database deleted","dbId":"6548ef92d7be320564945169"}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.enclaive.cloud/enclaive-multi-cloud-platform/developers/api/client-api/manage/database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
