Aller au contenu principal

Notifications

Base URL : /api/v1/admin/org

Gestion des modèles de notification et des envois programmés.


Canaux​

CanalValeur (channel)Statut
EmailEmailImplémenté (SendGrid)
SMSSmsStub (log only)
WhatsAppWhatsAppStub (log only)
WebhookWebhookPlanifié
Casse et implémentation

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)​

CodeDéclencheur
recharge_completedRechargement réussi
anomaly_alertAnomalie détectée
low_balanceSolde sous le seuil
purchase_receiptReçu d'achat
reservation_confirmationConfirmation de réservation
reservation_reminderRappel de réservation
scheduled_broadcastDiffusion programmée

Structure d'un template​

ChampTypeDescription
iduuidIdentifiant
codestringCode d'événement
channelstringEmail, Sms, WhatsApp, Webhook
organization_iduuid?Organisation
subjectstring?Objet (email)
bodystringCorps (Handlebars)
variablesstring[]Variables utilisées
is_activebooleanActif
created_atdatetimeCréation

GET /admin/org/notification-templates​

Permissions : notification.read

ParamTypeDéfaut
limitinteger20
offsetinteger0

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​

ChampTypeDescription
iduuidIdentifiant
organization_iduuidOrganisation
namestringNom
template_codestringCode du template
channelstringCanal
schedule_cronstringExpression CRON
filter_queryobject?Filtre de destinataires
is_activebooleanActive
last_run_atdatetime?Dernière exécution
created_atdatetimeCréation

GET /admin/org/scheduled-notifications​

Permissions : notification.read

ParamTypeDéfaut
limitinteger20
offsetinteger0

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​

PermissionDescription
notification.read / notification.create / notification.update / notification.deleteCRUD templates et planifications
notification.manageSuper-permission

Voir aussi​