Skip to main content
POST
/
v2
/
topics
PHP
declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$createUpdateTopicRequestDto = new Components\CreateUpdateTopicRequestDto(
    key: 'task:12345',
    name: 'Task Title',
);

$response = $sdk->topics->create(
    createUpdateTopicRequestDto: $createUpdateTopicRequestDto
);

if ($response->topicResponseDto !== null) {
    // handle response
}
{
  "_id": "64da692e9a94fb2e6449ad06",
  "key": "product-updates",
  "name": "Product Updates",
  "createdAt": "2023-08-15T00:00:00.000Z",
  "updatedAt": "2023-08-15T00:00:00.000Z"
}

Authorizations

Authorization
string
header
required

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

Headers

idempotency-key
string

A header for idempotency purposes

Query Parameters

failIfExists
boolean

If true, the request will fail if a topic with the same key already exists

Body

application/json
key
string
required

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.

Required string length: 1 - 100
Example:

"task:12345"

name
string

The display name for the topic

Maximum string length: 100
Example:

"Task Title"

Response

OK

_id
string
required

The identifier of the topic

Example:

"64da692e9a94fb2e6449ad06"

key
string
required

The unique key of the topic

Example:

"product-updates"

name
string

The name of the topic

Example:

"Product Updates"

createdAt
string

The date the topic was created

Example:

"2023-08-15T00:00:00.000Z"

updatedAt
string

The date the topic was last updated

Example:

"2023-08-15T00:00:00.000Z"