Notifications
Base URL : /api/v1/admin/org
Gestion des modèles de notification et des envois programmés.
Canaux
| Canal | Valeur (channel) | Statut |
|---|---|---|
Email | Implémenté (SendGrid) | |
| SMS | Sms | Stub (log only) |
WhatsApp | Stub (log only) | |
| Webhook | Webhook | Planifié |
channel est sérialisé en PascalCase ("Email", "Sms"). Seul l'email est réellement envoyé ; SMS et WhatsApp sont des stubs qui journalisent seulement. Les templates utilisent le moteur Handlebars.
Types d'événements (template codes)
| Code | Déclencheur |
|---|---|
recharge_completed | Rechargement réussi |
anomaly_alert | Anomalie détectée |
low_balance | Solde sous le seuil |
purchase_receipt | Reçu d'achat |
reservation_confirmation | Confirmation de réservation |
reservation_reminder | Rappel de réservation |
scheduled_broadcast | Diffusion programmée |
Structure d'un template
| Champ | Type | Description |
|---|---|---|
id | uuid | Identifiant |
code | string | Code d'événement |
channel | string | Email, Sms, WhatsApp, Webhook |
organization_id | uuid? | Organisation |
subject | string? | Objet (email) |
body | string | Corps (Handlebars) |
variables | string[] | Variables utilisées |
is_active | boolean | Actif |
created_at | datetime | Création |
GET /admin/org/notification-templates
Permissions : notification.read
| Param | Type | Défaut |
|---|---|---|
limit | integer | 20 |
offset | integer | 0 |
Réponse (200) :
{
"items": [
{
"id": "uuid",
"code": "recharge_completed",
"channel": "Email",
"organization_id": "uuid",
"subject": "Votre carte a été rechargée",
"body": "Bonjour {{display_name}}, votre carte {{card_number}} a été rechargée de {{amount}} FCFA.",
"variables": ["display_name", "card_number", "amount"],
"is_active": true,
"created_at": "2025-01-10T00:00:00Z"
}
],
"total": 8
}
GET /admin/org/notification-templates/{id}
Permissions : notification.read — Réponse : objet template brut.
POST /admin/org/notification-templates
Permissions : notification.create
{
"code": "low_balance",
"channel": "Sms",
"subject": null,
"body": "Votre solde est faible : {{balance}} FCFA.",
"variables": ["balance"]
}
Champs requis : code, channel, body, variables (peut être []).
Réponse (201) : { "message": "Template créé", "template": {...} }
PUT /admin/org/notification-templates/{id}
Permissions : notification.update
{
"code": "low_balance",
"channel": "Sms",
"body": "Solde insuffisant : {{balance}} FCFA.",
"variables": ["balance"],
"is_active": false
}
Champs requis : code, channel, body, variables, is_active.
Réponse (200) : { "message": "Template mis à jour", "template": {...} }
DELETE /admin/org/notification-templates/{id}
Permissions : notification.delete
Réponse (200) : { "message": "Template supprimé" }
Notifications programmées
Structure ScheduledNotification
| Champ | Type | Description |
|---|---|---|
id | uuid | Identifiant |
organization_id | uuid | Organisation |
name | string | Nom |
template_code | string | Code du template |
channel | string | Canal |
schedule_cron | string | Expression CRON |
filter_query | object? | Filtre de destinataires |
is_active | boolean | Active |
last_run_at | datetime? | Dernière exécution |
created_at | datetime | Création |
GET /admin/org/scheduled-notifications
Permissions : notification.read
| Param | Type | Défaut |
|---|---|---|
limit | integer | 20 |
offset | integer | 0 |
Réponse (200) :
{
"items": [
{
"id": "uuid",
"organization_id": "uuid",
"name": "Rappel lundi",
"template_code": "low_balance",
"channel": "Sms",
"schedule_cron": "0 8 * * 1",
"filter_query": null,
"is_active": true,
"last_run_at": null,
"created_at": "2025-01-25T14:00:00Z"
}
],
"total": 3
}
GET /admin/org/scheduled-notifications/{id}
Permissions : notification.read — Réponse : objet brut.
POST /admin/org/scheduled-notifications
Permissions : notification.create
{
"name": "Rappel lundi",
"template_code": "low_balance",
"channel": "Sms",
"schedule_cron": "0 8 * * 1",
"filter_query": null
}
Champs requis : name, template_code, channel, schedule_cron.
Réponse (201) : { "message": "Notification programmée créée", "scheduled": {...} }
PUT /admin/org/scheduled-notifications/{id}
Permissions : notification.update
{
"name": "Rappel lundi matin",
"template_code": "low_balance",
"channel": "Sms",
"schedule_cron": "0 9 * * 1",
"filter_query": null,
"is_active": false
}
Réponse (200) : { "message": "Notification programmée mise à jour", "scheduled": {...} }
DELETE /admin/org/scheduled-notifications/{id}
Permissions : notification.delete
Réponse (200) : { "message": "Notification programmée supprimée" }
Permissions
| Permission | Description |
|---|---|
notification.read / notification.create / notification.update / notification.delete | CRUD templates et planifications |
notification.manage | Super-permission |
Voir aussi
- Paramètres —
notification_config(canaux, routage) - Tickets de support
- Notifs — Setup