=============================== Disposition Notification Format =============================== .. contents:: :local: :depth: 3 Introduction ~~~~~~~~~~~~~~~ Disposition Notifications are acknowledgments sent back to the sender to confirm the delivery and/or display status of a message. Requesting Disposition Notifications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When sending a message via :ref:`fetch_messages_webservice`, the sender can request delivery and display acknowledgments by including a ``disposition_notification`` node in the message payload, for example: .. code-block:: json { "from" : "johndow", "password" : "12345678", "sms_to" : "+1(555)123-1234", "sms_body" : "Hello World", "content_type" : "text/plain", "disposition_notification" : "xkXRBMCL.twvNcfC9:positive-delivery, display" } Format ~~~~~~~ The ``disposition_notification`` node follows this structure: .. code-block:: json { "disposition_notification": "message_id:notification-types" } message_id A unique identifier for the message generated by sender, used to correlate the notification with the original message. notification-types A comma-separated list specifying the types of notifications requested. Valid values are: positive-delivery Requests a delivery notification when the message is delivered to the recipient's device. display Requests a display notification when the message is displayed to the recipient. Processing on the Recipient's Side ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Upon receiving a message with a `disposition_notification` node, the recipient's application should generate the appropriate notifications: Delivery Notification Sent when the message is delivered to the device. Display Notification Sent when the message is displayed to the user. Format ~~~~~~~ .. code-block:: json { "message_id" : "xkXRBMCL.twvNcfC9", "delivery-notification" : { "datetime" : "2018-26-07T01:02:03Z", "status" : "delivered" }, "display-notification" : { "datetime" : "2018-26-07T01:02:03Z", "status" : "displayed" } } alternatively, multiple disposition notifications can be grouped in a json array .. code-block:: json [ { "message_id" : "message.1", "..." : "..." }, { "message_id" : "message.2", "..." : "..." }, ] message_id Mandatory. It identifies the message being confirmed and comes from the ``disposition_notification`` node of the send message web service call of the original message. delivery-notification This node is present when the user agent is notifying the other party that the message was delivered to the device. datetime It is the date and time :rfc:`3339` of the moment when the device got the message. status Only possible value is ``delivered`` display-notification This node is present when the user agent is notifying the other party that the message was displayed to the useruser. datetime It is the date and time :rfc:`3339` of the moment when user displayed the message. status Only possible value is ``displayed`` The content-type of the disposition notification is ``application/x-acro-disposition-notification``. Implementation ~~~~~~~~~~~~~~ If the server sends the current time in the fetch response, the server/local clock difference should be computed and ``datetime`` fields in the disposition notifications should be adjusted by the computed clock difference. .. note:: The display notification needs to be sent and the correct datetime needs to be set only after the user displays the message. The clock difference at that time may be completely different but we still use the clock difference detected during the fetch time - can't think of any other solution. .. important:: If the delivery of the disposition notification fails because of the transmission problems or the server responds wih 5xx HTTP code, the disposition notification delivery should be retried later.