Skip to content
m manifester.io
All Kafka APIs

Metadata

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 13 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
3
Encoded at
v13
Flexible versions
9+
Headers
req v2, resp v1
Request versions
0-13
Response versions
0-13
Request size
37 bytes
Response size
90 bytes
framerpc headerrequest bodyRecordBatchRecordresponse bodytagged_fields

Request

MetadataRequest v13, request header v2, 37 bytes on the wire

byte layout (37 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

MetadataRequest                           message v13                                                     [0x0000, 37B]
+-- Frame                                                                                                 [0x0000, 4B]   length-delimited framing
|   +-- size                              int32                   = 33                                    [0x0000, 4B]   number of bytes that follow, patched after encoding
+-- RequestHeader                         v2                                                              [0x0004, 11B]  common request header
|   +-- request_api_key                   int16                   = 3 (Metadata)                          [0x0004, 2B]   numeric id of the API being invoked
|   +-- request_api_version               int16                   = 13                                    [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
+-- MetadataRequest                       struct                                                          [0x000f, 22B]  message body, version 13
    +-- Topics                            []MetadataRequestTopic  = 1 element                             [0x000f, 19B]  The topics to fetch metadata for.
    |   +-- length                        uvarint                 = 2 (compact, n+1)                      [0x000f, 1B]   one sample element follows
    |   +-- MetadataRequestTopic[0]       MetadataRequestTopic    = struct                                [0x0010, 18B]
    |       +-- TopicId                   uuid                    = 00000000-0000-0000-0000-000000000000  [0x0010, 16B]  The topic id.
    |       +-- Name                      string                  = "" (compact, len+1=1)                 [0x0020, 1B]   The topic name.
    |       +-- tagged_fields             uvarint                 = 0                                     [0x0021, 1B]   number of tagged fields in this struct
    +-- AllowAutoTopicCreation            bool                    = false                                 [0x0022, 1B]   If this is true, the broker may auto-create topics that we requested which ...
    +-- IncludeTopicAuthorizedOperations  bool                    = false                                 [0x0023, 1B]   Whether to include topic authorized operations.
    +-- tagged_fields                     uvarint                 = 0                                     [0x0024, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 3,
  "type": "request",
  "listeners": ["broker"],
  "name": "MetadataRequest",
  "validVersions": "0-13",
  "flexibleVersions": "9+",
  "fields": [
    // In version 0, an empty array indicates "request metadata for all topics."  In version 1 and
    // higher, an empty array indicates "request metadata for no topics," and a null array is used to
    // indicate "request metadata for all topics."
    //
    // Version 2 and 3 are the same as version 1.
    //
    // Version 4 adds AllowAutoTopicCreation.
    //
    // Starting in version 8, authorized operations can be requested for cluster and topic resource.
    //
    // Version 9 is the first flexible version.
    //
    // Version 10 adds topicId and allows name field to be null. However, this functionality was not implemented on the server.
    // Versions 10 and 11 should not use the topicId field or set topic name to null.
    //
    // Version 11 deprecates IncludeClusterAuthorizedOperations field. This is now exposed
    // by the DescribeCluster API (KIP-700).
    // Version 12 supports topic Id.
    // Version 13 supports top-level error code in the response.
    { "name": "Topics", "type": "[]MetadataRequestTopic", "versions": "0+", "nullableVersions": "1+",
      "about": "The topics to fetch metadata for.", "fields": [
      { "name": "TopicId", "type": "uuid", "versions": "10+", "ignorable": true, "about": "The topic id." },
      { "name": "Name", "type": "string", "versions": "0+", "entityType": "topicName", "nullableVersions": "10+",
        "about": "The topic name." }
    ]},
    { "name": "AllowAutoTopicCreation", "type": "bool", "versions": "4+", "default": "true", "ignorable": false,
      "about": "If this is true, the broker may auto-create topics that we requested which do not already exist, if it is configured to do so." },
    { "name": "IncludeClusterAuthorizedOperations", "type": "bool", "versions": "8-10",
      "about": "Whether to include cluster authorized operations." },
    { "name": "IncludeTopicAuthorizedOperations", "type": "bool", "versions": "8+",
      "about": "Whether to include topic authorized operations." }
  ]
}

Response

MetadataResponse v13, response header v1, 90 bytes on the wire

byte layout (90 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
0040
0050

object tree

MetadataResponse                                  message v13                                                          [0x0000, 90B]
+-- Frame                                                                                                              [0x0000, 4B]   length-delimited framing
|   +-- size                                      int32                        = 86                                    [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
+-- MetadataResponse                              struct                                                               [0x0009, 81B]  message body, version 13
    +-- ThrottleTimeMs                            int32                        = 0                                     [0x0009, 4B]   The duration in milliseconds for which the request was throttled due to a q...
    +-- Brokers                                   []MetadataResponseBroker     = 1 element                             [0x000d, 12B]  A list of brokers present in the cluster.
    |   +-- length                                uvarint                      = 2 (compact, n+1)                      [0x000d, 1B]   one sample element follows
    |   +-- MetadataResponseBroker[0]             MetadataResponseBroker       = struct                                [0x000e, 11B]
    |       +-- NodeId                            int32                        = 0                                     [0x000e, 4B]   The broker ID.
    |       +-- Host                              string                       = "" (compact, len+1=1)                 [0x0012, 1B]   The broker hostname.
    |       +-- Port                              int32                        = 0                                     [0x0013, 4B]   The broker port.
    |       +-- Rack                              string                       = "" (compact, len+1=1)                 [0x0017, 1B]   The rack of the broker, or null if it has not been assigned to a rack.
    |       +-- tagged_fields                     uvarint                      = 0                                     [0x0018, 1B]   number of tagged fields in this struct
    +-- ClusterId                                 string                       = "" (compact, len+1=1)                 [0x0019, 1B]   The cluster ID that responding broker belongs to.
    +-- ControllerId                              int32                        = 0                                     [0x001a, 4B]   The ID of the controller broker.
    +-- Topics                                    []MetadataResponseTopic      = 1 element                             [0x001e, 57B]  Each topic in the response.
    |   +-- length                                uvarint                      = 2 (compact, n+1)                      [0x001e, 1B]   one sample element follows
    |   +-- MetadataResponseTopic[0]              MetadataResponseTopic        = struct                                [0x001f, 56B]
    |       +-- ErrorCode                         int16                        = 0                                     [0x001f, 2B]   The topic error, or 0 if there was no error.
    |       +-- Name                              string                       = "" (compact, len+1=1)                 [0x0021, 1B]   The topic name. Null for non-existing topics queried by ID. This is never n...
    |       +-- TopicId                           uuid                         = 00000000-0000-0000-0000-000000000000  [0x0022, 16B]  The topic id. Zero for non-existing topics queried by name. This is never z...
    |       +-- IsInternal                        bool                         = false                                 [0x0032, 1B]   True if the topic is internal.
    |       +-- Partitions                        []MetadataResponsePartition  = 1 element                             [0x0033, 31B]  Each partition in the topic.
    |       |   +-- length                        uvarint                      = 2 (compact, n+1)                      [0x0033, 1B]   one sample element follows
    |       |   +-- MetadataResponsePartition[0]  MetadataResponsePartition    = struct                                [0x0034, 30B]
    |       |       +-- ErrorCode                 int16                        = 0                                     [0x0034, 2B]   The partition error, or 0 if there was no error.
    |       |       +-- PartitionIndex            int32                        = 0                                     [0x0036, 4B]   The partition index.
    |       |       +-- LeaderId                  int32                        = 0                                     [0x003a, 4B]   The ID of the leader broker.
    |       |       +-- LeaderEpoch               int32                        = 0                                     [0x003e, 4B]   The leader epoch of this partition.
    |       |       +-- ReplicaNodes              []int32                      = 1 element                             [0x0042, 5B]   The set of all nodes that host this partition.
    |       |       |   +-- length                uvarint                      = 2 (compact, n+1)                      [0x0042, 1B]   one sample element follows
    |       |       |   +-- int32[0]              int32                        = 0                                     [0x0043, 4B]
    |       |       +-- IsrNodes                  []int32                      = 1 element                             [0x0047, 5B]   The set of nodes that are in sync with the leader for this partition.
    |       |       |   +-- length                uvarint                      = 2 (compact, n+1)                      [0x0047, 1B]   one sample element follows
    |       |       |   +-- int32[0]              int32                        = 0                                     [0x0048, 4B]
    |       |       +-- OfflineReplicas           []int32                      = 1 element                             [0x004c, 5B]   The set of offline replicas of this partition.
    |       |       |   +-- length                uvarint                      = 2 (compact, n+1)                      [0x004c, 1B]   one sample element follows
    |       |       |   +-- int32[0]              int32                        = 0                                     [0x004d, 4B]
    |       |       +-- tagged_fields             uvarint                      = 0                                     [0x0051, 1B]   number of tagged fields in this struct
    |       +-- TopicAuthorizedOperations         int32                        = 0                                     [0x0052, 4B]   32-bit bitfield to represent authorized operations for this topic.
    |       +-- tagged_fields                     uvarint                      = 0                                     [0x0056, 1B]   number of tagged fields in this struct
    +-- ErrorCode                                 int16                        = 0                                     [0x0057, 2B]   The top-level error code, or 0 if there was no error.
    +-- tagged_fields                             uvarint                      = 0                                     [0x0059, 1B]   number of tagged fields in this struct

kafka message schema (.json)

{
  "apiKey": 3,
  "type": "response",
  "name": "MetadataResponse",
  // Version 1 adds fields for the rack of each broker, the controller id, and whether or not the topic is internal.
  //
  // Version 2 adds the cluster ID field.
  //
  // Version 3 adds the throttle time.
  //
  // Version 4 is the same as version 3.
  //
  // Version 5 adds a per-partition offline_replicas field. This field specifies
  // the list of replicas that are offline.
  //
  // Starting in version 6, on quota violation, brokers send out responses before throttling.
  //
  // Version 7 adds the leader epoch to the partition metadata.
  //
  // Starting in version 8, brokers can send authorized operations for topic and cluster.
  //
  // Version 9 is the first flexible version.
  //
  // Version 10 adds topicId.
  //
  // Version 11 deprecates ClusterAuthorizedOperations. This is now exposed
  // by the DescribeCluster API (KIP-700).
  // Version 12 supports topicId.
  // Version 13 supports top-level error code in the response.
  "validVersions": "0-13",
  "flexibleVersions": "9+",
  "fields": [
    { "name": "ThrottleTimeMs", "type": "int32", "versions": "3+", "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": "Brokers", "type": "[]MetadataResponseBroker", "versions": "0+",
      "about": "A list of brokers present in the cluster.", "fields": [
      { "name": "NodeId", "type": "int32", "versions": "0+", "mapKey": true, "entityType": "brokerId",
        "about": "The broker ID." },
      { "name": "Host", "type": "string", "versions": "0+",
        "about": "The broker hostname." },
      { "name": "Port", "type": "int32", "versions": "0+",
        "about": "The broker port." },
      { "name": "Rack", "type": "string", "versions": "1+", "nullableVersions": "1+", "ignorable": true, "default": "null",
        "about": "The rack of the broker, or null if it has not been assigned to a rack." }
    ]},
    { "name": "ClusterId", "type": "string", "nullableVersions": "2+", "versions": "2+", "ignorable": true, "default": "null",
      "about": "The cluster ID that responding broker belongs to." },
    { "name": "ControllerId", "type": "int32", "versions": "1+", "default": "-1", "ignorable": true, "entityType": "brokerId",
      "about": "The ID of the controller broker." },
    { "name": "Topics", "type": "[]MetadataResponseTopic", "versions": "0+",
      "about": "Each topic in the response.", "fields": [
      { "name": "ErrorCode", "type": "int16", "versions": "0+",
        "about": "The topic error, or 0 if there was no error." },
      { "name": "Name", "type": "string", "versions": "0+", "mapKey": true, "entityType": "topicName", "nullableVersions": "12+",
        "about": "The topic name. Null for non-existing topics queried by ID. This is never null when ErrorCode is zero. One of Name and TopicId is always populated." },
      { "name": "TopicId", "type": "uuid", "versions": "10+", "ignorable": true,
        "about": "The topic id. Zero for non-existing topics queried by name. This is never zero when ErrorCode is zero. One of Name and TopicId is always populated." },
      { "name": "IsInternal", "type": "bool", "versions": "1+", "default": "false", "ignorable": true,
        "about": "True if the topic is internal." },
      { "name": "Partitions", "type": "[]MetadataResponsePartition", "versions": "0+",
        "about": "Each partition in the topic.", "fields": [
        { "name": "ErrorCode", "type": "int16", "versions": "0+",
          "about": "The partition error, or 0 if there was no error." },
        { "name": "PartitionIndex", "type": "int32", "versions": "0+",
          "about": "The partition index." },
        { "name": "LeaderId", "type": "int32", "versions": "0+", "entityType": "brokerId",
          "about": "The ID of the leader broker." },
        { "name": "LeaderEpoch", "type": "int32", "versions": "7+", "default": "-1", "ignorable": true,
          "about": "The leader epoch of this partition." },
        { "name": "ReplicaNodes", "type": "[]int32", "versions": "0+", "entityType": "brokerId",
          "about": "The set of all nodes that host this partition." },
        { "name": "IsrNodes", "type": "[]int32", "versions": "0+", "entityType": "brokerId",
          "about": "The set of nodes that are in sync with the leader for this partition." },
        { "name": "OfflineReplicas", "type": "[]int32", "versions": "5+", "ignorable": true, "entityType": "brokerId",
          "about": "The set of offline replicas of this partition." }
      ]},
      { "name": "TopicAuthorizedOperations", "type": "int32", "versions": "8+", "default": "-2147483648",
        "about": "32-bit bitfield to represent authorized operations for this topic." }
    ]},
    { "name": "ClusterAuthorizedOperations", "type": "int32", "versions": "8-10", "default": "-2147483648",
      "about": "32-bit bitfield to represent authorized operations for this cluster." },
    { "name": "ErrorCode", "type": "int16", "versions": "13+", "ignorable": true,
      "about": "The top-level error code, or 0 if there was no error." }

  ]
}