- list - List topic subscriptions
- create - Create topic subscriptions
- delete - Delete topic subscriptions
- get_subscription - Retrieve a topic subscription
- update - Update a topic subscription
List all subscriptions of subscribers for a topic. Checkout all available filters in the query section.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.list(request={
"topic_key": "<value>",
"limit": 10,
"context_keys": [
"tenant:org-123",
"region:us-east-1",
],
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.TopicsControllerListTopicSubscriptionsRequest | ✔️ | The request object to use for the request. |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerListTopicSubscriptionsResponse
| 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 | */* |
This api will create subscription for subscriberIds for a topic. Its like subscribing to a common interest group. if topic does not exist, it will be created.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.create(topic_key="<value>", create_topic_subscriptions_request_dto={
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriber_id": "subscriber-123",
},
{
"identifier": "subscriber-456-subscription-b",
"subscriber_id": "subscriber-456",
},
],
"name": "My Topic",
"context": {
"key": "org-acme",
},
"preferences": [
{
"condition": {
"===": [
{
"var": "tier",
},
"premium",
],
},
"workflow_id": "workflow-123",
},
],
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
topic_key |
str | ✔️ | The key identifier of the topic |
create_topic_subscriptions_request_dto |
models.CreateTopicSubscriptionsRequestDto | ✔️ | 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.TopicsControllerCreateTopicSubscriptionsResponse
| 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 subscriptions for subscriberIds for a topic.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.delete(topic_key="<value>", delete_topic_subscriptions_request_dto={
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriber_id": "subscriber-123",
},
{
"subscriber_id": "subscriber-456",
},
{
"identifier": "subscriber-789-subscription-b",
},
],
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
topic_key |
str | ✔️ | The key identifier of the topic |
delete_topic_subscriptions_request_dto |
models.DeleteTopicSubscriptionsRequestDto | ✔️ | 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.TopicsControllerDeleteTopicSubscriptionsResponse
| 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 a subscription by its unique identifier for a topic.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.get_subscription(topic_key="<value>", identifier="<value>")
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
topic_key |
str | ✔️ | The key identifier of the topic |
identifier |
str | ✔️ | The unique identifier of the subscription |
idempotency_key |
Optional[str] | ➖ | A header for idempotency purposes |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. |
models.TopicsControllerGetTopicSubscriptionResponse
| 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 | */* |
Update a subscription by its unique identifier for a topic. You can update the preferences and name associated with the subscription.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.update(topic_key="<value>", identifier="<value>", update_topic_subscription_request_dto={
"name": "My Subscription",
"preferences": [
{
"condition": {
"===": [
{
"var": "tier",
},
"premium",
],
},
"workflow_id": "workflow-123",
},
],
})
# Handle response
print(res)| Parameter | Type | Required | Description |
|---|---|---|---|
topic_key |
str | ✔️ | The key identifier of the topic |
identifier |
str | ✔️ | The unique identifier of the subscription |
update_topic_subscription_request_dto |
models.UpdateTopicSubscriptionRequestDto | ✔️ | 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.TopicsControllerUpdateTopicSubscriptionResponse
| 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 | */* |