Schedule Notification
POST /notification/schedule
The schedule Notification endpoint allows the creation and scheduling of a notification. The service then receives requests containing the required parameters, analyzes the provided information, and, upon verification, saves the notification in a data persistence tool.
Request Body
{ "notifications": [ { "project": "", "clientId": "", "msg": "", "channel": "", "to": "", "templateId": "", "templateParams": "", "notificationDate": "", "sendNow": false } ] }
Parameter Name | Type | Required | Description |
---|---|---|---|
project | string | Yes | Reference project to send notifications. This allows the app to store data in a different data persistence tool. Supported values:
|
clientId | string | Yes | Could be:
|
msg | string | Yes, for SMS Optional for FBM/ WA | Message to be send by the notification. Mandatory for SMS For WA (only): if provided, the service will send the msg value, and will NOT try to use the template. |
channel | string | Yes | Way of communication where the scheduled message will be sent: Current supported values:
|
to | string | Yes | Identifier used by the specified channel to send the message. |
templateId | string | Yes | Identifier used for ALL channels to tag the type of message. This is later use for canceling scheduled messages. For WA (only): TemplateID used on the Meta service. SMS & FBM: id is for internal used (mainly to cancel notifications) |
templateParams | string | optional | Parameters to be used in the template specified. |
notificationDate | string | Yes if sendNow=false | Date on which the notification will be sent. Format: |
processId | string | optional | Allows the application to store any value or values for debugging or cross reference. Optional. |
sendNow | boolean | optional | Parameter to specify if the notification should be sent on creation time. |
Request body SMS
{ "notifications": [ { "project": "LAC-FP", "clientId": "cMyjKYJtgSI", "channel": "SMS", "templateId": "template_3", "msg": "hi", "to": "+26658636836", "templateParams": "", "processId": "any data from the originator app", // optional (under dev) "notificationDate": "2024-02-23T13:18:30.800Z" } ] }
Request body Facebook template
{ "notifications": [ { "project": "LAC-FP", "clientId": "cMyjKYJtgSI", "channel": "facebook", "templateId": "template_3", "msg": "message text" "templateParams": "{'quick_replies':[{'content_type':'text','image_url':'http://example.com/img/red.png','payload':'<POSTBACK_PAYLOAD>','title':'Red'},{'content_type':'text','image_url':'http://example.com/img/green.png','payload':'<POSTBACK_PAYLOAD><','title':'Green'}],'text':'Pick a color:'}", "to": "1234jdj204", "notificationDate": "2023-11-23T13:18:30.800Z",// this will be ignored as sendNow = true "sendNow": true}] }
Check out official Meta’s quick replies for facebook documentation to know more about the structure to use in templateParams parameter when the channel is.
We also can send a bundle of notifications:
{ "notifications": [ { "project": "", "clientId": "", "msg": "", "channel": "", "to": "", "templateId": "", "templateParams": "", "notificationDate": "", "sendNow": false }, { ... }, { ... }, ... ] }
Example Request:
{ "notifications": [ { "project": "LAC-FP", "clientId": "cMyjKYJtgSI", "msg": "hi", "channel": "facebook", "to": "a234jdjf12js252kakd9", "templateId": "1", "templateParams": "", "notificationDate": "2023-11-23T13:18:30.800Z" "sendNow": false }, { "project": "LAC-FP", "clientId": "cMyjKYJtgSI", "msg": "hi", "channel": "sms", "to": "+26658636836", "templateId": "3", "templateParams": "", "notificationDate": "2023-11-23T13:18:30.800Z", "sendNow": false } ] }
Responses
200: Success
{ "notifications": [ { "notificationID": "askdh83asd9", "project": "", "clientId": "", "msg": "", "channel": "", "to": "", "templateId": "", "templateParams": "", "notificationDate": "", "status": "scheduled", }, ... ] }
409: Conflict. The request was processed but the resource was not found.
{ "timestamp": "2024-02-29T04:35:22.307Z", "statusCode": 409, "message": "An error occurred, please check import summary.", "errors\"": [ { "httpStatus": "Conflict", "httpStatusCode": 409, "status": "ERROR", "message": "An error occurred, please check import summary.", "response": { "responseType": "asd \"ImportSummaries\"", "status": "ERROR", "imported": 0, "updated": 0, "deleted": 0, "ignored": 1, "importOptions": { "idSchemes": {}, "dryRun": false, "async": false, "importStrategy": "CREATE_AND_UPDATE", "mergeMode": "REPLACE", "reportMode": "FULL", "skipExistingCheck": false, "sharing": false, "skipNotifications": false, "skipAudit": false, "datasetAllowsPeriods": false, "strictPeriods": false, "strictDataElements": false, "strictCategoryOptionCombos": false, "strictAttributeOptionCombos": false, "strictOrganisationUnits": false, "requireCategoryOptionCombo": false, "requireAttributeOptionCombo": false, "skipPatternValidation": false, "ignoreEmptyCollection": false, "force": false, "firstRowIsHeader": true, "skipLastUpdated": false, "mergeDataValues": false, "skipCache": false }, "importSummaries": [ { "responseType": "ImportSummary", "status": "ERROR", "importOptions": { "idSchemes": {}, "dryRun": false, "async": false, "importStrategy": "CREATE_AND_UPDATE", "mergeMode": "REPLACE", "reportMode": "FULL", "skipExistingCheck": false, "sharing": false, "skipNotifications": false, "skipAudit": false, "datasetAllowsPeriods": false, "strictPeriods": false, "strictDataElements": false, "strictCategoryOptionCombos": false, "strictAttributeOptionCombos": false, "strictOrganisationUnits": false, "requireCategoryOptionCombo": false, "requireAttributeOptionCombo": false, "skipPatternValidation": false, "ignoreEmptyCollection": false, "force": false, "firstRowIsHeader": true, "skipLastUpdated": false, "mergeDataValues": false, "skipCache": false }, "description": "Event.trackedEntityInstance does not point to a valid tracked entity instance: cMyjKYJtgSIasdasd", "importCount": { "imported": 0, "updated": 0, "ignored": 1, "deleted": 0 }, "conflicts": [], "reference": "R75K9h5mTt2" } ], "total": 1 } } ] }
422: Unprocessable Entity. Missing required properties in Request Body
{ "timestamp": "2024-02-28T03:46:08.196Z", "statusCode": 422, "message": "Invalid request payload", "errors": [ { "type": "field", "msg": "Invalid value", "path": "notifications[0].clientId", "location": "body" }, { "type": "field", "msg": "clientId is required", "path": "notifications[0].clientId", "location": "body" } ]
500: Internal Server Error
{ "timestamp": "2024-02-29T04:26:43.447Z", "statusCode": 500, "message": "Request failed with status code 500", "errors": [] }