Create Topic
POST /public/v1/topics
Creates a new topic in the connected Kafka cluster with the specified configuration.
Request
Body Parameters
| Field | Type | Description | Required |
|---|---|---|---|
name | string | Name of the topic to create | Yes |
metadata | object (TopicMetadata) | Topic metadata configuration | Yes |
configs | array of objects (TopicConfig) | Key-value configuration pairs | Optional |
TopicMetadata Structure
| Field | Type | Description | Required |
|---|---|---|---|
partitions | integer | Number of partitions for the topic | Yes |
replicationFactor | integer | Replication factor for the topic | Yes |
TopicConfig Structure
| Field | Type | Description | Required |
|---|---|---|---|
name | string | Configuration parameter name | Yes |
value | string | Configuration parameter value | Yes |
Example Request
curl --location 'https://your-instance.com/public/v1/topics' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-api-key>' \
--data-raw '{
"name": "my.new.topic",
"metadata": {
"partitions": 3,
"replicationFactor": 2
},
"configs": [
{
"name": "cleanup.policy",
"value": "delete"
},
{
"name": "retention.ms",
"value": "604800000"
}
]
}'
Response
HTTP Status Code: 200 OK
Response Body: (empty)
Possible Errors
| Status Code | Description | Solution |
|---|---|---|
| 400 | Invalid request | Check your request payload format |
| 401 | Unauthorized | Check your API key |
| 409 | Topic already exists | Use a different topic name or delete the existing topic first |
Best Practices
- Choose an appropriate partition count based on expected throughput and parallelism.
- Set a replication factor of at least 2–3 for data durability.
- Configure retention policies carefully according to your data lifecycle requirements.