Create a topic
POST /topics
A category contacts subscribe to, with a default for those who never chose.
Body
namestringRequiredUp to 50 characters, unique among live topics.
default_subscriptionstringRequiredopt_inoropt_out: what a contact with no explicit choice is treated as. Fixed after creation.descriptionstringUp to 200 characters, shown on the preference page.
visibilitystringpubliclists the topic on every contact's preference page;private(the default) only for contacts already opted in.
Request
curl -X POST "https://api.rasket.com/topics" \
-H "Authorization: Bearer $RASKET_API_KEY" \
-H "User-Agent: acme-billing/1.0" \
-H "Content-Type: application/json" \
-d '{
"name": "Product updates",
"description": "What shipped this month.",
"default_subscription": "opt_in",
"visibility": "public"
}'const response = await fetch("https://api.rasket.com/topics", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RASKET_API_KEY}`,
"User-Agent": "acme-billing/1.0",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Product updates",
description: "What shipped this month.",
default_subscription: "opt_in",
visibility: "public"
}),
});
const { id } = await response.json();import os
import requests
response = requests.post(
"https://api.rasket.com/topics",
headers={
"Authorization": f"Bearer {os.environ['RASKET_API_KEY']}",
"User-Agent": "acme-billing/1.0",
},
json={
"name": "Product updates",
"description": "What shipped this month.",
"default_subscription": "opt_in",
"visibility": "public"
},
)
id = response.json()["id"]Response 201
{
"object": "topic",
"id": "0199d2f1-4c4e-7a20-9c31-6f2b8a0e5d17"
}- A live topic with the same name is
422 invalid_parameter. - A broadcast scoped to a topic goes only to contacts whose effective subscription to it is
opt_in.