# Create an In-Memory DB Instance

The request creates a new In-Memory DB instance on IONOS DBaaS. Each In-Memory DB instance can contain multiple nodes.

{% hint style="info" %}
**Note:**

* Only contract administrators, owners, and users with **Access and manage DBaaS** privileges can create and manage In-Memory DB instances, provided the new IAM system is disabled.
* After creating an instance, you can access it via the corresponding LAN using the same `username` and `password` specified during creation.
* You can only set the `username` and `password` via the API while creating an In-Memory DB instance. Once configured, they cannot be updated.
  {% endhint %}

The data center must be provided as a `UUID`. The easiest way to retrieve the `UUID` is through the [<mark style="color:blue;">Cloud API</mark>](https://docs.ionos.com/reference/general-information/core-api-specification).

## Endpoint

Use a region-specific endpoint from the following list to create an In-Memory DB instance:

* `https://in-memory-db.de-txl.ionos.com/replicasets`
* `https://in-memory-db.de-fra.ionos.com/replicasets`
* `https://in-memory-db.es-vit.ionos.com/replicasets`
* `https://in-memory-db.gb-lhr.ionos.com/replicasets`
* `https://in-memory-db.us-ewr.ionos.com/replicasets`
* `https://in-memory-db.us-las.ionos.com/replicasets`
* `https://in-memory-db.us-mci.ionos.com/replicasets`
* `https://in-memory-db.fr-par.ionos.com/replicasets`

## Request

```bash
curl -X 'POST' \
  'https://in-memory-db.de-txl.ionos.com/replicasets' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $Token' \
--data 
'{
   "metadata":{
      
   },
   "properties":{
      "displayName":"In-Memory DB replica set",
      "version":"7.2",
      "replicas":2,
      "resources":{
         "cores":4,
         "ram":4
      },
      "persistence":{
         "mode":"None",
         "minimalSaveInterval":3600
      },
      "evictionPolicy":"allkeys-lru",
      "connections":[
         {
            "datacenterId":"dd00-7a96-dd00-dd00-bcaa13",
            "lanId":"2",
            "cidr":"123.123.1.100/24"
         }
      ],
      "maintenanceWindow":{
         "time":"16:30:59",
         "dayOfTheWeek":"Monday"
      },
      "credentials":{
         "username":"user13",
         "password":"mypassword"
      },
      "initialSnapshotId": "12345678-1234-1234-1234-123456789012"
      }
}'
```

{% tabs %}
{% tab title="Request Header Parameters" %}
To make authenticated requests to the API, the following fields are mandatory in the request header:

| Header Parameters | Required |  Type  | Description                                                  |
| ----------------- | :------: | :----: | ------------------------------------------------------------ |
| `Authorization`   |    yes   | string | Provide a header value as `Bearer` followed by your `token`. |
| `Content-Type`    |    yes   | string | Set this to `application/json`.                              |
| {% endtab %}      |          |        |                                                              |

{% tab title="Request Body Parameters" %}
Below is the list of mandatory body parameters:

| Body Parameters   | Type    | Description                                                                                           | Example                                                                                                                                              |
| ----------------- | ------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `displayName`     | string  | The human-readable name of your replica set.                                                          | In-Memory DB replica set                                                                                                                             |
| `version`         | string  | The version of your replica set.                                                                      | 7.2                                                                                                                                                  |
| `replicas`        | integer | The total number of replicas in the replica set (one active and n-1 passive).                         | 2                                                                                                                                                    |
| `resources`       | object  | The resources of the individual replicas.                                                             | `"cores": 4`, `"ram": 4`                                                                                                                             |
| `persistenceMode` | string  | Specifies data persistence mode. The values are: `None` (default value), `AOF`, `RDB`, and `RDB_AOF`. | `RDB`                                                                                                                                                |
| `evictionPolicy`  | string  | The eviction policy for the replica set.                                                              | The values are: `noeviction`, `allkeys-lru`, `allkeys-lfu`, `allkeys-random`, `volatile-lru`, `volatile-lfu`, `volatile-random`, and `volatile-ttl`. |
| `connections`     | object  | The network connection for your replica set. Only one connection is allowed.                          | `{ "datacenterId": "5a029f4a-72e5-11ec-90d6-0242ac120003", "lanId": "2", "cidr": "192.168.1.100/24"}`                                                |
| `credentials`     | object  | Credentials for the In-Memory DB replicaset.                                                          | `"username": "DatabaseAdmin"`                                                                                                                        |
| {% endtab %}      |         |                                                                                                       |                                                                                                                                                      |
| {% endtabs %}     |         |                                                                                                       |                                                                                                                                                      |

## Response

Your values will differ from those in the sample code. It may contain different IDs, timestamps etc.

You may have noticed that the `metadata.state` is `BUSY` and that the instance is not yet reachable. This is because the cloud will create a completely new instance and needs to provision new nodes for all the requested replicas. This process runs asynchronously in the background and might take up to 30 minutes.

**202 Successful operation**

```json
{
"id": "1046e9bf-dbc0-5bd3-9291-713d36ab77e9",
"type": "replicaset",
"href": "/replicasets/1046e9bf-dbc0-5bd3-9291-713d36ab77e9",
"metadata": {
"createdDate": "2020-12-10T13:37:50+01:00",
"createdBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
"createdByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
"lastModifiedDate": "2020-12-11T13:37:50+01:00",
"lastModifiedBy": "ionos:identity:::users/87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
"lastModifiedByUserId": "87f9a82e-b28d-49ed-9d04-fba2c0459cd3",
"resourceURN": "ionos:<product>:<location>:<contract>:<resource-path>",
"state": "AVAILABLE",
"message": "In progress.",
"dnsName": "in-memory-db.example.com"
},
"properties": {
"displayName": "In-Memory DB replica set",
"version": "7.2",
"replicas": 2,
"resources": {},
"persistenceMode": "None",
"evictionPolicy": "allkeys-lru",
"connections": [],
"maintenanceWindow": {},
"credentials": {},
"initialSnapshotId": "12345678-1234-1234-1234-123456789012"
}
}
```


---

# 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.ionos.com/cloud/~/revisions/AMiYziCllTKB2y2lmONY/databases/in-memory-db/api-howtos/create-in-memory-db-instance.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.
