Create or update a topic

Creates a new topic if it does not exist, or updates an existing topic if it already exists

POST
/v2/topics

Authorization

Authorization<token>

API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".

In: header

Request Body

application/jsonRequired
keyRequiredstring

The unique key identifier for the topic. The key must contain only alphanumeric characters (a-z, A-Z, 0-9), hyphens (-), underscores (_), colons (:), or be a valid email address.

Minimum length: 1Maximum length: 100
namestring

The display name for the topic

Minimum length: 0Maximum length: 100

Header Parameters

idempotency-keystring

A header for idempotency purposes

Response Body

OK

_idRequiredstring

The identifier of the topic

keyRequiredstring

The unique key of the topic

namestring

The name of the topic

createdAtstring

The date the topic was created

updatedAtstring

The date the topic was last updated

export interface Response {
  /**
   * The identifier of the topic
   */
  _id: string;
  /**
   * The unique key of the topic
   */
  key: string;
  /**
   * The name of the topic
   */
  name?: string;
  /**
   * The date the topic was created
   */
  createdAt?: string;
  /**
   * The date the topic was last updated
   */
  updatedAt?: string;
}
 
curl -X POST "https://api.novu.co/v2/topics" \
  -H "idempotency-key: string" \
  -H "Authorization: <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "task:12345",
    "name": "Task Title"
  }'
{
  "_id": "64da692e9a94fb2e6449ad06",
  "key": "product-updates",
  "name": "Product Updates",
  "createdAt": "2023-08-15T00:00:00.000Z",
  "updatedAt": "2023-08-15T00:00:00.000Z"
}