Update a Kafka topic

Update a topic's settings. We apply the change to the brokers in the background. When a broker's disk is nearly full, you can still lower retention_bytes.

PATCH https://{availability_zone}.betterstackcloud.com/v1/kafka/{kafka_id}/topics/{id}
kafka_id string required

The ID of the kafka the Kafka topic belongs to.

id string required

The ID of the Kafka topic to update.

Authorization string required

Bearer $TOKEN

Content-Type string

application/json

partitions integer

The number of partitions, at least 1. All topics together must fit within the cluster type's max_partitions. On update, you can only increase it.

retention_bytes integer

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.

retention_ms integer

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

cleanup_policy string

How Kafka removes old messages.
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.

max_message_bytes integer

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

202 Accepted
{
  "id": "example",
  "name": "Example Kafka topic",
  "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"
}

Returns the updated Kafka topic.

id string

The topic's ID, a UUID. Get, update and delete a topic by this ID, never by its name.

name string

The topic's name, unique in the cluster, 1–249 letters, digits, dots, hyphens and underscores. Can't be . or .. or start with __. Can't be changed after the topic is created.

partitions integer

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

replication_factor integer

The number of copies of each partition, the same as the cluster's number of brokers.

retention_bytes integer

The most data to keep in each partition, in bytes, at least 1048576.

retention_ms integer

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

cleanup_policy string

How Kafka removes old messages.
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.

max_message_bytes integer

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

budget_bytes integer

The most disk space the topic can use on each broker, in bytes. The budget is partitions times retention_bytes, plus one segment for each partition.

created_at datetime or null

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

updated_at datetime or null

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