Skip to content

Latest commit

 

History

History
505 lines (368 loc) · 33.3 KB

File metadata and controls

505 lines (368 loc) · 33.3 KB

Subscribers

Overview

A subscriber in Novu represents someone who should receive a message. A subscriber's profile information contains important attributes about the subscriber that will be used in messages (name, email). The subscriber object can contain other key-value pairs that can be used to further personalize your messages. https://docs.novu.co/subscribers/subscribers

Available Operations

Search

Search subscribers by their email, phone, subscriberId and name. The search is case sensitive and supports pagination.Checkout all available filters in the query section.

Example Usage

using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

SubscribersControllerSearchSubscribersRequest req = new SubscribersControllerSearchSubscribersRequest() {
    Limit = 10D,
};

var res = await sdk.Subscribers.SearchAsync(req);

// handle response

Parameters

Parameter Type Required Description
request SubscribersControllerSearchSubscribersRequest ✔️ The request object to use for the request.

Response

SubscribersControllerSearchSubscribersResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

Create

Create a subscriber with the subscriber attributes. subscriberId is a required field, rest other fields are optional, if the subscriber already exists, it will be updated

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.CreateAsync(createSubscriberRequestDto: new CreateSubscriberRequestDto() {
    FirstName = "John",
    LastName = "Doe",
    Email = "john.doe@example.com",
    Phone = "+1234567890",
    Avatar = "https://example.com/avatar.jpg",
    Locale = "en-US",
    Timezone = "America/New_York",
    SubscriberId = "<id>",
});

// handle response

Parameters

Parameter Type Required Description
CreateSubscriberRequestDto CreateSubscriberRequestDto ✔️ N/A
FailIfExists bool If true, the request will fail if a subscriber with the same subscriberId already exists
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerCreateSubscriberResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.SubscriberResponseDto 409 application/json
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

Retrieve

Retrieve a subscriber by its unique key identifier subscriberId. subscriberId field is required.

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.RetrieveAsync(subscriberId: "<id>");

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ The identifier of the subscriber
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerGetSubscriberResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

Patch

Update a subscriber by its unique key identifier subscriberId. subscriberId is a required field, rest other fields are optional

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.PatchAsync(
    subscriberId: "<id>",
    patchSubscriberRequestDto: new PatchSubscriberRequestDto() {
        FirstName = "John",
        LastName = "Doe",
        Email = "john.doe@example.com",
        Phone = "+1234567890",
        Avatar = "https://example.com/avatar.jpg",
        Locale = "en-US",
        Timezone = "America/New_York",
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ The identifier of the subscriber
PatchSubscriberRequestDto PatchSubscriberRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerPatchSubscriberResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

Delete

Deletes a subscriber entity from the Novu platform along with associated messages, preferences, and topic subscriptions. subscriberId is a required field.

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.DeleteAsync(subscriberId: "<id>");

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ The identifier of the subscriber
IdempotencyKey string A header for idempotency purposes

Response

SubscribersControllerRemoveSubscriberResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

CreateBulk

  Using this endpoint multiple subscribers can be created at once. The bulk API is limited to 500 subscribers per request.

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.CreateBulkAsync(bulkSubscriberCreateDto: new BulkSubscriberCreateDto() {
    Subscribers = new List<CreateSubscriberRequestDto>() {
        new CreateSubscriberRequestDto() {
            SubscriberId = "<id>",
        },
    },
});

// handle response

Parameters

Parameter Type Required Description
BulkSubscriberCreateDto BulkSubscriberCreateDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersV1ControllerBulkCreateSubscribersResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

UpdateCredentials

Update credentials for a provider such as slack and FCM. providerId is required field. This API creates the deviceTokens or replaces the existing ones.

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.UpdateCredentialsAsync(
    subscriberId: "<id>",
    updateSubscriberChannelRequestDto: new UpdateSubscriberChannelRequestDto() {
        ProviderId = ChatOrPushProviderEnum.Slack,
        Credentials = new ChannelCredentials() {
            WebhookUrl = "https://example.com/webhook",
            Channel = "general",
            DeviceTokens = new List<string>() {
                "token1",
                "token2",
                "token3",
            },
            AlertUid = "12345-abcde",
            Title = "Critical Alert",
            ImageUrl = "https://example.com/image.png",
            State = "resolved",
            ExternalUrl = "https://example.com/details",
        },
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ N/A
UpdateSubscriberChannelRequestDto UpdateSubscriberChannelRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersV1ControllerUpdateSubscriberChannelResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

AppendCredentials

Upsert credentials for a provider such as slack and FCM. providerId is required field. This API creates deviceTokens or appends to the existing ones.

Example Usage

using Novu;
using Novu.Models.Components;
using System.Collections.Generic;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.AppendCredentialsAsync(
    subscriberId: "<id>",
    updateSubscriberChannelRequestDto: new UpdateSubscriberChannelRequestDto() {
        ProviderId = ChatOrPushProviderEnum.OneSignal,
        Credentials = new ChannelCredentials() {
            WebhookUrl = "https://example.com/webhook",
            Channel = "general",
            DeviceTokens = new List<string>() {
                "token1",
                "token2",
                "token3",
            },
            AlertUid = "12345-abcde",
            Title = "Critical Alert",
            ImageUrl = "https://example.com/image.png",
            State = "resolved",
            ExternalUrl = "https://example.com/details",
        },
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ N/A
UpdateSubscriberChannelRequestDto UpdateSubscriberChannelRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersV1ControllerModifySubscriberChannelResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

DeleteCredentials

Delete subscriber credentials for a provider such as slack and FCM by providerId. This action is irreversible and will remove the credentials for the provider for particular subscriberId.

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.DeleteCredentialsAsync(
    subscriberId: "<id>",
    providerId: "<id>"
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ N/A
ProviderId string ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersV1ControllerDeleteSubscriberCredentialsResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*

UpdateOnlineStatus

Update the subscriber online status by its unique key identifier subscriberId

Example Usage

using Novu;
using Novu.Models.Components;

var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");

var res = await sdk.Subscribers.UpdateOnlineStatusAsync(
    subscriberId: "<id>",
    updateSubscriberOnlineFlagRequestDto: new UpdateSubscriberOnlineFlagRequestDto() {
        IsOnline = false,
    }
);

// handle response

Parameters

Parameter Type Required Description
SubscriberId string ✔️ N/A
UpdateSubscriberOnlineFlagRequestDto UpdateSubscriberOnlineFlagRequestDto ✔️ N/A
IdempotencyKey string A header for idempotency purposes

Response

SubscribersV1ControllerUpdateSubscriberOnlineFlagResponse

Errors

Error Type Status Code Content Type
Novu.Models.Errors.ErrorDto 414 application/json
Novu.Models.Errors.ErrorDto 400, 401, 403, 404, 405, 409, 413, 415 application/json
Novu.Models.Errors.ValidationErrorDto 422 application/json
Novu.Models.Errors.ErrorDto 500 application/json
Novu.Models.Errors.APIException 4XX, 5XX */*