Create a Kafka cluster

Create a Kafka cluster, and optionally its first topics.

POST https://{availability_zone}.betterstackcloud.com/v1/kafka
Authorization string required

Bearer $TOKEN

Content-Type string

application/json

team_id string required

The ID of the team to create the cluster in. betterstack team list shows it.

name string required

The cluster's name, at most 255 characters.

type string required

The cluster's type, such as KA1. List the types with betterstack kafka-type list.

engine_version string

The Kafka version, such as 4.4. List the versions with betterstack kafka-version list. Defaults to the latest version.

broker_count integer default: 3

The number of brokers, 1 or 3. Defaults to 3. Can't be changed later. A single broker keeps one copy of your data, so a lost broker can't be rebuilt from another one.

public_access boolean default: false

Whether the cluster also gets public bootstrap and broker endpoints. The public endpoints use the same TLS and SCRAM credentials as the private ones.

network_ids array of strings

The IDs of your networks to attach to every broker. The networks must be in the cluster's team.

firewall_ids array of strings

The ID of a firewall to attach to every broker, at most one. The firewall must be in the cluster's team.

topics array of objects

Topics to create with the cluster. The topics must fit in the storage budget, as when you create a topic later.

topics[].name string required

The topic's name, 1–249 letters, digits, dots, hyphens or underscores. A name can't be . or .., and can't start with __.

topics[].partitions integer default: 3

The number of partitions, at least 1. All topics together must fit within the type's max_partitions.

topics[].retention_bytes integer default: 1073741824

The most data to keep in each partition, in bytes, at least 1048576. All topics together, plus one segment for each partition, must fit in the cluster's storage budget.

topics[].retention_ms integer default: 604800000

How long to keep messages, in milliseconds, at least 60000. Send -1 to keep them with no time limit. retention_bytes still limits the size.

topics[].cleanup_policy string default: delete

How Kafka removes old messages. Defaults to delete.
Valid values:
delete: Deletes messages older than the retention time or past the retention size.
compact: Keeps only the latest message for each key.
compact_delete: Keeps only the latest message for each key, and also deletes messages past retention. Kafka calls it compact,delete.

topics[].max_message_bytes integer default: 1048576

The largest message the topic accepts, in bytes, from 1024 to 8388608.

term string default: monthly

The billing term. Defaults to monthly. Possible values: monthly, annual.

metadata object

Your tags, as an object of string keys and values. Accepts any keys.

202 Accepted
{
  "id": "example",
  "name": "Example Kafka cluster",
  "type": "KA1",
  "broker_count": 50,
  "replication_factor": 1,
  "min_insync_replicas": 1,
  "usable_storage_gb": 1,
  "max_partitions": 1,
  "storage_budget_bytes": 1,
  "storage_budget_used_bytes": 1,
  "partition_count": 50,
  "engine_version": "1.4.2",
  "engine_patch_version": "1.4.2",
  "available_engine_versions": [
    "1.4.2"
  ],
  "status": "provisioning",
  "status_message": "example",
  "public_access": false,
  "endpoint": {
    "bootstrap_servers": "example",
    "hostname": "proxy.example.com",
    "port": 443,
    "security_protocol": "example",
    "sasl_mechanism": "example",
    "brokers": [
      {
        "node_id": 123456789,
        "hostname": "proxy.example.com"
      }
    ],
    "public_bootstrap_servers": "example",
    "public_hostname": "proxy.example.com",
    "public_port": 443,
    "public_brokers": [
      {
        "node_id": 123456789,
        "hostname": "proxy.example.com"
      }
    ]
  },
  "brokers": [
    {
      "id": "example",
      "node_id": 123456789,
      "status": "provisioning",
      "hostname": "proxy.example.com",
      "disk_used_bytes": 1,
      "under_replicated_partitions": 1,
      "private_ips": [
        {
          "network_id": "123456789",
          "ip_address": "example"
        }
      ],
      "last_seen_at": "2026-07-01T12:00:00.000Z"
    }
  ],
  "topics": [
    {
      "id": "example",
      "name": "Example",
      "partitions": 1,
      "replication_factor": 1,
      "retention_bytes": 1,
      "retention_ms": 1,
      "cleanup_policy": "delete",
      "max_message_bytes": 1,
      "budget_bytes": 1,
      "created_at": "2026-07-01T12:00:00.000Z",
      "updated_at": "2026-07-01T12:00:00.000Z"
    }
  ],
  "users": [
    {
      "id": "example",
      "username": "example",
      "default_user": false,
      "privileges": [
        {
          "topic_pattern": "example",
          "permission": "consume"
        }
      ],
      "created_at": "2026-07-01T12:00:00.000Z",
      "updated_at": "2026-07-01T12:00:00.000Z"
    }
  ],
  "network_ids": [
    "123456789"
  ],
  "firewall_ids": [
    "123456789"
  ],
  "term": "monthly",
  "created_at": "2026-07-01T12:00:00.000Z",
  "updated_at": "2026-07-01T12:00:00.000Z",
  "team_id": "t123",
  "metadata": {
    "example": "value"
  }
}

Returns the newly created Kafka cluster.

id string

The cluster's ID, a UUID.

name string

The cluster's name, at most 255 characters, unique among your organization's clusters that aren't destroyed or failed.

type string

The cluster's type, such as KA1.

broker_count integer

The number of brokers, 1 for development or 3 to survive the loss of a broker. Can't be changed after the cluster is created.

replication_factor integer

The number of copies of each partition, always equal to broker_count. Every broker stores every partition.

min_insync_replicas integer

The number of copies that must confirm a write, 1 with one broker and 2 with three.

usable_storage_gb integer

The storage for your topics on each broker, in GiB.

max_partitions integer

The most partitions the cluster's type allows across all topics.

storage_budget_bytes integer

The storage budget of each broker, in bytes. Every topic must fit in it.

storage_budget_used_bytes integer

The storage your topics reserve, in bytes. Each topic reserves its retention_bytes times its number of partitions, plus one segment for each partition.

partition_count integer

The number of partitions across all topics.

engine_version string

The Kafka version as major and minor, such as 4.4.

engine_patch_version string or null

The exact Kafka release installed, such as 4.4.0.

available_engine_versions array of strings

The version you can upgrade the cluster to, the next one we offer. The list is empty when the cluster runs the newest version.

status string

The cluster's state.
Valid values:
provisioning: We're starting the brokers and installing Kafka.
running: The cluster is ready. Right after it's created, brokers can still be starting.
degraded: A broker is down, partitions are missing copies or a disk is almost full. status_message says which.
rescaling: We're changing the cluster's type.
upgrading: We're upgrading the cluster to a newer Kafka version.
failed: We couldn't create the cluster. status_message says why.
destroyed: The cluster is destroyed.

status_message string or null

Why the cluster is in its current state, such as which broker is down, or null when there's nothing to report.

public_access boolean

Whether the cluster also has public endpoints. Clients connect with TLS and SCRAM on both the private and the public endpoints.

endpoint object

The addresses clients connect to, the bootstrap address and one for each broker. The fields that start with public_ are only present when public_access is on. Clients must reach every broker, not only the bootstrap address.

endpoint.bootstrap_servers string

The bootstrap servers.

endpoint.hostname string or null

The hostname.

endpoint.port integer

The port.

endpoint.security_protocol string

The security protocol.

endpoint.sasl_mechanism string

The sasl mechanism.

endpoint.brokers array of objects

The brokers.

endpoint.brokers[].node_id integer

The node id.

endpoint.brokers[].hostname string or null

The hostname.

endpoint.public_bootstrap_servers string

The public bootstrap servers.

endpoint.public_hostname string

The public hostname.

endpoint.public_port integer

The public port.

endpoint.public_brokers array of objects

The public brokers.

endpoint.public_brokers[].node_id integer

The node id.

endpoint.public_brokers[].hostname string

The hostname.

brokers array of objects

The cluster's brokers, with their addresses on your networks and their last reported health. All brokers have the same role.

brokers[].id string

The id.

brokers[].node_id integer

The node id.

brokers[].status string

Possible values: provisioning, starting, running, down.

brokers[].hostname string or null

The hostname.

brokers[].disk_used_bytes integer or null

The disk used bytes.

brokers[].under_replicated_partitions integer or null

The under replicated partitions.

brokers[].private_ips array of objects

The private ips.

brokers[].private_ips[].network_id string

The network id.

brokers[].private_ips[].ip_address string

The ip address.

brokers[].last_seen_at datetime or null

In ISO 8601 format, such as 2026-07-01T12:00:00Z.

topics array of objects

The cluster's topics, ordered by name. Add, update or remove them with betterstack kafka-topic.

topics[].id string

The id.

topics[].name string

The name.

topics[].partitions integer

The partitions.

topics[].replication_factor integer

The replication factor.

topics[].retention_bytes integer

The retention bytes.

topics[].retention_ms integer

The retention ms.

topics[].cleanup_policy string

Possible values: delete, compact, compact_delete.

topics[].max_message_bytes integer

The max message bytes.

topics[].budget_bytes integer

The budget bytes.

topics[].created_at datetime or null

In ISO 8601 format, such as 2026-07-01T12:00:00Z.

topics[].updated_at datetime or null

In ISO 8601 format, such as 2026-07-01T12:00:00Z.

users array of objects

The cluster's users, ordered by username. Add, update or remove them with betterstack kafka-user, which also gets their passwords.

users[].id string

The id.

users[].username string

The username.

users[].default_user boolean

The default user.

users[].privileges array of objects

The privileges.

users[].privileges[].topic_pattern string

The topic pattern.

users[].privileges[].permission string

Possible values: consume, produce, produce_consume.

users[].created_at datetime or null

In ISO 8601 format, such as 2026-07-01T12:00:00Z.

users[].updated_at datetime or null

In ISO 8601 format, such as 2026-07-01T12:00:00Z.

network_ids array of strings

The IDs of your networks attached to every broker. Order doesn't matter.

firewall_ids array of strings

The ID of the firewall attached to every broker, at most one. Order doesn't matter.

term string

The billing term. Defaults to monthly.
Valid values:
monthly: Billed every month.
annual: Paid for a year.

created_at datetime

When the cluster was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

updated_at datetime

When the cluster was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.

team_id string

The ID of the team that owns the cluster.

metadata object

Your tags, as an object of string keys and values.