(messages)
A message in Novu represents a notification delivered to a recipient on a particular channel. Messages contain information about the request that triggered its delivery, a view of the data sent to the recipient, and a timeline of its lifecycle events. Learn more about messages. https://docs.novu.co/workflows/messages
- retrieve - Get messages
- delete - Delete message
- deleteByTransactionId - Delete messages by transactionId
Returns a list of messages, could paginate using the page
query parameter
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.messages.retrieve({});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { messagesRetrieve } from "@novu/api/funcs/messagesRetrieve.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await messagesRetrieve(novu, {});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.MessagesControllerGetMessagesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.MessagesControllerGetMessagesResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
errors.ErrorDto | 414 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.ErrorDto | 500 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Deletes a message entity from the Novu platform
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.messages.delete("<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { messagesDelete } from "@novu/api/funcs/messagesDelete.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await messagesDelete(novu, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
messageId |
string | ✔️ | N/A |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.MessagesControllerDeleteMessageResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
errors.ErrorDto | 414 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.ErrorDto | 500 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Deletes messages entity from the Novu platform using TransactionId of message
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.messages.deleteByTransactionId("<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { messagesDeleteByTransactionId } from "@novu/api/funcs/messagesDeleteByTransactionId.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await messagesDeleteByTransactionId(novu, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
transactionId |
string | ✔️ | N/A |
channel |
operations.Channel | ➖ | The channel of the message to be deleted |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.MessagesControllerDeleteMessagesByTransactionIdResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
errors.ErrorDto | 414 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.ErrorDto | 500 | application/json |
errors.SDKError | 4XX, 5XX | */* |