(notifications)
Manage notifications
- list - List all notifications
- updateStatus - Update notification status
- updateAllStatus - Update status of all notifications
Retrieve a list of notifications for the authenticated team.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.notifications.list({
cursor: "20",
pageSize: 20,
status: [
"unread",
"read",
],
userId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
priority: 5,
maxPriority: 3,
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { notificationsList } from "@midday-ai/sdk/funcs/notificationsList.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await notificationsList(midday, {
cursor: "20",
pageSize: 20,
status: [
"unread",
"read",
],
userId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
priority: 5,
maxPriority: 3,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("notificationsList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.ListNotificationsRequest | ✔️ | 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.ListNotificationsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Update the status of a specific notification.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.notifications.updateStatus({
notificationId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2",
requestBody: {
status: "read",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { notificationsUpdateStatus } from "@midday-ai/sdk/funcs/notificationsUpdateStatus.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await notificationsUpdateStatus(midday, {
notificationId: "b3b6e2c2-1f2a-4e3b-9c1d-2a4b6e2c21f2",
requestBody: {
status: "read",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("notificationsUpdateStatus failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.UpdateNotificationStatusRequest | ✔️ | 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.UpdateNotificationStatusResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
Update the status of all notifications for the authenticated team.
import { Midday } from "@midday-ai/sdk";
const midday = new Midday({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const result = await midday.notifications.updateAllStatus({
status: "read",
});
console.log(result);
}
run();The standalone function version of this method:
import { MiddayCore } from "@midday-ai/sdk/core.js";
import { notificationsUpdateAllStatus } from "@midday-ai/sdk/funcs/notificationsUpdateAllStatus.js";
// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
security: {
oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
},
});
async function run() {
const res = await notificationsUpdateAllStatus(midday, {
status: "read",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("notificationsUpdateAllStatus failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.UpdateAllNotificationsStatusSchema | ✔️ | 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.UpdateAllNotificationsStatusResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |