For the complete documentation index, see llms.txt. This page is also available as Markdown.

MongoDB v2 API Workflows

Use these end-to-end workflows to deploy, connect, operate, and restore resources using the IONOS CLOUD DBaaS MongoDB v2 API.

  • Deploy a MongoDB cluster: Plan your cluster configuration and provision it through to the AVAILABLE state.

  • Connect to your MongoDB cluster: Connect to a provisioned cluster using its connection URI and credentials.

  • Operate a MongoDB cluster: Manage a running cluster with day-to-day operations and deprovision it when no longer needed.

  • Restore from a snapshot: Recover cluster data to a specific point in time using Point-in-Time Recovery (PITR).

  • Verify snapshot data residency: Confirm that cluster snapshots are stored in the expected Object Storage region.

Note: If an operation returns an error, see the response details of each operation for API-specific error codes. For generic HTTP status codes used across IONOS CLOUD APIs, see HTTP Status Codes.

Deploy a MongoDB Cluster

Use this workflow to plan and provision a new MongoDB cluster.

Prerequisites

  • An access token that authenticates your API requests. For more information, see Authentication.

  • The Universally Unique Identifier (UUID) of an existing Virtual Data Center (VDC) (datacenterId) that resides in the same region as your target MongoDB endpoint. To create a VDC, use IONOS CLOUD API.

  • The identifier of a private Local Area Network (LAN) (lanId) within that VDC. The cluster connects to this LAN during provisioning. To create a LAN, use IONOS CLOUD API.

  • Static IP addresses in Classless Inter-Domain Routing (CIDR) notation (instanceAddresses): one for each instance of the cluster, or exactly three for an ENTERPRISE cluster with sharding enabled. Example: 192.168.2.101/24. The range 10.208.0.0/12 is unavailable.

1

Plan Configuration

  1. Find the snapshot location: Specify the region where your cluster's snapshots are stored.

    • Action: Browse the list to identify an available snapshot region.

    • Result: The API returns HTTP 200 with a list of snapshot locations. Note the location value to use in properties.snapshot.location when provisioning the cluster.

    Note: For geographic data safety, choose a snapshot location in a different region from your cluster endpoint.

  2. Select a MongoDB version: Retrieve the list of supported MongoDB versions.

    • Action: Identify the version that matches your requirements.

    • Result: The API returns HTTP 200 with a list of supported MongoDB versions. Each entry includes the version identifier, its lifecycle status (BETA, SUPPORTED, RECOMMENDED, or DEPRECATED), a canUpgradeTo array listing available upgrade paths, and the lifecycle dates creationFreezeDate and deprecationDate. Note the version identifier to use for properties.version when provisioning the cluster.

  3. Choose an edition: Select the edition that matches your requirements.

    • BUSINESS: Retrieve the available instance templates with Retrieve all InstanceTemplates. Each template defines cores, ram, and storageSize. Note the id of the template to use as instanceTemplateId.

    • ENTERPRISE: Define the resources yourself in the instances object (count, ram, cores, and storageSize). Optionally activate sharding (sharding.enabled and sharding.shards, from 2 to 5) and the BI Connector (biConnectorEnabled).

    Note: When sharding is enabled, instances.count is the number of replicas per shard.

2

Provision a Cluster

  1. Create the cluster:

    • Action: Provide the required fields: edition, name, version, connection (containing datacenterId, lanId, and instanceAddresses), snapshot (containing location and retentionDays), maintenanceWindow, and credentials (containing username, password, and database). For BUSINESS, also provide instanceTemplateId and instanceCount. For ENTERPRISE, also provide instances.

    Note:

    • connection.datacenterId and connection.lanId cannot be changed after the cluster is created. Confirm they are correct before submitting this request.

    • The number of instanceAddresses must match the number of instances in the cluster. For an ENTERPRISE cluster with sharding enabled, provide exactly three addresses. This applies regardless of the instance count and the number of shards. They are used by the three config servers that store the cluster metadata, which are separate from the shard instances.

    • logsEnabled and metricsEnabled are optional. Set either to true to activate log or metrics forwarding.

      • logsEnabled requires the IONOS CLOUD Logging Service to be activated on your contract.

      • metricsEnabled requires the IONOS CLOUD Monitoring Service to be activated on your contract. Activating either service incurs extra costs.

Example request bodies for each edition:

{
  "properties": {
    "edition": "ENTERPRISE",
    "name": "cms-prod",
    "version": "7",
    "instances": {
      "count": 3,
      "ram": 8,
      "cores": 4,
      "storageSize": 100
    },
    "connection": {
      "datacenterId": "5a029f4a-72e5-11ec-90d6-0242ac120003",
      "lanId": "2",
      "instanceAddresses": [
        "192.168.2.101/24",
        "192.168.2.102/24",
        "192.168.2.103/24"
      ]
    },
    "snapshot": {
      "location": "eu-south-2",
      "retentionDays": 7
    },
    "maintenanceWindow": {
      "dayOfTheWeek": "Sunday",
      "time": "02:00:00"
    },
    "credentials": {
      "username": "my_db_user",
      "password": "S3cure!Pass",
      "database": "mydb"
    }
  }
}

Result: The API returns HTTP 201. Note the id: you need it in every subsequent cluster operation. metadata.state starts as PROVISIONING.

Note:

  • Cluster provisioning is asynchronous. Poll Retrieve Cluster until metadata.state is AVAILABLE. Once available, metadata.connectionUri contains the connection string.

  • If metadata.state returns FAILED, the cluster failed to provision. Retrieve the cluster details using Retrieve Cluster and check metadata.statusMessage for the failure reason.

Next steps: To connect to your cluster, see Connect to Your MongoDB Cluster.

Connect to Your MongoDB Cluster

Use this workflow to retrieve the MongoDB cluster connection URI and connect using your credentials.

Prerequisites

  • Ensure the cluster is in the AVAILABLE state.

  • You must have the id (UUID) of the cluster. You receive this when you complete the Deploy a MongoDB Cluster workflow.

  • You must have the credentials.username, credentials.password, and credentials.database set during provisioning.

  • Your client must have network access to the LAN that the cluster is connected to.

1

Retrieve the Connection Details

  1. Retrieve the cluster:

    • Result: The API returns HTTP 200. Note metadata.connectionUri. Example: mongodb+srv://m-12abd343.mongodb.gb-bhx.ionoscloud.com.

2

Connect with the Connection URI

Use the following details with mongosh or any MongoDB driver:

Property

Value

Connection URI

metadata.connectionUri value from the first step

User

The username from credentials.username

Authentication database

admin

Example:

Note: The user owns the database from credentials.database, but you authenticate against the admin database. The mongodb+srv connection URI sets this automatically.

3

Connect through the BI Connector (Optional)

On ENTERPRISE clusters with biConnectorEnabled set to true, the BI Connector is reachable over the MySQL wire protocol at bi-connect.<mongo-host> on the fixed port 27015. Example: bi-connect.m-12abd343.mongodb.gb-bhx.ionoscloud.com:27015.

Operate a MongoDB Cluster

Use this workflow to manage a running cluster and deprovision it when it is no longer needed.

Prerequisites

  • Ensure the cluster is in the AVAILABLE state.

  • You must have the id (UUID) of the cluster.

Note: Cluster updates use the Ensure pattern. Retrieve the cluster, change the fields you need, and submit the full object with Update Cluster. Fields not included in the request reset to their defaults. Omit credentials to leave the existing user unchanged.

Review Snapshots

  • Action: Filter by filter.clusterId to list the snapshots of one cluster.

  • Result: Each snapshot shows earliestRecoveryTargetTime and latestRecoveryTargetTime. If latestRecoveryTargetTime is null, the cluster can be restored up to the current time.

Scale Cluster Resources

  • Action: For BUSINESS, change instanceTemplateId or instanceCount. For ENTERPRISE, change the values in instances. Submit the full cluster object. If the number of instances changes, update connection.instanceAddresses in the same request so that it contains exactly one address per instance. For example, increasing a three-instance cluster to four instances requires a fourth address in the list. For an ENTERPRISE cluster with sharding enabled, the list always contains exactly three addresses.

  • Result: The API accepts the change and metadata.state moves to UPDATING. Poll until it returns to AVAILABLE.

Add Shards

  • Action: On an ENTERPRISE cluster with sharding enabled, increase sharding.shards and submit the full cluster object.

  • Result: The cluster moves to UPDATING and returns to AVAILABLE when the change completes.

Note: You can increase the number of shards but not reduce it. Once sharding is enabled, you cannot disable it.

Monitor Version Lifecycle

  • Action: Check the status, creationFreezeDate, and deprecationDate of your cluster's version. A DEPRECATED status or an approaching deprecationDate indicates that you should plan an upgrade.

Upgrade the MongoDB Version

  • Action: Set properties.version to a version listed in the canUpgradeTo array of your current version. Downgrades are not supported.

Update the Maintenance Window

  • Action: Change maintenanceWindow.dayOfTheWeek and maintenanceWindow.time (UTC). The window is four hours long and starts at time.

Deprovision the Cluster

Deprovision the cluster when it is no longer needed to release resources.

  • Action: Submit the delete request to permanently remove the cluster.

  • Result: The API returns HTTP 202, confirming the delete request is accepted. Deletion is asynchronous: metadata.state moves to DESTROYING and the cluster is removed once deletion completes.

Restore from a Snapshot

Use this workflow to recover cluster data to a specific point in time. MongoDB supports Point-in-Time Recovery (PITR): the restore starts from the base snapshot and replays the oplog up to recoveryTargetDatetime.

Prerequisites

  • An access token that authenticates your API requests. For more information, see Authentication.

  • The id of the source cluster.

Step 1: Find the Snapshot

  1. List the snapshots:

    • Action: Filter by filter.clusterId.

    • Result: Note the snapshot id and its recovery window (earliestRecoveryTargetTime to latestRecoveryTargetTime). Also note requiredStorageSize, the minimum storage needed to restore this snapshot, in MiB.

Path 1: Create a New Cluster from a Snapshot

  • Action: Provide the full cluster configuration and add restoreFromSnapshot with sourceSnapshotId. Optionally add recoveryTargetDatetime. If omitted, the snapshot is applied in full.

  • Result: A new cluster is provisioned with the restored data.

Note: Only snapshots from clusters in the same region are eligible. The snapshot's requiredStorageSize is in mebibytes (MiB), while instances.storageSize (Enterprise) and the instance template's storageSize (Business) are in gigabytes (GB). Convert the value before you choose the storage (1 GiB = 1,024 MiB) and round up. The new cluster's storage per instance must be at least that amount.

Path 2: Restore the Existing Cluster in Place

Use this path when you must recover the current cluster to an earlier state. This path is destructive and cannot be undone.

  • Action: Submit the full cluster object and add restoreFromSnapshot with recoveryTargetDatetime only. Do not set sourceSnapshotId: the source is inferred from the cluster's own snapshots.

  • Result: The cluster is restored to the target time.

Verify Snapshot Data Residency

Use this workflow to confirm that cluster snapshots are stored in the expected Object Storage region.

1

Find the Cluster's Snapshot Location

2

Verify the Snapshot Location

  • Action: Filter by filter.clusterId.

  • Result: Each snapshot's location should match the value from the first step.

Last updated

Was this helpful?