> For the complete documentation index, see [llms.txt](https://docs.lenses.io/latest/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lenses.io/latest/devx/5.5/user-guide/cli/data/kafka-topics.md).

# Kafka topics

## View all topics <a href="#view-all-topics" id="view-all-topics"></a>

The optional names flag wil display only the names of the topics. If you use the –unwrap flag, each topic name will be displayed on a new line as text:

```bash
lenses-cli topics [--names [--unwrap]]
```

## View a specific topic <a href="#view-a-specific-topic" id="view-a-specific-topic"></a>

```bash
lenses-cli topic --name=reddit_posts
```

## Create topics <a href="#create-topics" id="create-topics"></a>

```bash
lenses-cli topic create \
    --name="topicName" \
    --replication=1 \
    --partitions=1 \
    --configs="{\"max.message.bytes\": \"1000010\"}"
```

Update from a file:

```bash
lenses-cli topic create ./topic.yml
```

Example file:

```yaml
name: topicName
replication: 1
partitions: 1
configs:
  max.message.bytes: "1000010"
```

## Update a topic’s configuration <a href="#update-a-topics-configuration" id="update-a-topics-configuration"></a>

```bash
lenses-cli topic update \
    --name="topic2" \
    --configs="{\"max.message.bytes\": \"1000020\"}"
```

Update from a file:

```bash
lenses-cli topic update ./topic.yaml
```

Example file:

```yaml
name: topicName
replication: 1
partitions: 1
configs:
  max.message.bytes: "1000010"
```

## Update a topic’s metadata configuration <a href="#update-a-topics-metadata-configuration" id="update-a-topics-metadata-configuration"></a>

```bash
# first change the key/value type
lenses-cli topics metadata set \
    --name=topicName \
    --key-type=bytes \
    --value-type=xml

# now you may change its schema
lenses-cli topics metadata set \
    --name=topicName \
    --key-type=bytes \
    --key-schema="{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"keyField\",\"type\":\"string\"}]}" \
    --value-type=xml \
    --value-schema="{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"valueField\",\"type\":\"string\"}]}"
```

Update from a file:

```bash
lenses-cli topic update ./topic.yaml
```

Example file:

```yaml
topicName: topicName
keyType: bytes
valueType: xml
valueSchema: "{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"heading3\",\"type\":\"string\"}]}"
```

## Delete topics <a href="#delete-topics" id="delete-topics"></a>

```bash
lenses-cli topic delete --name="topic2"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lenses.io/latest/devx/5.5/user-guide/cli/data/kafka-topics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
