(topics)
Topics are a way to group subscribers together so that they can be notified of events at once. A topic is identified by a custom key. This can be helpful for things like sending out marketing emails or notifying users of new features. Topics can also be used to send notifications to the subscribers who have been grouped together based on their interests, location, activities and much more. https://docs.novu.co/subscribers/topics
- create - Topic creation
- delete - Delete topic
- get - Get topic
- list - Get topic list filtered
- rename - Rename a topic
Create a topic
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$createTopicRequestDto = new Components\CreateTopicRequestDto(
key: '<key>',
name: '<value>',
);
$response = $sdk->topics->create(
createTopicRequestDto: $createTopicRequestDto,
idempotencyKey: '<value>'
);
if ($response->createTopicResponseDto !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
createTopicRequestDto |
Components\CreateTopicRequestDto | ✔️ | N/A |
idempotencyKey |
?string | ➖ | A header for idempotency purposes |
?Operations\TopicsControllerCreateTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ErrorDto | 414 | application/json |
Errors\ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
Errors\ValidationErrorDto | 422 | application/json |
Errors\ErrorDto | 500 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Delete a topic by its topic key if it has no subscribers
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$response = $sdk->topics->delete(
topicKey: '<value>',
idempotencyKey: '<value>'
);
if ($response->statusCode === 200) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
topicKey |
string | ✔️ | The topic key |
idempotencyKey |
?string | ➖ | A header for idempotency purposes |
?Operations\TopicsControllerDeleteTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ErrorDto | 414 | application/json |
Errors\ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
Errors\ValidationErrorDto | 422 | application/json |
Errors\ErrorDto | 500 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Get a topic by its topic key
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$response = $sdk->topics->get(
topicKey: '<value>',
idempotencyKey: '<value>'
);
if ($response->getTopicResponseDto !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
topicKey |
string | ✔️ | The topic key |
idempotencyKey |
?string | ➖ | A header for idempotency purposes |
?Operations\TopicsControllerGetTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ErrorDto | 414 | application/json |
Errors\ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
Errors\ValidationErrorDto | 422 | application/json |
Errors\ErrorDto | 500 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Returns a list of topics that can be paginated using the page
query parameter and filtered by the topic key with the key
query parameter
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$response = $sdk->topics->list(
page: 0,
pageSize: 10,
key: 'exampleKey',
idempotencyKey: '<value>'
);
if ($response->filterTopicsResponseDto !== null) {
// handle response
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
page |
?int | ➖ | The page number to retrieve (starts from 0) | 0 |
pageSize |
?int | ➖ | The number of items to return per page (default: 10) | 10 |
key |
?string | ➖ | A filter key to apply to the results | exampleKey |
idempotencyKey |
?string | ➖ | A header for idempotency purposes |
?Operations\TopicsControllerListTopicsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ErrorDto | 414 | application/json |
Errors\ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
Errors\ValidationErrorDto | 422 | application/json |
Errors\ErrorDto | 500 | application/json |
Errors\APIException | 4XX, 5XX | */* |
Rename a topic by providing a new name
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$renameTopicRequestDto = new Components\RenameTopicRequestDto(
name: '<value>',
);
$response = $sdk->topics->rename(
topicKey: '<value>',
renameTopicRequestDto: $renameTopicRequestDto,
idempotencyKey: '<value>'
);
if ($response->renameTopicResponseDto !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
topicKey |
string | ✔️ | The topic key |
renameTopicRequestDto |
Components\RenameTopicRequestDto | ✔️ | N/A |
idempotencyKey |
?string | ➖ | A header for idempotency purposes |
?Operations\TopicsControllerRenameTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ErrorDto | 414 | application/json |
Errors\ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
Errors\ValidationErrorDto | 422 | application/json |
Errors\ErrorDto | 500 | application/json |
Errors\APIException | 4XX, 5XX | */* |