Novu API: Novu REST API. Please see https://docs.novu.co/api-reference for more details.
Novu Documentation
https://docs.novu.co
Trigger event is the main (and only) way to send notifications to subscribers.
The trigger identifier is used to match the particular workflow associated with it.
Additional information can be passed according the body interface below.
import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.trigger(trigger_event_request_dto=novu_py.TriggerEventRequestDto(
workflow_id="workflow_identifier",
payload={
"comment_id": "string",
"post": {
"text": "string",
},
},
overrides={
"fcm": {
"data": {
"key": "value",
},
},
},
to=novu_py.SubscriberPayloadDto(
subscriber_id="<id>",
),
))
# Handle response
print(res)
models.EventsControllerTriggerResponse
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 |
*/* |
Using a previously generated transactionId during the event trigger,
will cancel any active or pending workflows. This is useful to cancel active digests, delays etc...
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.cancel(transaction_id="<id>")
# Handle response
print(res)
Parameter |
Type |
Required |
Description |
transaction_id |
str |
✔️ |
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.EventsControllerCancelResponse
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 |
*/* |
Trigger a broadcast event to all existing subscribers, could be used to send announcements, etc.
In the future could be used to trigger events to a subset of subscribers based on defined filters.
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.trigger_broadcast(trigger_event_to_all_request_dto={
"name": "<value>",
"payload": {
"comment_id": "string",
"post": {
"text": "string",
},
},
})
# Handle response
print(res)
models.EventsControllerBroadcastEventToAllResponse
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 |
*/* |
Using this endpoint you can trigger multiple events at once, to avoid multiple calls to the API.
The bulk API is limited to 100 events per request.
import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.trigger_bulk(bulk_trigger_event_dto={
"events": [
novu_py.TriggerEventRequestDto(
workflow_id="workflow_identifier",
payload={
"comment_id": "string",
"post": {
"text": "string",
},
},
overrides={
"fcm": {
"data": {
"key": "value",
},
},
},
to=novu_py.SubscriberPayloadDto(
subscriber_id="<id>",
),
),
novu_py.TriggerEventRequestDto(
workflow_id="workflow_identifier",
payload={
"comment_id": "string",
"post": {
"text": "string",
},
},
overrides={
"fcm": {
"data": {
"key": "value",
},
},
},
to=[
novu_py.TopicPayloadDto(
topic_key="<value>",
type=novu_py.TriggerRecipientsTypeEnum.SUBSCRIBER,
),
],
),
novu_py.TriggerEventRequestDto(
workflow_id="workflow_identifier",
payload={
"comment_id": "string",
"post": {
"text": "string",
},
},
overrides={
"fcm": {
"data": {
"key": "value",
},
},
},
to=[
"SUBSCRIBER_ID",
"SUBSCRIBER_ID",
],
),
],
})
# Handle response
print(res)
models.EventsControllerTriggerBulkResponse
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 |
*/* |