(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
- list - Get topic list filtered
- delete - Delete topic
- retrieve - Get topic
- rename - Rename a topic
Create a topic
from novu_py import Novu
import os
with Novu(
secret_key=os.getenv("NOVU_SECRET_KEY", ""),
) as novu:
res = novu.topics.create(create_topic_request_dto={
"key": "<key>",
"name": "<value>",
})
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
create_topic_request_dto |
models.CreateTopicRequestDto | ✔️ | N/A |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerCreateTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
models.ErrorDto | 414 | application/json |
models.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
models.ValidationErrorDto | 422 | application/json |
models.ErrorDto | 500 | application/json |
models.APIError | 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
from novu_py import Novu
import os
with Novu(
secret_key=os.getenv("NOVU_SECRET_KEY", ""),
) as novu:
res = novu.topics.list(key="exampleKey")
# Handle response
print(res)
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
page |
Optional[int] | ➖ | The page number to retrieve (starts from 0) | 0 |
page_size |
Optional[int] | ➖ | The number of items to return per page (default: 10) | 10 |
key |
Optional[str] | ➖ | A filter key to apply to the results | exampleKey |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerListTopicsResponse
Error Type | Status Code | Content Type |
---|---|---|
models.ErrorDto | 414 | application/json |
models.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
models.ValidationErrorDto | 422 | application/json |
models.ErrorDto | 500 | application/json |
models.APIError | 4XX, 5XX | */* |
Delete a topic by its topic key if it has no subscribers
from novu_py import Novu
import os
with Novu(
secret_key=os.getenv("NOVU_SECRET_KEY", ""),
) as novu:
res = novu.topics.delete(topic_key="<value>")
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
topic_key |
str | ✔️ | The topic key |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerDeleteTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
models.ErrorDto | 414 | application/json |
models.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
models.ValidationErrorDto | 422 | application/json |
models.ErrorDto | 500 | application/json |
models.APIError | 4XX, 5XX | */* |
Get a topic by its topic key
from novu_py import Novu
import os
with Novu(
secret_key=os.getenv("NOVU_SECRET_KEY", ""),
) as novu:
res = novu.topics.retrieve(topic_key="<value>")
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
topic_key |
str | ✔️ | The topic key |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerGetTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
models.ErrorDto | 414 | application/json |
models.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
models.ValidationErrorDto | 422 | application/json |
models.ErrorDto | 500 | application/json |
models.APIError | 4XX, 5XX | */* |
Rename a topic by providing a new name
from novu_py import Novu
import os
with Novu(
secret_key=os.getenv("NOVU_SECRET_KEY", ""),
) as novu:
res = novu.topics.rename(topic_key="<value>", rename_topic_request_dto={
"name": "<value>",
})
# Handle response
print(res)
Parameter | Type | Required | Description |
---|---|---|---|
topic_key |
str | ✔️ | The topic key |
rename_topic_request_dto |
models.RenameTopicRequestDto | ✔️ | N/A |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerRenameTopicResponse
Error Type | Status Code | Content Type |
---|---|---|
models.ErrorDto | 414 | application/json |
models.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
models.ValidationErrorDto | 422 | application/json |
models.ErrorDto | 500 | application/json |
models.APIError | 4XX, 5XX | */* |