# Scale a MongoDB Cluster Vertically

{% tabs %}
{% tab title="MongoDB Business" %}
DBaaS allows you to scale up and down the size of your database instances. Database instance sizes are managed similarly to [<mark style="color:blue;">Cubes</mark>](https://api.ionos.com/docs/cloud/v6/#tag/Templates); each template exposes a combination of resource sizes that can be assigned to any of your clusters.

{% hint style="info" %}
**Note:** You can get a list of available MongoDB Templates through the [<mark style="color:blue;">API</mark>](https://api.ionos.com/docs/mongodb/v1/#tag/Templates).

```bash
curl --include \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    https://api.ionos.com/databases/mongodb/templates
```

{% endhint %}

To change the template, issue a `PATCH` request containing the MongoDB `templateID`.

### Endpoint

Use the following endpoint to change the template: `https://api.ionos.com/databases/mongodb/clusters/{clusterId}`

{% hint style="info" %}
**Note:** The sample cluster UUID is `d02de413-d5af-4104-a6f9-3a3c2766ee61`.
{% endhint %}

### Request

```bash
curl --include \
    --request PATCH \
    --user "clientname@ionos.com:Mb2.r5oHf-0t" \
    --header "Content-Type: application/json" \
    --data-binary '{
      "properties": {
        "templateID": "6b78ea06-ee0e-4689-998c-fc9c46e781f6"
      }
    }' 
```

### Response

```json
{
  "type": "cluster",
  "id": "d02de413-d5af-4104-a6f9-3a3c2766ee61",
  "metadata": {
    "state": "BUSY",
    "health": "DEGRADED",
    "createdDate": "2020-12-10T12:37:50.000Z",
    "createdBy": "clientname@ionos.com",
    "createdByUserId": "012342f-411f-1eeb-9d07-046c59cc737e"
  },
  "properties": {
    "type": "replicaset",
    "edition": "business",
    "displayName": "Represents database name",
    "location": "de/fra",
    "connections": [
      {
        "datacenterId": "b1432c51-c20a-4f83-876f-c3a8a9e1fbec",
        "lanId": "28",
        "cidrList": [
          "10.1.1.3/24",
          "10.1.1.4/24",
          "10.1.1.5/24"
        ]
      }
    ],
    "templateID": "15c6dd2f-02d2-4987-b439-9a58dd59ecc3",
    "instances": 3,
    "maintenanceWindow": {
      "time": "16:30:59",
      "dayOfTheWeek": "Monday"
    },
    "connectionString": "mongodb+srv://m-65f4a879f126e3c4.mongodb.de-fra.ionos.com"
  }
}
```

The provisioning engine will delete a secondary replica and create a new server of the desired size. Once ready, it will replicate the existing data to this new server via the [<mark style="color:blue;">MongoDB Replication mechanism</mark>](https://www.mongodb.com/docs/manual/replication/). During this procedure, the cluster should operate normally. When the provisioning engine identifies the new server is complete and healthy, it will continue the rollout for every remaining secondary replica up to the primary.

{% hint style="info" %}
**Note:** Be prepared for possible downtime in case of a cluster with only one replica.
{% endhint %}
{% endtab %}

{% tab title="MongoDB Enterprise" %}
{% hint style="info" %}
**Note:** To scale resources in the **Enterprise** edition, please contact [<mark style="color:blue;">IONOS Cloud Support</mark>](https://docs.ionos.com/cloud/support/general-information/contact-information) for assistance with this feature.
{% endhint %}
{% endtab %}
{% endtabs %}
