JavaScript SDK:通知参考
用于发送和管理通知的每种方法及其签名。
6分钟 读取·级别 参考·修改于 2026年10月12日
该英文文本是根据法文原文自动生成的,尚未经过审查。
该页面已自动翻译。英文版具有权威性。
#
班级
通知服务
| 财产 | 描述 |
|---|---|
readonly admin: NotificationsAdminService | 管理子客户端:统计、队列、报废 (DLQ)、供应商日志、事件、规则和设置。 |
| 方法 | 描述 |
|---|---|
send(options: SendNotificationOptions): Promise<AuraResponse<Notification>>send(channel: NotificationChannel, recipient: string, body: string, options?: { subject?: string; templateId?: string; variables?: Record<string, unknown>; metadata?: Record<string, unknown>; idempotencyKey?: string; }): Promise<AuraResponse<Notification>> | 对要发送的通知进行排队(现代对象 API)。 |
sendBatch(items: Array<SendNotificationRequest | SendNotificationItem>): Promise<AuraResponse<BatchSendResponse>> | 发送一批通知 (POST /send/batch)。 |
sendEmail(recipient: string, subject: string, body: string, options?: SendEmailOptions): Promise<AuraResponse<Notification>> | 发送交易电子邮件 (channel: 'email')。 |
sendSms(recipient: string, body: string, options?: SendSmsOptions): Promise<AuraResponse<Notification>> | 发送交易短信 (channel: 'sms')。 |
sendPush(recipient: string, title: string, body: string, options?: SendPushOptions): Promise<AuraResponse<Notification>> | 发送移动推送通知(channel: 'push'、FCM 或 APNs)。 |
sendWebhook(targetUrl: string, event: string, payload: string | Record<string, unknown>, options?: SendWebhookOptions): Promise<AuraResponse<Notification>> | 发出传出 HTTP POST Webhook (channel: 'webhook')。 |
retry(id: string): Promise<AuraResponse<Notification>> | 重试失败的通知(status: 'failed' 或 'dead_lettered')。 |
list(options?: { channel?: NotificationChannel; status?: NotificationStatus; search?: string; sort?: 'created_at' | 'updated_at' | 'status'; order?: 'asc' | 'desc'; limit?: number; offset?: number; }): Promise<AuraResponse<Notification[]>> | 列出项目的通知历史记录,可按 channel、 status 和 search进行过滤,按 created_at、 updated_at 或 status排序,并使用 limit / offset 分页。 |
get(id: string): Promise<AuraResponse<Notification>> | 通过标识符读取通知。 |
listTemplates(): Promise<AuraResponse<NotificationTemplate[]>> | 列出项目消息模板。 |
getTemplate(id: string): Promise<AuraResponse<NotificationTemplate>> | 通过标识符读取消息模板。 |
createTemplate(template: Omit<NotificationTemplate, 'id' | 'project_id' | 'created_at' | 'updated_at'>): Promise<AuraResponse<NotificationTemplate>> | 创建一个模板 — name、 channel、 subject、 body,仅此而已。 |
updateTemplate(id: string, updates: Partial<Pick<NotificationTemplate, 'name' | 'subject' | 'body'>>): Promise<AuraResponse<NotificationTemplate>> | 更新模板: name、 subject 和/或 body。 |
deleteTemplate(id: string): Promise<AuraResponse<null>> | 删除消息模板。 |
#
班级
通知管理服务
| 方法 | 描述 |
|---|---|
getSettings(): Promise<AuraResponse<NotificationSettingsPublic>> | 检索项目的公共供应商和配额设置 (GET /settings)。 |
updateSettings(settings: NotificationSettingsPatch | Partial<NotificationSettings>): Promise<AuraResponse<NotificationSettingsPublic>> | 更新项目的供应商或配额设置 (PATCH /settings)。 |
getStats(options?: { window?: NotificationStatsWindow; channel?: NotificationChannel; }): Promise<AuraResponse<NotificationStats>> | 聚合发送统计信息 (GET /stats)。 |
getQueue(): Promise<AuraResponse<NotificationQueueStats>> | 读取发送队列的状态:待处理通知的深度和分布。 |
listAttempts(notificationId: string): Promise<AuraResponse<NotificationAttempt[]>> | 列出发送通知的尝试,以及提供商对每个通知的响应。 |
listDeadLetters(options?: { channel?: NotificationChannel; search?: string; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationDeadLetter[]>> | 列出放置在垃圾队列 (DLQ) 中的通知,可通过 channel 和 search进行过滤。 |
retryDeadLetter(id: string): Promise<AuraResponse<Notification>> | 从报废队列 (DLQ) 重新发送特定通知。 |
listEvents(options?: { status?: 'received' | 'matched' | 'ignored' | 'failed' | 'enqueued'; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationEvent[]>> | 列出规则引擎接收到的事件,可通过 status进行过滤。 |
listProviderLogs(options?: { channel?: NotificationChannel; status?: NotificationAttemptStatus; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationProviderLog[]>> | 第三方供应商执行日志 (GET /providers/logs)。 |
previewTemplate(id: string, variables: Record<string, unknown>): Promise<AuraResponse<NotificationTemplatePreview>> | 使用给定的 variables 渲染模型以进行预览,而不发送消息。 |
listRules(): Promise<AuraResponse<NotificationRule[]>> | 列出项目通知规则(自动触发发送)。 |
createRule(rule: CreateNotificationRuleRequest): Promise<AuraResponse<NotificationRule>> | 创建通知规则:对于检查 condition的每个 trigger_type 类型的事件,将在 channel 上向 recipient_expr指定的收件人发送一条消息,并具有可选的延迟。 |
getRule(id: string): Promise<AuraResponse<NotificationRule>> | 通过标识符读取通知规则。 |
updateRule(id: string, updates: UpdateNotificationRuleRequest): Promise<AuraResponse<NotificationRule>> | 更新通知规则:仅提供的字段发生更改(例如 enabled)。 |
deleteRule(id: string): Promise<AuraResponse<null>> | 删除通知规则。 |
生成的页面
该页面是根据 SDK 的类型声明和注释生成的,因此它不会偏离已发布的代码。有关工作示例,请阅读指南。
最后更新· 2026年10月12日