Skip to content
m manifester.io
All Kafka APIs

CreateTopics

This page encodes the smallest legal instance of the request and the response: numeric fields are zero, strings and byte arrays are empty, every array carries exactly one sample element, and any records field holds one empty 61-byte RecordBatch v2. Version 7 is a flexible version, so every struct is terminated by a uvarint tagged-field count and strings and arrays carry compact length-plus-one prefixes. Sizes below include the leading int32 size prefix.

API key
19
Encoded at
v7
Flexible versions
5+
Headers
req v2, resp v1
Request versions
2-7
Response versions
2-7
Request size
45 bytes
Response size
49 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields

Request

CreateTopicsRequest v7, request header v2, 45 bytes on the wire

byte layout (45 bytes, 16 bytes per row)

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020

object tree

CreateTopicsRequest                                message v7                                             [0x0000, 45B]
+-- Frame                                                                                                 [0x0000, 4B]   length-delimited framing
|   +-- size                                       int32                         = 41                     [0x0000, 4B]   number of bytes that follow, patched after encoding
+-- RequestHeader                                  v2                                                     [0x0004, 11B]  common request header
|   +-- request_api_key                            int16                         = 19 (CreateTopics)      [0x0004, 2B]   numeric id of the API being invoked
|   +-- request_api_version                        int16                         = 7                      [0x0006, 2B]   version of the API being invoked
|   +-- correlation_id                             int32                         = 0                      [0x0008, 4B]   echoed back by the broker in the response
|   +-- client_id                                  nullable_string               = "" (int16 len=0)       [0x000c, 2B]   always a non-flexible int16-prefixed string
|   +-- tagged_fields                              uvarint                       = 0                      [0x000e, 1B]   number of tagged fields in the header
+-- CreateTopicsRequest                            struct                                                 [0x000f, 30B]  message body, version 7
    +-- Topics                                     []CreatableTopic              = 1 element              [0x000f, 24B]  The topics to create.
    |   +-- length                                 uvarint                       = 2 (compact, n+1)       [0x000f, 1B]   one sample element follows
    |   +-- CreatableTopic[0]                      CreatableTopic                = struct                 [0x0010, 23B]
    |       +-- Name                               string                        = "" (compact, len+1=1)  [0x0010, 1B]   The topic name.
    |       +-- NumPartitions                      int32                         = 0                      [0x0011, 4B]   The number of partitions to create in the topic, or -1 if we are either spe...
    |       +-- ReplicationFactor                  int16                         = 0                      [0x0015, 2B]   The number of replicas to create for each partition in the topic, or -1 if ...
    |       +-- Assignments                        []CreatableReplicaAssignment  = 1 element              [0x0017, 11B]  The manual partition assignment, or the empty array if we are using automat...
    |       |   +-- length                         uvarint                       = 2 (compact, n+1)       [0x0017, 1B]   one sample element follows
    |       |   +-- CreatableReplicaAssignment[0]  CreatableReplicaAssignment    = struct                 [0x0018, 10B]
    |       |       +-- PartitionIndex             int32                         = 0                      [0x0018, 4B]   The partition index.
    |       |       +-- BrokerIds                  []int32                       = 1 element              [0x001c, 5B]   The brokers to place the partition on.
    |       |       |   +-- length                 uvarint                       = 2 (compact, n+1)       [0x001c, 1B]   one sample element follows
    |       |       |   +-- int32[0]               int32                         = 0                      [0x001d, 4B]
    |       |       +-- tagged_fields              uvarint                       = 0                      [0x0021, 1B]   number of tagged fields in this struct
    |       +-- Configs                            []CreatableTopicConfig        = 1 element              [0x0022, 4B]   The custom topic configurations to set.
    |       |   +-- length                         uvarint                       = 2 (compact, n+1)       [0x0022, 1B]   one sample element follows
    |       |   +-- CreatableTopicConfig[0]        CreatableTopicConfig          = struct                 [0x0023, 3B]
    |       |       +-- Name                       string                        = "" (compact, len+1=1)  [0x0023, 1B]   The configuration name.
    |       |       +-- Value                      string                        = "" (compact, len+1=1)  [0x0024, 1B]   The configuration value.
    |       |       +-- tagged_fields              uvarint                       = 0                      [0x0025, 1B]   number of tagged fields in this struct
    |       +-- tagged_fields                      uvarint                       = 0                      [0x0026, 1B]   number of tagged fields in this struct
    +-- timeoutMs                                  int32                         = 0                      [0x0027, 4B]   How long to wait in milliseconds before timing out the request.
    +-- validateOnly                               bool                          = false                  [0x002b, 1B]   If true, check that the topics can be created as specified, but don't creat...
    +-- tagged_fields                              uvarint                       = 0                      [0x002c, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 19,
  "type": "request",
  "listeners": ["broker", "controller"],
  "name": "CreateTopicsRequest",
  // Versions 0-1 were removed in Apache Kafka 4.0, Version 2 is the new baseline.
  //
  // Version 1 adds validateOnly.
  //
  // Version 4 makes partitions/replicationFactor optional even when assignments are not present (KIP-464)
  //
  // Version 5 is the first flexible version.
  // Version 5 also returns topic configs in the response (KIP-525).
  //
  // Version 6 is identical to version 5 but may return a THROTTLING_QUOTA_EXCEEDED error
  // in the response if the topics creation is throttled (KIP-599).
  //
  // Version 7 is the same as version 6.
  "validVersions": "2-7",
  "flexibleVersions": "5+",
  "fields": [
    { "name": "Topics", "type": "[]CreatableTopic", "versions": "0+",
      "about": "The topics to create.", "fields": [
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName",
        "about": "The topic name." },
      { "name": "NumPartitions", "type": "int32", "versions": "0+",
        "about": "The number of partitions to create in the topic, or -1 if we are either specifying a manual partition assignment or using the default partitions." },
      { "name": "ReplicationFactor", "type": "int16", "versions": "0+",
        "about": "The number of replicas to create for each partition in the topic, or -1 if we are either specifying a manual partition assignment or using the default replication factor." },
      { "name": "Assignments", "type": "[]CreatableReplicaAssignment", "versions": "0+",
        "about": "The manual partition assignment, or the empty array if we are using automatic assignment.", "fields": [
        { "name": "PartitionIndex", "type": "int32", "versions": "0+", "mapKey": true,
          "about": "The partition index." },
        { "name": "BrokerIds", "type": "[]int32", "versions": "0+", "entityType": "brokerId",
          "about": "The brokers to place the partition on." }
      ]},
      { "name": "Configs", "type": "[]CreatableTopicConfig", "versions": "0+",
        "about": "The custom topic configurations to set.", "fields": [
        { "name": "Name", "type": "string", "versions": "0+" , "mapKey": true,
          "about": "The configuration name." },
        { "name": "Value", "type": "string", "versions": "0+", "nullableVersions": "0+",
          "about": "The configuration value." }
      ]}
    ]},
    { "name": "timeoutMs", "type": "int32", "versions": "0+", "default": "60000",
      "about": "How long to wait in milliseconds before timing out the request." },
    { "name": "validateOnly", "type": "bool", "versions": "1+", "default": "false", "ignorable": false,
      "about": "If true, check that the topics can be created as specified, but don't create anything." }
  ]
}

Response

CreateTopicsResponse v7, response header v1, 49 bytes on the wire

byte layout (49 bytes, 16 bytes per row)

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0000
0010
0020
0030

object tree

CreateTopicsResponse                          message v7                                                       [0x0000, 49B]
+-- Frame                                                                                                      [0x0000, 4B]   length-delimited framing
|   +-- size                                  int32                    = 45                                    [0x0000, 4B]   number of bytes that follow, patched after encoding
+-- ResponseHeader                            v1                                                               [0x0004, 5B]   common response header
|   +-- correlation_id                        int32                    = 0                                     [0x0004, 4B]   matches the correlation_id of the request
|   +-- tagged_fields                         uvarint                  = 0                                     [0x0008, 1B]   number of tagged fields in the header
+-- CreateTopicsResponse                      struct                                                           [0x0009, 40B]  message body, version 7
    +-- ThrottleTimeMs                        int32                    = 0                                     [0x0009, 4B]   The duration in milliseconds for which the request was throttled due to a q...
    +-- Topics                                []CreatableTopicResult   = 1 element                             [0x000d, 35B]  Results for each topic we tried to create.
    |   +-- length                            uvarint                  = 2 (compact, n+1)                      [0x000d, 1B]   one sample element follows
    |   +-- CreatableTopicResult[0]           CreatableTopicResult     = struct                                [0x000e, 34B]
    |       +-- Name                          string                   = "" (compact, len+1=1)                 [0x000e, 1B]   The topic name.
    |       +-- TopicId                       uuid                     = 00000000-0000-0000-0000-000000000000  [0x000f, 16B]  The unique topic ID.
    |       +-- ErrorCode                     int16                    = 0                                     [0x001f, 2B]   The error code, or 0 if there was no error.
    |       +-- ErrorMessage                  string                   = "" (compact, len+1=1)                 [0x0021, 1B]   The error message, or null if there was no error.
    |       +-- NumPartitions                 int32                    = 0                                     [0x0022, 4B]   Number of partitions of the topic.
    |       +-- ReplicationFactor             int16                    = 0                                     [0x0026, 2B]   Replication factor of the topic.
    |       +-- Configs                       []CreatableTopicConfigs  = 1 element                             [0x0028, 7B]   Configuration of the topic.
    |       |   +-- length                    uvarint                  = 2 (compact, n+1)                      [0x0028, 1B]   one sample element follows
    |       |   +-- CreatableTopicConfigs[0]  CreatableTopicConfigs    = struct                                [0x0029, 6B]
    |       |       +-- Name                  string                   = "" (compact, len+1=1)                 [0x0029, 1B]   The configuration name.
    |       |       +-- Value                 string                   = "" (compact, len+1=1)                 [0x002a, 1B]   The configuration value.
    |       |       +-- ReadOnly              bool                     = false                                 [0x002b, 1B]   True if the configuration is read-only.
    |       |       +-- ConfigSource          int8                     = 0                                     [0x002c, 1B]   The configuration source.
    |       |       +-- IsSensitive           bool                     = false                                 [0x002d, 1B]   True if this configuration is sensitive.
    |       |       +-- tagged_fields         uvarint                  = 0                                     [0x002e, 1B]   number of tagged fields in this struct
    |       +-- tagged_fields                 uvarint                  = 0                                     [0x002f, 1B]   number of tagged fields in this struct
    +-- tagged_fields                         uvarint                  = 0                                     [0x0030, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 19,
  "type": "response",
  "name": "CreateTopicsResponse",
  // Versions 0-1 were removed in Apache Kafka 4.0, Version 2 is the new baseline.
  //
  // Version 1 adds a per-topic error message string.
  //
  // Version 2 adds the throttle time.
  //
  // Starting in version 3, on quota violation, brokers send out responses before throttling.
  //
  // Version 4 makes partitions/replicationFactor optional even when assignments are not present (KIP-464).
  //
  // Version 5 is the first flexible version.
  // Version 5 also returns topic configs in the response (KIP-525).
  //
  // Version 6 is identical to version 5 but may return a THROTTLING_QUOTA_EXCEEDED error
  // in the response if the topics creation is throttled (KIP-599).
  //
  // Version 7 returns the topic ID of the newly created topic if creation is successful.
  "validVersions": "2-7",
  "flexibleVersions": "5+",
  "fields": [
    { "name": "ThrottleTimeMs", "type": "int32", "versions": "2+", "ignorable": true,
      "about": "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota." },
    { "name": "Topics", "type": "[]CreatableTopicResult", "versions": "0+",
      "about": "Results for each topic we tried to create.", "fields": [
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName",
        "about": "The topic name." },
      { "name": "TopicId", "type": "uuid", "versions": "7+", "ignorable": true, "about": "The unique topic ID."},
      { "name": "ErrorCode", "type": "int16", "versions": "0+",
        "about": "The error code, or 0 if there was no error." },
      { "name": "ErrorMessage", "type": "string", "versions": "1+", "nullableVersions": "0+", "ignorable": true,
        "about": "The error message, or null if there was no error." },
      { "name": "TopicConfigErrorCode", "type": "int16", "versions": "5+", "tag": 0, "taggedVersions": "5+", "ignorable": true,
        "about": "Optional topic config error returned if configs are not returned in the response." },
      { "name": "NumPartitions", "type": "int32", "versions": "5+", "default": "-1", "ignorable": true,
        "about": "Number of partitions of the topic." },
      { "name": "ReplicationFactor", "type": "int16", "versions": "5+", "default": "-1", "ignorable": true,
        "about": "Replication factor of the topic." },
      { "name": "Configs", "type": "[]CreatableTopicConfigs", "versions": "5+", "nullableVersions": "5+", "ignorable": true,
        "about": "Configuration of the topic.", "fields": [
        { "name": "Name", "type": "string", "versions": "5+",
          "about": "The configuration name." },
        { "name": "Value", "type": "string", "versions": "5+", "nullableVersions": "5+",
          "about": "The configuration value." },
        { "name": "ReadOnly", "type": "bool", "versions": "5+",
          "about": "True if the configuration is read-only." },
        { "name": "ConfigSource", "type": "int8", "versions": "5+", "default": "-1", "ignorable": true,
          "about": "The configuration source." },
        { "name": "IsSensitive", "type": "bool", "versions": "5+",
          "about": "True if this configuration is sensitive." }
      ]}
    ]}
  ]
}