- Create - Create a context
- List - List all contexts
- Update - Update a context
- Retrieve - Retrieve a context
- Delete - Delete a context
Create a new context with the specified type, id, and data. Returns 409 if context already exists.
**type** and **id** are required fields, **data** is optional, if the context already exists, it returns the 409 response
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Contexts.CreateAsync(createContextRequestDto: new CreateContextRequestDto() {
Type = "tenant",
Id = "org-acme",
Data = new Dictionary<string, object>() {
{ "tenantName", "Acme Corp" },
{ "region", "us-east-1" },
{ "settings", new Dictionary<string, object>() {
{ "theme", "dark" },
} },
},
});
// handle response| Parameter | Type | Required | Description |
|---|---|---|---|
CreateContextRequestDto |
CreateContextRequestDto | ✔️ | N/A |
IdempotencyKey |
string | ➖ | A header for idempotency purposes |
ContextsControllerCreateContextResponse
| 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 | */* |
Retrieve a paginated list of all contexts, optionally filtered by type and key pattern.
**type** and **id** are optional fields, if provided, only contexts with the matching type and id will be returned.
**search** is an optional field, if provided, only contexts with the matching key pattern will be returned.
Checkout all possible parameters in the query section below for more details
using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
ContextsControllerListContextsRequest req = new ContextsControllerListContextsRequest() {
Limit = 10D,
Id = "tenant-prod-123",
Search = "tenant",
};
var res = await sdk.Contexts.ListAsync(req);
// handle response| Parameter | Type | Required | Description |
|---|---|---|---|
request |
ContextsControllerListContextsRequest | ✔️ | The request object to use for the request. |
ContextsControllerListContextsResponse
| 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 | */* |
Update the data of an existing context. type and id are required fields, data is required. Only the data field is updated, the rest of the context is not affected. If the context does not exist, it returns the 404 response
using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Contexts.UpdateAsync(
id: "<id>",
type: "<value>",
updateContextRequestDto: new UpdateContextRequestDto() {
Data = new Dictionary<string, object>() {
{ "tenantName", "Acme Corp" },
{ "region", "us-east-1" },
{ "settings", new Dictionary<string, object>() {
{ "theme", "dark" },
} },
},
}
);
// handle response| Parameter | Type | Required | Description |
|---|---|---|---|
Id |
string | ✔️ | Context ID |
Type |
string | ✔️ | Context type |
UpdateContextRequestDto |
UpdateContextRequestDto | ✔️ | N/A |
IdempotencyKey |
string | ➖ | A header for idempotency purposes |
ContextsControllerUpdateContextResponse
| 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 | */* |
Retrieve a specific context by its type and id. type and id are required fields, if the context does not exist, it returns the 404 response
using Novu;
using Novu.Models.Components;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Contexts.RetrieveAsync(
id: "<id>",
type: "<value>"
);
// handle response| Parameter | Type | Required | Description |
|---|---|---|---|
Id |
string | ✔️ | Context ID |
Type |
string | ✔️ | Context type |
IdempotencyKey |
string | ➖ | A header for idempotency purposes |
ContextsControllerGetContextResponse
| 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 a context by its type and id. type and id are required fields, if the context does not exist, it returns the 404 response
using Novu;
using Novu.Models.Components;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Contexts.DeleteAsync(
id: "<id>",
type: "<value>"
);
// handle response| Parameter | Type | Required | Description |
|---|---|---|---|
Id |
string | ✔️ | Context ID |
Type |
string | ✔️ | Context type |
IdempotencyKey |
string | ➖ | A header for idempotency purposes |
ContextsControllerDeleteContextResponse
| 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 | */* |