# Create a Kafka Cluster

You can create a new Kafka cluster with specified configurations.

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

* Only contract administrators, owners, and users with **Access and manage Event Streams for Apache Kafka** privileges can create and manage Kafka clusters.
* After creating the cluster, you can use it via the corresponding LAN and certificates.
  {% endhint %}

The data center must be provided as an `UUID`. The easiest way to retrieve the `UUID` is through the [<mark style="color:blue;">IONOS CLOUD API</mark>](https://docs.ionos.com/cloud/reference/api-specification-files/api-overview).

## Endpoint

`POST /clusters`

The `POST /clusters` endpoint allows you to create a new Kafka cluster with specified properties. The name, version, size, and connection fields are required. The response includes the newly created cluster's ID, metadata, and properties, along with its current state and broker addresses.

Use this endpoint to provision a Kafka cluster tailored to your application's requirements, ensuring seamless integration and efficient data management.

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

* Select the size of your Kafka cluster according to your throughput and data retention requirements. For example, if you have three topics, each with a retention time of seven days, and you expect 500 KB of data per second on each of these topics, you can calculate that you will need a minimum of 866 GB of total storage in your Kafka cluster.
* Consider that the final storage consumption can be several times the incoming data volume, depending on the configured replication factor for the topic.
  {% endhint %}

## Request

```bash
curl -X 'POST' \
  'https://kafka.de-txl.ionos.com/clusters' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer $Token' \
--data
'{
  "metadata": {},
  "properties": {
    "name": "my-kafka-cluster",
    "version": "3.9.0",
    "size": "S",
    "connections": [
      {
        "datacenterId": "5a029f4a-72e5-11ec-90d6-0242ac120003",
        "lanId": "2",
        "brokerAddresses": [
          "192.168.1.101/24",
          "192.168.1.102/24",
          "192.168.1.103/24"
        ]
      }
    ]
  }
}`
```

{% 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                                                  |
| ----------------- | -------- | ------ | ------------------------------------------------------------ |
| `Content-Type`    | yes      | string | Set this to `application/json`.                              |
| `Accept`          | yes      | string | Set this to `application/json`.                              |
| `Authorization`   | yes      | string | Provide a header value as `Bearer` followed by your `token`. |
| {% endtab %}      |          |        |                                                              |

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

| Body Parameter    | Type   | Description                                                    | Example                                                     |
| ----------------- | ------ | -------------------------------------------------------------- | ----------------------------------------------------------- |
| `name`            | string | The name of the Kafka cluster.                                 | my-kafka-cluster                                            |
| `version`         | string | The version of Kafka to use for the cluster.                   | 3.9.0                                                       |
| `size`            | string | The size of the Kafka cluster.                                 | S                                                           |
| `datacenterId`    | string | The UUID of the data center where the cluster will be created. | 5a029f4a-72e5-11ec-90d6-0242ac120003                        |
| `lanId`           | string | The LAN ID where the cluster will be connected.                | 2                                                           |
| `brokerAddresses` | array  | List of broker addresses for the cluster.                      | \["192.168.1.101/24","192.168.1.102/24","192.168.1.103/24"] |
| {% endtab %}      |        |                                                                |                                                             |
| {% endtabs %}     |        |                                                                |                                                             |

## Response

**200 Successful operation**

```json
{
  "id": "e69b22a5-8fee-56b1-b6fb-4a07e4205ead",
  "type": "cluster",
  "href": "/clusters/e69b22a5-8fee-56b1-b6fb-4a07e4205ead",
  "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",
    "brokerAddresses": [
      "192.168.1.101:9093",
      "192.168.1.102:9093",
      "192.168.1.103:9093"
    ]
  },
  "properties": {
    "name": "my-kafka-cluster",
    "version": "3.9.0",
    "size": "S",
    "connections": [
      {
        "datacenterId": "5a029f4a-72e5-11ec-90d6-0242ac120003",
        "lanId": "2",
        "brokerAddresses": [
          "192.168.1.101/24",
          "192.168.1.102/24",
          "192.168.1.103/24"
        ]
      }
    ]
  }
}
```


---

# 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/data-analytics/kafka/api-howtos/create-kafka.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.
