---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/reference/ydb-cli/topic-create.md
  - https://ydb.tech/docs/ru/reference/ydb-cli/topic-create.md
  - href: en/reference/ydb-cli/topic-create.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/reference/ydb-cli/topic-create.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# Creating a topic

You can use the `topic create` subcommand to create a new topic.

General format of the command:

```bash
ydb [global options...] topic create [options...] <topic-path>
```

* `global options`: [Global parameters](https://ydb.tech/docs/en/reference/ydb-cli/commands/global-options.md).
* `options`: [Parameters of the subcommand](#options).
* `topic-path`: Topic path.

View the description of the create topic command:

```bash
ydb topic create --help
```

## Parameters of the subcommand {#options}

| Name                           | Description                                                                                                                                                                                                                                                                                                                                                                     |
|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--partitions-count`           | The number of topic [partitions](../../concepts/datamodel/topic.md#partitioning).<br/>The default value is `1`.                                                                                                                                                                                                                                                                           |
| `--retention-period`           | Data retention time in a topic. A positive number followed by a unit of time.<br/>The following units are supported:<ul><li>`s` – seconds;</li><li>`m` – minutes;</li><li>`h` – hours;</li><li>`d` – days.</li></ul>The default value is `18h`.                                                                                                                                 |
| `--partition-write-speed-kbps` | The maximum write speed to a [partition](../../concepts/datamodel/topic.md#partitioning), specified in KB/s.<br/>The default value is `1024`.                                                                                                                                                                                                                                             |
| `--retention-storage-mb`       | The maximum storage size, specified in MB. When the limit is reached, the oldest data will be deleted. The consumed space may exceed the set value when autopartitioning is enabled.<br/>The default value is `0` (no limit).                                                                                                                                                                                                                                 |
| `--supported-codecs`           | Supported data compression methods. Set with a comma.<br/>The default value is `raw`.<br/>Possible values:<ul><li>`RAW`: No compression.</li><li>`ZSTD`: [zstd](https://en.wikipedia.org/wiki/Zstandard) compression.</li><li>`GZIP`: [gzip](https://en.wikipedia.org/wiki/Gzip) compression.</li><li>`LZOP`: [lzop](https://en.wikipedia.org/wiki/Lzop) compression.</li></ul> |
| `--metering-mode`              | The topic pricing method for a serverless database.<br/>Possible values:<ul><li>`request-units`: Based on actual usage.</li><li>`reserved-capacity`: Based on dedicated resources.</li></ul>                                                                                                                                                                                    |

## Examples {examples}

<!-- source: en/_includes/ydb-cli-profile.md -->
{% note info %}

The examples use the `quickstart` profile. To learn more, see [Creating a profile to connect to a test database](https://ydb.tech/docs/en/reference/ydb-cli/profile/create.md#quickstart).

{% endnote %}
<!-- endsource: en/_includes/ydb-cli-profile.md -->

Create a topic with 2 partitions, `RAW` and `GZIP` compression methods, message retention time of 2 hours, and the `my-topic` path:

```bash
ydb -p quickstart topic create \
  --partitions-count 2 \
  --supported-codecs raw,gzip \
  --retention-period 2h \
  my-topic
```

View parameters of the created topic:

```bash
ydb -p quickstart scheme describe my-topic
```

Result:

```text
RetentionPeriod: 2h
PartitionsCount: 2
SupportedCodecs: RAW, GZIP
```
