Publish to topic
Publish an event to a topic by slug. The event will be fanned out to all subscribers.
POST
/topics/{slug}/publish
Publish an event to a topic by slug. The event will be fanned out to all subscribers.
Authentication
API Key (header: X-API-Key) API Key (cookie: better-auth.session_token)
Path Parameters
slug
string
required
path
Topic slug
Example:
"order-events"Request Body required
Event payload
application/jsonResponses
200
Event published
application/jsonevent_id
string
REQUIRED
topic
string
REQUIRED
received_at
string
REQUIRED
401
Unauthorized
404
Topic not found or inactive
curl -X POST 'https://hookstream.io/v1/topics/order-events/publish' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{}'
const response = await fetch('https://hookstream.io/v1/topics/order-events/publish', {
method: 'POST',
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({})
});
const data = await response.json();
console.log(data);
import requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
response = requests.post('https://hookstream.io/v1/topics/order-events/publish', headers=headers, json={})
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{}`)
req, _ := http.NewRequest("POST", "https://hookstream.io/v1/topics/order-events/publish", 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))
}
200
Response
{
"event_id": "<string>",
"topic": "<string>",
"received_at": "<string>"
}
POST
/topics/{slug}/publish