Skip to main content
POST
/
topics
Create a new Kafka topic
curl --request POST \
  --url https://api.streamkap.com/topics \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "topic_name": "<string>",
  "num_partitions": 1,
  "replication_factor": 2,
  "min_insync_replicas": 2,
  "retention_ms": 0,
  "retention_bytes": 0,
  "max_message_bytes": 2,
  "custom_configs": {},
  "tags": [
    "<string>"
  ]
}
'
import requests

url = "https://api.streamkap.com/topics"

payload = {
"topic_name": "<string>",
"num_partitions": 1,
"replication_factor": 2,
"min_insync_replicas": 2,
"retention_ms": 0,
"retention_bytes": 0,
"max_message_bytes": 2,
"custom_configs": {},
"tags": ["<string>"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
topic_name: '<string>',
num_partitions: 1,
replication_factor: 2,
min_insync_replicas: 2,
retention_ms: 0,
retention_bytes: 0,
max_message_bytes: 2,
custom_configs: {},
tags: ['<string>']
})
};

fetch('https://api.streamkap.com/topics', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.streamkap.com/topics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'topic_name' => '<string>',
'num_partitions' => 1,
'replication_factor' => 2,
'min_insync_replicas' => 2,
'retention_ms' => 0,
'retention_bytes' => 0,
'max_message_bytes' => 2,
'custom_configs' => [

],
'tags' => [
'<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.streamkap.com/topics"

payload := strings.NewReader("{\n \"topic_name\": \"<string>\",\n \"num_partitions\": 1,\n \"replication_factor\": 2,\n \"min_insync_replicas\": 2,\n \"retention_ms\": 0,\n \"retention_bytes\": 0,\n \"max_message_bytes\": 2,\n \"custom_configs\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.streamkap.com/topics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"topic_name\": \"<string>\",\n \"num_partitions\": 1,\n \"replication_factor\": 2,\n \"min_insync_replicas\": 2,\n \"retention_ms\": 0,\n \"retention_bytes\": 0,\n \"max_message_bytes\": 2,\n \"custom_configs\": {},\n \"tags\": [\n \"<string>\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.streamkap.com/topics")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"topic_name\": \"<string>\",\n \"num_partitions\": 1,\n \"replication_factor\": 2,\n \"min_insync_replicas\": 2,\n \"retention_ms\": 0,\n \"retention_bytes\": 0,\n \"max_message_bytes\": 2,\n \"custom_configs\": {},\n \"tags\": [\n \"<string>\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "name": "<string>",
  "entity": {
    "entity_id": "<string>",
    "name": "<string>",
    "topic_ids": [
      "<string>"
    ],
    "topic_db_ids": [
      "<string>"
    ],
    "display_name": "<string>",
    "filtered_snapshot_language": "<string>"
  },
  "num_partitions": 123,
  "replication_factor": 123,
  "prefix": "<string>",
  "serialization": {
    "key_format": "unknown",
    "value_format": "unknown",
    "key_converter": "<string>",
    "value_converter": "<string>",
    "schema_registry_enabled": false
  },
  "warnings": []
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
topic_name
string
required

Kafka topic name

Required string length: 1 - 249
num_partitions
integer
default:1

Number of partitions

Required range: x >= 1
replication_factor
integer | null

Replication factor (defaults to broker count)

Required range: x >= 1
cleanup_policy
enum<string> | null

Topic cleanup policy

Available options:
delete,
compact,
delete,compact
min_insync_replicas
integer | null

Minimum in-sync replicas

Required range: x >= 1
retention_ms
integer | null

Time to retain data in ms (-1 for unlimited)

Required range: x >= -1
retention_bytes
integer | null

Max size on disk in bytes (-1 for unlimited)

Required range: x >= -1
max_message_bytes
integer | null

Maximum message size in bytes

Required range: x >= 1
custom_configs
Custom Configs · object | null

Additional topic configs as key-value pairs

tags
string[] | null

Tag IDs to assign to the topic

Response

Successful Response

id
string
required
name
string
required
entity
TopicDetailsEntity · object
required
num_partitions
integer
required
replication_factor
integer
required
prefix
string | null
serialization
TopicSerialization · object | null

Serialization format information for a topic.

Topics inherit their serialization format from their producer (source/transform). Most Streamkap sources use Avro by default with Schema Registry.

warnings
CreateTopicWarning · object[]