SDK JavaScript : référence sur les notifications
Chaque méthode d'envoi et de gestion des notifications, avec sa signature.
6 min de lecture·Niveau référence·Révisé le 12 oct. 2026
Ce texte anglais a été généré automatiquement à partir de l’original français et n’a pas encore été relu.
Cette page a été traduite automatiquement. La version anglaise fait foi.
#
Classe
Service de notifications
| Propriété | Descriptif |
|---|---|
readonly admin: NotificationsAdminService | Sous-client d'administration : statistiques, file d'attente, rebuts (DLQ), journaux des fournisseurs, événements, règles et paramètres. |
| Méthode | Descriptif |
|---|---|
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>> | Met en file d’attente une notification à envoyer (API Modern Object). |
sendBatch(items: Array<SendNotificationRequest | SendNotificationItem>): Promise<AuraResponse<BatchSendResponse>> | Envoie un lot de notifications (POST /send/batch). |
sendEmail(recipient: string, subject: string, body: string, options?: SendEmailOptions): Promise<AuraResponse<Notification>> | Envoie un e-mail transactionnel (channel: 'email'). |
sendSms(recipient: string, body: string, options?: SendSmsOptions): Promise<AuraResponse<Notification>> | Envoie un SMS transactionnel (channel: 'sms'). |
sendPush(recipient: string, title: string, body: string, options?: SendPushOptions): Promise<AuraResponse<Notification>> | Envoie une notification push mobile (channel: 'push', FCM ou APN). |
sendWebhook(targetUrl: string, event: string, payload: string | Record<string, unknown>, options?: SendWebhookOptions): Promise<AuraResponse<Notification>> | Émet un webhook HTTP POST sortant (channel: 'webhook'). |
retry(id: string): Promise<AuraResponse<Notification>> | Réessayez une notification ayant échoué (status: 'failed' ou '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[]>> | Répertorie l'historique des notifications du projet, filtrable par channel, status et search, trié par created_at, updated_at ou status, avec la pagination limit / offset . |
get(id: string): Promise<AuraResponse<Notification>> | Lit une notification par son identifiant. |
listTemplates(): Promise<AuraResponse<NotificationTemplate[]>> | Répertorie les modèles de messages du projet. |
getTemplate(id: string): Promise<AuraResponse<NotificationTemplate>> | Lit un modèle de message par son identifiant. |
createTemplate(template: Omit<NotificationTemplate, 'id' | 'project_id' | 'created_at' | 'updated_at'>): Promise<AuraResponse<NotificationTemplate>> | Crée un modèle — name, channel, subject, body et rien d'autre. |
updateTemplate(id: string, updates: Partial<Pick<NotificationTemplate, 'name' | 'subject' | 'body'>>): Promise<AuraResponse<NotificationTemplate>> | Met à jour un modèle : name, subject et/ou body. |
deleteTemplate(id: string): Promise<AuraResponse<null>> | Supprime un modèle de message. |
#
Classe
Service d'administration des notifications
| Méthode | Descriptif |
|---|---|
getSettings(): Promise<AuraResponse<NotificationSettingsPublic>> | Récupère les paramètres de fournisseur public et de quota du projet (GET /settings). |
updateSettings(settings: NotificationSettingsPatch | Partial<NotificationSettings>): Promise<AuraResponse<NotificationSettingsPublic>> | Met à jour les paramètres de fournisseur ou de quota du projet (PATCH /settings). |
getStats(options?: { window?: NotificationStatsWindow; channel?: NotificationChannel; }): Promise<AuraResponse<NotificationStats>> | Statistiques d'envoi agrégées (GET /stats). |
getQueue(): Promise<AuraResponse<NotificationQueueStats>> | Lit l'état de la file d'attente d'envoi : profondeur et répartition des notifications en attente. |
listAttempts(notificationId: string): Promise<AuraResponse<NotificationAttempt[]>> | Répertorie les tentatives d'envoi d'une notification, avec la réponse du fournisseur à chacune. |
listDeadLetters(options?: { channel?: NotificationChannel; search?: string; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationDeadLetter[]>> | Répertorie les notifications placées dans la file d'attente des déchets (DLQ), filtrables par channel et search. |
retryDeadLetter(id: string): Promise<AuraResponse<Notification>> | Renvoie une notification spécifique depuis la file d'attente des rebuts (DLQ). |
listEvents(options?: { status?: 'received' | 'matched' | 'ignored' | 'failed' | 'enqueued'; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationEvent[]>> | Répertorie les événements reçus par le moteur de règles, filtrables par status. |
listProviderLogs(options?: { channel?: NotificationChannel; status?: NotificationAttemptStatus; limit?: number; offset?: number; }): Promise<AuraResponse<NotificationProviderLog[]>> | Journaux d'exécution de fournisseurs tiers (GET /providers/logs). |
previewTemplate(id: string, variables: Record<string, unknown>): Promise<AuraResponse<NotificationTemplatePreview>> | Rend un modèle avec le variables donné pour un aperçu, sans envoyer de message. |
listRules(): Promise<AuraResponse<NotificationRule[]>> | Liste les règles de notification du projet (déclenchement automatique d'un envoi). |
createRule(rule: CreateNotificationRuleRequest): Promise<AuraResponse<NotificationRule>> | Crée une règle de notification : pour chaque événement de type trigger_type qui vérifie condition, un message est envoyé sur channel au destinataire indiqué par recipient_expr, avec un délai optionnel. |
getRule(id: string): Promise<AuraResponse<NotificationRule>> | Lit une règle de notification par son identifiant. |
updateRule(id: string, updates: UpdateNotificationRuleRequest): Promise<AuraResponse<NotificationRule>> | Met à jour une règle de notification : seuls les champs fournis changent (par exemple enabled). |
deleteRule(id: string): Promise<AuraResponse<null>> | Supprime une règle de notification. |
Page générée
Cette page est générée à partir des déclarations de type et des commentaires du SDK, elle ne peut donc pas dériver du code publié. Pour des exemples concrets, lisez les guides.
Dernière mise à jour · 12 oct. 2026