Skip to content

Latest commit

 

History

History
238 lines (164 loc) · 15.5 KB

README.md

File metadata and controls

238 lines (164 loc) · 15.5 KB

Topics

(topics)

Overview

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

Available Operations

create

Create a topic

Example Usage

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)

Parameters

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.

Response

models.TopicsControllerCreateTopicResponse

Errors

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 */*

list

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

Example Usage

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)

Parameters

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.

Response

models.TopicsControllerListTopicsResponse

Errors

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

Delete a topic by its topic key if it has no subscribers

Example Usage

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)

Parameters

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.

Response

models.TopicsControllerDeleteTopicResponse

Errors

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 */*

retrieve

Get a topic by its topic key

Example Usage

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)

Parameters

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.

Response

models.TopicsControllerGetTopicResponse

Errors

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

Rename a topic by providing a new name

Example Usage

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)

Parameters

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.

Response

models.TopicsControllerRenameTopicResponse

Errors

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 */*