topic create
kafka topic create <topics...>
Create one or more topics
Arguments
| Argument | Description |
|---|---|
topics... |
topic names to create |
Shared options and defaults: connection profiles, JSON output, logging and help.
Defaults
Explicit replica assignment excludes partition/replication counts. Otherwise flags override cli.topicDefaults, then omitted values follow client/broker defaults. –dry-run validates without creating.
Before you run
Creates topics and broker resources. Dry-run validates the request without creation; set explicit partition/replication values for a known cluster.
Flags
| Flag | Description |
|---|---|
--brokers <string> |
comma-separated broker list, e.g. localhost:9092 |
-p, --partitions <number> |
number of partitions |
-r, --replication-factor <number> |
replication factor |
--replica-assignment <string> (repeatable) |
explicit partition=replica,replica assignment (repeatable, exclusive with –partitions/–replication-factor) |
--config <key=value> (repeatable) |
a topic config entry, key=value (repeatable) |
--dry-run |
validate without creating anything |
--if-not-exists |
treat an already-existing topic as success |
--fail-fast |
issue one batched call instead of one call per topic |
Examples
kafka topic create orders --partitions 3 --replication-factor 1
kafka topic create orders payments --dry-run
Output
Illustrative, abbreviated output. Empty arrays show the result envelope; actual entries, identifiers, optional fields and broker errors depend on the request and cluster.
With --json:
{
"results": [
{
"topic": "events",
"ok": true
}
]
}
Declared exit codes: 0, 1, 2, 4. See the exit-code reference for meanings.