Create subscription
Subscribe a destination to a topic with optional filters and transforms.
POST
/topics/{id}/subscriptions
Subscribe a destination to a topic with optional filters and transforms.
Authentication
API Key (header: X-API-Key) API Key (cookie: better-auth.session_token)
Path Parameters
id
string
required
path
Resource ID (32-char hex)
Example:
"a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"Request Body required
Request body
application/jsondestination_id
string
REQUIRED
Destination ID to subscribe
filter_rules
object[]
Optional filter rules for this subscription
Array of:
transform_expression
string
Optional JSONata transform expression
Responses
201
Subscription created
application/jsonsubscription
unknown
REQUIRED
400
Bad request
401
Unauthorized
404
Not found
409
Already subscribed
curl -X POST 'https://hookstream.io/v1/topics/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6/subscriptions' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"destination_id": "string",
"filter_rules": [
{}
],
"transform_expression": "string"
}'
const response = await fetch('https://hookstream.io/v1/topics/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6/subscriptions', {
method: 'POST',
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"destination_id": "string",
"filter_rules": [
{}
],
"transform_expression": "string"
})
});
const data = await response.json();
console.log(data);
import requests
headers = {
'Authorization': 'Bearer YOUR_API_TOKEN'
}
response = requests.post('https://hookstream.io/v1/topics/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6/subscriptions', headers=headers, json={
"destination_id": "string",
"filter_rules": [
{}
],
"transform_expression": "string"
})
print(response.json())
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"destination_id": "string",
"filter_rules": [
{}
],
"transform_expression": "string"
}`)
req, _ := http.NewRequest("POST", "https://hookstream.io/v1/topics/a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6/subscriptions", 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
{
"subscription": {
"id": "<string>",
"org_id": "<string>",
"env_id": "<string>",
"topic_id": "<string>",
"destination_id": "<string>",
"filter_rules": "<string>",
"transform_expression": "<string>",
"enabled": 123,
"created_at": "<string>",
"destination_name": "<string>"
}
}
POST
/topics/{id}/subscriptions