Skip to Content

Create a topic

Creates a topic in the caller's or requested namespace.

POST
/v1/topics

Creates a topic in the caller's or requested namespace. The subscription default is opt_out when omitted. Sending defaults must be compatible with that namespace. An organization holds at most 200 topics.

Authorization

apiKey
headerx-api-key<token>

Request Body

application/json
  1. body
name*string
Length1 <= length <= 120
description?string|null|null
namespaceId?|null|null
default?|null
defaultSenderId?|null|null
replyMailboxId?|null|null
templateId?|null|null

Response Body

Topic

application/json
  1. response
id*TopicId
Match^tpc_[0-9a-hjkmnp-tv-z]{16,24}$
namespaceId*|null
name*string
description*string|null
default*string
Value in"opt_out""opt_in"
isDefault*boolean
defaultSenderId*|null
replyMailboxId*|null
templateId*|null
subscriptions*
createdAt*string
updatedAt*string
Example Request
import { createClient } from "samva";

const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });

const result = await samva.topics.create({
  "name": "example"
});
Example Response
{
  "id": "string",
  "namespaceId": "string",
  "name": "string",
  "description": "string",
  "default": "opt_out",
  "isDefault": true,
  "defaultSenderId": "string",
  "replyMailboxId": "string",
  "templateId": "string",
  "subscriptions": {
    "sms": {
      "subscribed": 0,
      "unsubscribed": 0
    },
    "whatsapp": {
      "subscribed": 0,
      "unsubscribed": 0
    },
    "email": {
      "subscribed": 0,
      "unsubscribed": 0
    }
  },
  "createdAt": "string",
  "updatedAt": "string"
}

Related documentation