> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-vector.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# upstash_kafka_topic

> Create and manage Kafka topics in Upstash.

<RequestExample>
  ```hcl example.tf
  # Not necessary if the topic belongs to an already created cluster.
  resource "upstash_kafka_cluster" "exampleKafkaCluster" {
    cluster_name = "Terraform_Upstash_Cluster"
    region       = "eu-west-1"
    multizone    = false
  }

  resource "upstash_kafka_topic" "exampleKafkaTopic" {
    topic_name       = "TerraformTopic"
    partitions       = 1
    retention_time   = 625135
    retention_size   = 725124
    max_message_size = 829213
    cleanup_policy   = "delete"

    # Here, you can use the newly created kafka_cluster resource (above) named exampleKafkaCluster.
    # And use its ID so that the topic binds to it.
    # Alternatively, provide the ID of an already created cluster.
    cluster_id = resource.upstash_kafka_cluster.exampleKafkaCluster.cluster_id
  }
  ```
</RequestExample>

## Schema

### Required

<ParamField query="cleanup_policy" type="string" required>
  Cleanup policy will be used in the topic. `compact` or `delete`
</ParamField>

<ParamField query="cluster_id" type="string" required>
  ID of the cluster the topic will be deployed in
</ParamField>

<ParamField query="max_message_size" type="number" required>
  Max message size in the topic
</ParamField>

<ParamField query="partitions" type="number" required>
  The number of partitions the topic will have
</ParamField>

<ParamField query="retention_size" type="number" required>
  Retention size of the messages in the topic
</ParamField>

<ParamField query="retention_time" type="number" required>
  Retention time of messages in the topic
</ParamField>

<ParamField query="topic_name" type="string" required>
  Name of the topic
</ParamField>

### Read-Only

<ResponseField name="creation_time" type="number">
  Creation time of the topic
</ResponseField>

<ResponseField name="id" type="string">
  The ID of this resource.
</ResponseField>

<ResponseField name="multizone" type="bool">
  Whether multizone replication is enabled
</ResponseField>

<ResponseField name="password" type="string">
  Password to be used in authenticating to the cluster
</ResponseField>

<ResponseField name="region" type="string">
  Region of the kafka topic
</ResponseField>

<ResponseField name="rest_endpoint" type="string">
  REST endpoint of the kafka topic
</ResponseField>

<ResponseField name="state" type="string">
  State of the credential. `active` or `deleted`
</ResponseField>

<ResponseField name="tcp_endpoint" type="string">
  TCP endpoint of the kafka topic
</ResponseField>

<ResponseField name="topic_id" type="string">
  Unique cluster ID for created topic
</ResponseField>

<ResponseField name="username" type="string">
  Base64 encoded username to be used in authenticating to the cluster
</ResponseField>
