Create topic
Create a new pub/sub topic.
POST
/topics
Create a new pub/sub topic.
Authentication
API Key (header: X-API-Key) API Key (cookie: better-auth.session_token)
Request Body required
Request body
application/jsonorg_id
string
Organization ID (defaults to auth context)
env_id
string
Environment ID (defaults to auth context)
name
string
REQUIRED
Topic name
slug
string
REQUIRED
URL-safe slug for publishing
description
string
Optional description
schema
object
Optional JSON Schema for validation
Responses
201
Topic created
application/jsontopic
object | null
REQUIRED
id
string
REQUIRED
org_id
string
REQUIRED
env_id
string
REQUIRED
name
string
REQUIRED
slug
string
REQUIRED
description
string | null
REQUIRED
schema
string | null
REQUIRED
status
string
REQUIRED
created_at
string
REQUIRED
updated_at
string
REQUIRED
400
Bad request
401
Unauthorized
409
Slug already exists
curl -X POST 'https://hookstream.io/v1/topics' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "org_id": "string", "env_id": "string", "name": "order.events", "slug": "order-events", "description": "string", "schema": {}}'
const response = await fetch('https://hookstream.io/v1/topics', { method: 'POST', headers: { "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ "org_id": "string", "env_id": "string", "name": "order.events", "slug": "order-events", "description": "string", "schema": {} })});const data = await response.json();console.log(data);
import requestsheaders = { 'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://hookstream.io/v1/topics', headers=headers, json={ "org_id": "string", "env_id": "string", "name": "order.events", "slug": "order-events", "description": "string", "schema": {}})print(response.json())
package mainimport ( "fmt" "io" "net/http" "strings")func main() { body := strings.NewReader(`{ "org_id": "string", "env_id": "string", "name": "order.events", "slug": "order-events", "description": "string", "schema": {}}`) req, _ := http.NewRequest("POST", "https://hookstream.io/v1/topics", body) req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN") req.Header.Set("Content-Type", "application/json") resp, _ := http.DefaultClient.Do(req) defer resp.Body.Close() result, _ := io.ReadAll(resp.Body) fmt.Println(string(result))}
201
Response
{ "topic": { "id": "<string>", "org_id": "<string>", "env_id": "<string>", "name": "<string>", "slug": "<string>", "description": "<string>", "schema": "<string>", "status": "<string>", "created_at": "<string>", "updated_at": "<string>" }}
API Playground
Try this endpoint
POST
/topics