Create topic Run in API Explorer

POST /v1/topics

Create a topic.

Query parameters

  • validate_only boolean

    If true, makes this request a dry run; everything is validated but no topics are actually created.

application/json

Body Required

The topic to create.

  • configs array[object]

    An array of key-value config pairs for a topic. These correspond to Kafka topic-level configs.

    Hide configs attributes Show configs attributes object
    • name string

      A topic-level config key (e.g. segment.bytes).

    • value string | null

      A topic-level config value (e.g. 1073741824).

  • name string

    Name of topic.

  • partition_count integer(int32) | null

    The number of partitions to give the topic. If specifying partitions manually (see replica_assignments), set to -1. Or, to use the cluster default partition count, set to null.

  • replica_assignments array[object]

    Manually specify broker ID assignments for partition replicas. If manually assigning replicas, both replication_factor and partition_count must be -1.

    Hide replica_assignments attributes Show replica_assignments attributes object
    • partition_id integer(int32)

      A partition to create.

    • replica_ids array[integer(int32)]

      The broker IDs the partition replicas are assigned to.

  • replication_factor integer(int32) | null

    The number of replicas every partition must have. If specifying partitions manually (see replica_assignments), set to -1. Or, to use the cluster default replication factor, set to null.

Responses

  • 201 application/json

    Topic created

    Hide response attributes Show response attributes object
    • partition_count integer(int32)

      The number of partitions created for the topic. This field has a default value of -1, which may be returned if the broker does not support v5+ of this request which added support for returning this information.

    • replication_factor integer(int32)

      The number of replicas per topic partition. This field has a default of -1, which may be returned if the broker does not support v5+ of this request which added support for returning this information.

    • topic_name string

      Name of topic.

  • 401 application/json

    Unauthenticated.

    Hide response attributes Show response attributes object
    • code string(int32)

      RPC status code, as described here.

      Values are OK, CANCELLED, UNKNOWN, INVALID_ARGUMENT, DEADLINE_EXCEEDED, NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED, UNAUTHENTICATED, RESOURCE_EXHAUSTED, FAILED_PRECONDITION, ABORTED, OUT_OF_RANGE, UNIMPLEMENTED, INTERNAL, UNAVAILABLE, or DATA_LOSS.

    • details array[object]

      A list of messages that carries the error details.

      Details of the error.

      Details of the error.

      One of:
    • message string

      Detailed error message. No compatibility guarantees are given for the text contained in this message.

  • 500 application/json

    Internal Server Error. Reach out to support.

    Hide response attributes Show response attributes object
    • code string(int32)

      RPC status code, as described here.

      Values are OK, CANCELLED, UNKNOWN, INVALID_ARGUMENT, DEADLINE_EXCEEDED, NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED, UNAUTHENTICATED, RESOURCE_EXHAUSTED, FAILED_PRECONDITION, ABORTED, OUT_OF_RANGE, UNIMPLEMENTED, INTERNAL, UNAVAILABLE, or DATA_LOSS.

    • details array[object]

      A list of messages that carries the error details.

      Details of the error.

      Details of the error.

      One of:
    • message string

      Detailed error message. No compatibility guarantees are given for the text contained in this message.

  • default application/json

    An unexpected error response.

    Hide response attributes Show response attributes object
    • code string(int32)

      RPC status code, as described here.

      Values are OK, CANCELLED, UNKNOWN, INVALID_ARGUMENT, DEADLINE_EXCEEDED, NOT_FOUND, ALREADY_EXISTS, PERMISSION_DENIED, UNAUTHENTICATED, RESOURCE_EXHAUSTED, FAILED_PRECONDITION, ABORTED, OUT_OF_RANGE, UNIMPLEMENTED, INTERNAL, UNAVAILABLE, or DATA_LOSS.

    • details array[object]

      A list of messages that carries the error details.

      Details of the error.

      Details of the error.

      One of:
    • message string

      Detailed error message. No compatibility guarantees are given for the text contained in this message.

POST /v1/topics
curl \
 --request POST 'https://{dataplane_api_subdomain}.cloud.redpanda.com/v1/topics' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"configs":[{"name":"string","value":"string"}],"name":"string","partition_count":42,"replica_assignments":[{"partition_id":42,"replica_ids":[42]}],"replication_factor":42}'
Request examples
{
  "configs": [
    {
      "name": "string",
      "value": "string"
    }
  ],
  "name": "string",
  "partition_count": 42,
  "replica_assignments": [
    {
      "partition_id": 42,
      "replica_ids": [
        42
      ]
    }
  ],
  "replication_factor": 42
}
Response examples (201)
{
  "partition_count": 42,
  "replication_factor": 42,
  "topic_name": "string"
}
Response examples (401)
{
  "code": "OK",
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.BadRequest",
      "field_violations": [
        {
          "description": "string",
          "field": "string"
        }
      ]
    }
  ],
  "message": "string"
}
Response examples (500)
{
  "code": "OK",
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.BadRequest",
      "field_violations": [
        {
          "description": "string",
          "field": "string"
        }
      ]
    }
  ],
  "message": "string"
}
Response examples (default)
{
  "code": "OK",
  "details": [
    {
      "@type": "type.googleapis.com/google.rpc.BadRequest",
      "field_violations": [
        {
          "description": "string",
          "field": "string"
        }
      ]
    }
  ],
  "message": "string"
}