Novu 3.12.0
dotnet add package Novu --version 3.12.0
NuGet\Install-Package Novu -Version 3.12.0
<PackageReference Include="Novu" Version="3.12.0" />
<PackageVersion Include="Novu" Version="3.12.0" />
<PackageReference Include="Novu" />
paket add Novu --version 3.12.0
#r "nuget: Novu, 3.12.0"
#:package Novu@3.12.0
#addin nuget:?package=Novu&version=3.12.0
#tool nuget:?package=Novu&version=3.12.0
Novu
SDK Example Usage
Trigger Notification Event
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Cancel Triggered Event
using Novu;
using Novu.Models.Components;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.CancelAsync(transactionId: "<id>");
// handle response
Broadcast Event to All
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.BroadcastAsync(triggerEventToAllRequestDto: new TriggerEventToAllRequestDto() {
Name = "<value>",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new TriggerEventToAllRequestDtoOverrides() {
AdditionalProperties = new Dictionary<string, Dictionary<string, object>>() {
{ "fcm", new Dictionary<string, object>() {
{ "data", new Dictionary<string, object>() {
{ "key", "value" },
} },
} },
},
},
Actor = TriggerEventToAllRequestDtoActor.CreateSubscriberPayloadDto(
new SubscriberPayloadDto() {
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>",
}
),
Context = new Dictionary<string, TriggerEventToAllRequestDtoContext>() {
{ "key", TriggerEventToAllRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Trigger Notification Events in Bulk
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.TriggerBulkAsync(bulkTriggerEventDto: new BulkTriggerEventDto() {
Events = new List<TriggerEventRequestDto>() {
new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
},
new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
},
new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
},
},
});
// handle response
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
SecretKey |
apiKey | API key |
To authenticate with the API the SecretKey parameter must be set when initializing the SDK client instance. For example:
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply pass a RetryConfig to the call:
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.TriggerAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
}
);
// handle response
If you'd like to override the default retry strategy for all operations that support retries, you can use the RetryConfig optional parameter when intitializing the SDK:
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
secretKey: "YOUR_SECRET_KEY_HERE"
);
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Error Handling
BaseException is the base exception class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
Message |
string | Error message |
Request |
HttpRequestMessage | HTTP request object |
Response |
HttpResponseMessage | HTTP response object |
Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.
Example
using Novu;
using Novu.Models.Components;
using Novu.Models.Errors;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
try
{
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
}
catch (BaseException ex) // all SDK exceptions inherit from BaseException
{
// ex.ToString() provides a detailed error message
System.Console.WriteLine(ex);
// Base exception fields
HttpRequestMessage request = ex.Request;
HttpResponseMessage response = ex.Response;
var statusCode = (int)response.StatusCode;
var responseBody = ex.Body;
if (ex is PayloadValidationExceptionDto) // different exceptions may be thrown depending on the method
{
// Check error data fields
PayloadValidationExceptionDtoPayload payload = ex.Payload;
double StatusCode = payload.StatusCode;
string Timestamp = payload.Timestamp;
// ...
}
// An underlying cause may be provided
if (ex.InnerException != null)
{
Exception cause = ex.InnerException;
}
}
catch (System.Net.Http.HttpRequestException ex)
{
// Check ex.InnerException for Network connectivity errors
}
Error Classes
Primary exceptions:
BaseException: The base class for HTTP error responses.ErrorDto: *ValidationErrorDto: Unprocessable Entity. Status code422. *
Less common exceptions (5)
System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect theex.InnerException.Inheriting from
BaseException:PayloadValidationExceptionDto: Status code400. Applicable to 3 of 93 methods.*SubscriberResponseDto: Created. Status code409. Applicable to 1 of 93 methods.*TopicResponseDto: OK. Status code409. Applicable to 1 of 93 methods.*ResponseValidationError: Thrown when the response data could not be deserialized into the expected type.
* Refer to the relevant documentation to determine whether an exception applies to a specific operation.
Server Selection
Select Server by Index
You can override the default server globally by passing a server index to the serverIndex: int optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
| # | Server | Description |
|---|---|---|
| 0 | https://api.novu.co |
|
| 1 | https://eu.api.novu.co |
Example
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(
serverIndex: 0,
secretKey: "YOUR_SECRET_KEY_HERE"
);
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(
serverUrl: "https://eu.api.novu.co",
secretKey: "YOUR_SECRET_KEY_HERE"
);
var res = await sdk.TriggerAsync(triggerEventRequestDto: new TriggerEventRequestDto() {
WorkflowId = "workflow_identifier",
Payload = new Dictionary<string, object>() {
{ "comment_id", "string" },
{ "post", new Dictionary<string, object>() {
{ "text", "string" },
} },
},
Overrides = new Overrides() {},
To = To.CreateStr(
"SUBSCRIBER_ID"
),
Actor = Actor.CreateStr(
"<value>"
),
Context = new Dictionary<string, TriggerEventRequestDtoContext>() {
{ "key", TriggerEventRequestDtoContext.CreateStr(
"org-acme"
) },
},
});
// handle response
Custom HTTP Client
The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native
HttpClient. This
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
errors and response.
The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK,
or provide your own custom implementation with customized configuration such as custom message handlers, timeouts,
connection pooling, and other HTTP client settings.
The following example shows how to create a custom HTTP client with request modification and error handling:
using Novu;
using Novu.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _defaultClient;
public CustomHttpClient()
{
_defaultClient = new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Add custom header and timeout
request.Headers.Add("x-custom-header", "custom value");
request.Headers.Add("x-request-timeout", "30");
try
{
var response = await _defaultClient.SendAsync(request, cancellationToken);
// Log successful response
Console.WriteLine($"Request successful: {response.StatusCode}");
return response;
}
catch (Exception error)
{
// Log error
Console.WriteLine($"Request failed: {error.Message}");
throw;
}
}
public void Dispose()
{
_httpClient?.Dispose();
_defaultClient?.Dispose();
}
}
// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new Novu(client: customHttpClient);
You can also provide a completely custom HTTP client with your own configuration:
using Novu.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
private readonly HttpClient _httpClient;
public AdvancedHttpClient()
{
var handler = new HttpClientHandler()
{
MaxConnectionsPerServer = 10,
// ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
};
_httpClient = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
}
public void Dispose()
{
_httpClient?.Dispose();
}
}
var sdk = Novu.Builder()
.WithClient(new AdvancedHttpClient())
.Build();
For simple debugging, you can enable request/response logging by implementing a custom client:
public class LoggingHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _innerClient;
public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
{
_innerClient = innerClient ?? new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Log request
Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
var response = await _innerClient.SendAsync(request, cancellationToken);
// Log response
Console.WriteLine($"Received {response.StatusCode} response");
return response;
}
public void Dispose() => _innerClient?.Dispose();
}
var sdk = new Novu(client: new LoggingHttpClient());
The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles
BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- newtonsoft.json (>= 13.0.3)
- nodatime (>= 3.1.9)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Novu:
| Package | Downloads |
|---|---|
|
Novu.Extensions
Novu .NET SDK |
|
|
Novu.Sync
Novu .NET SDK |
|
|
TechAppBuilder.Complete
Complete TechAppBuilder suite with core TAB components for .NET 5.0 applications including Core, Common, CheckIn, CustomHookManager, Media, and TQL modules |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.12.0 | 47 | 1/8/2026 |
| 3.11.0 | 3,874 | 11/19/2025 |
| 2.5.0 | 5,090 | 10/9/2025 |
| 2.4.0 | 1,263 | 10/1/2025 |
| 2.3.0 | 1,141 | 9/17/2025 |
| 2.3.0-alpha.1 | 1,345 | 6/25/2025 |
| 2.2.0 | 7,498 | 6/17/2025 |
| 2.1.0 | 1,271 | 5/22/2025 |
| 1.0.6 | 1,026 | 5/2/2025 |
| 1.0.5 | 363 | 5/2/2025 |
| 1.0.4 | 376 | 5/2/2025 |
| 1.0.3 | 394 | 5/2/2025 |
| 0.6.1 | 4,784 | 4/25/2025 |
| 0.6.0 | 12,511 | 2/18/2025 |
| 0.5.0 | 317 | 2/18/2025 |
| 0.4.2 | 354 | 2/17/2025 |
| 0.4.1 | 242 | 2/14/2025 |
| 0.4.0 | 367 | 2/8/2025 |
| 0.3.3 | 145,186 | 9/15/2023 |
| 0.3.2 | 567 | 8/28/2023 |
| 0.3.0 | 1,023 | 8/25/2023 |
| 0.2.2 | 7,011 | 7/10/2023 |
| 0.2.1 | 6,398 | 6/2/2023 |
| 0.2.0 | 707 | 5/9/2023 |
| 0.1.9 | 327 | 5/5/2023 |
| 0.1.8 | 259 | 5/5/2023 |
| 0.1.3 | 265 | 5/1/2023 |
| 0.1.2 | 275 | 5/1/2023 |
| 0.1.1 | 285 | 5/1/2023 |
| 0.1.0 | 280 | 5/1/2023 |