Skip to content

Latest commit

 

History

History
168 lines (123 loc) · 9.5 KB

README.md

File metadata and controls

168 lines (123 loc) · 9.5 KB

Credentials

(subscribers.credentials)

Overview

Available Operations

  • update - Update subscriber credentials
  • append - Modify subscriber credentials
  • delete - Delete subscriber credentials by providerId

update

Subscriber credentials associated to the delivery methods such as slack and push tokens.

Example Usage

import novu_py
from novu_py import Novu
import os

with Novu(
    api_key=os.getenv("NOVU_API_KEY", ""),
) as novu:

    res = novu.subscribers.credentials.update(subscriber_id="<id>", update_subscriber_channel_request_dto={
        "provider_id": novu_py.UpdateSubscriberChannelRequestDtoProviderID.PUSHPAD,
        "credentials": {
            "webhook_url": "https://example.com/webhook",
            "channel": "general",
            "device_tokens": [
                "token1",
                "token2",
                "token3",
            ],
            "alert_uid": "12345-abcde",
            "title": "Critical Alert",
            "image_url": "https://example.com/image.png",
            "state": "resolved",
            "external_url": "https://example.com/details",
        },
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
subscriber_id str ✔️ N/A
update_subscriber_channel_request_dto models.UpdateSubscriberChannelRequestDto ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SubscribersControllerUpdateSubscriberChannelResponse

Errors

Error Type Status Code Content Type
models.ErrorDto 400, 404, 409 application/json
models.ValidationErrorDto 422 application/json
models.APIError 4XX, 5XX */*

append

Subscriber credentials associated to the delivery methods such as slack and push tokens. This endpoint appends provided credentials and deviceTokens to the existing ones.

Example Usage

import novu_py
from novu_py import Novu
import os

with Novu(
    api_key=os.getenv("NOVU_API_KEY", ""),
) as novu:

    res = novu.subscribers.credentials.append(subscriber_id="<id>", update_subscriber_channel_request_dto={
        "provider_id": novu_py.UpdateSubscriberChannelRequestDtoProviderID.ZULIP,
        "credentials": {
            "webhook_url": "https://example.com/webhook",
            "channel": "general",
            "device_tokens": [
                "token1",
                "token2",
                "token3",
            ],
            "alert_uid": "12345-abcde",
            "title": "Critical Alert",
            "image_url": "https://example.com/image.png",
            "state": "resolved",
            "external_url": "https://example.com/details",
        },
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
subscriber_id str ✔️ N/A
update_subscriber_channel_request_dto models.UpdateSubscriberChannelRequestDto ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SubscribersControllerModifySubscriberChannelResponse

Errors

Error Type Status Code Content Type
models.ErrorDto 400, 404, 409 application/json
models.ValidationErrorDto 422 application/json
models.APIError 4XX, 5XX */*

delete

Delete subscriber credentials such as slack and expo tokens.

Example Usage

from novu_py import Novu
import os

with Novu(
    api_key=os.getenv("NOVU_API_KEY", ""),
) as novu:

    res = novu.subscribers.credentials.delete(subscriber_id="<id>", provider_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
subscriber_id str ✔️ N/A
provider_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SubscribersControllerDeleteSubscriberCredentialsResponse

Errors

Error Type Status Code Content Type
models.ErrorDto 400, 404, 409 application/json
models.ValidationErrorDto 422 application/json
models.APIError 4XX, 5XX */*