Delivery callbacks (bat/messagelist)
A callback is a POST request with JSON sent to the address in the callbackUrl field of the bat/messagelist request. If the field is not set, the default address from the gateway settings is used.
For Cascade API callbacks (restapi.smsbat.com/api/CascadeMessage/...) see Cascade delivery callbacks: the format there is different.
When callbacks arrive
- Final callback: exactly one per message, when the delivery chain reaches its final result:
delivered,undeliverableorpermanenterror. - Read callback: Viber Business only. An optional second callback after the final one, if the recipient read the message.
Format
| Field | Type | Present | Description |
|---|---|---|---|
messagelistId | string | always | Batch identifier (UUID). |
messageId | string | always | Message identifier from the request. |
deliverystatus | string | always | delivered, undeliverable or permanenterror. |
partscount | int | always | Parts in the channel that delivered: for SMS the text parts (for example 2), for Viber 1. |
fallbacks | array of string | always | Fallback channels that were actually sent, in the order tried. [] if there were no fallbacks. |
extendedStatuses | array of string | always | Additional statuses or reasons, see the table below. Can be []. |
cost | number | delivered only | Delivery cost. |
rate | number | delivered only | Rate per unit. |
rateAmount | number | delivered only | Amount at the rate. |
rateCurrency | string | delivered only | Rate currency. |
billAmount | number | delivered only | Amount charged. |
billCurrency | string | delivered only | Currency charged. |
undeliverable or permanenterror. Both mean “not delivered” and are handled the same way by the system. The difference is informational:
undeliverableis a general failure: TTL expired, recipient not found, no device and so on. A retry may succeed.permanenterroris a permanent error: the number is invalid or does not accept messages. A retry is pointless.
Examples
Viber delivered: final callback
{"messagelistId":"23a77e9d-6184-42c5-9099-c71c66c77dec","messageId":"77665ec7-ede3-4dc4-a523-63d6f9f0fd4a","deliverystatus":"delivered","partscount":1,"cost":0.0,"fallbacks":[],"extendedStatuses":[],"rate":0.0,"rateAmount":0.0,"rateCurrency":"EUR","billAmount":0.0,"billCurrency":"EUR"}
Viber read: second callback after the final one
{"messagelistId":"23a77e9d-6184-42c5-9099-c71c66c77dec","messageId":"77665ec7-ede3-4dc4-a523-63d6f9f0fd4a","deliverystatus":"delivered","partscount":1,"cost":0.0,"fallbacks":[],"extendedStatuses":["VIBER_SEEN"],"rate":0.0,"rateAmount":0.0,"rateCurrency":"EUR","billAmount":0.0,"billCurrency":"EUR"}
deliverystatus stays delivered; the read event is reported through extendedStatuses: ["VIBER_SEEN"]. The billing fields repeat the values of the final callback.
Viber not delivered, with a reason
{"messagelistId":"afcb3c6b-9cb3-4a01-8a35-5ba0515e1d37","messageId":"cd1898b5-7037-4999-8ad3-a2a46c7304b0","deliverystatus":"undeliverable","partscount":1,"fallbacks":[],"extendedStatuses":["VIBER_USER_NOT_FOUND"]}
Callbacks about non-delivery have no billing fields (cost, rate*, bill*).
Viber not delivered, delivered by SMS fallback
{"messagelistId":"799a5bb5-e23d-4a0e-8a33-8a9fb0d697af","messageId":"abeb8fd8-d4b5-45c1-b0d8-ae5128ba74b6","deliverystatus":"delivered","partscount":2,"cost":1.802,"fallbacks":["sms"],"extendedStatuses":[],"rate":0.901,"rateAmount":1.802,"rateCurrency":"UAH","billAmount":1.802,"billCurrency":"UAH"}
fallbacks shows the channel that actually delivered and partscount the number of SMS text parts of the fallback. The reason the Viber attempt failed is not included in this callback.
Guarantees and order
| Scenario | Callbacks |
|---|---|
| Viber delivered | 1: delivered, extendedStatuses: [] |
| Viber delivered, then read | 2: delivered, [], then delivered, ["VIBER_SEEN"] |
| Viber failed, no fallbacks | 1: undeliverable, [reason] |
| Viber failed, SMS delivered | 1: delivered, [] (the Viber reason is not included) |
| Viber failed, SMS failed | 1: undeliverable, [] |
extendedStatuses values
| Value | Meaning | With deliverystatus |
|---|---|---|
VIBER_SEEN | The recipient read the message in Viber. | delivered |
VIBER_EXPIRED | The Viber message expired before delivery. | undeliverable |
VIBER_BLOCKED_BY_USER | The recipient blocked the sender in Viber. | undeliverable |
VIBER_USER_NOT_FOUND | The recipient was not found in Viber. | undeliverable |
VIBER_NO_DEVICE | The recipient has no device with Viber or no active session. | undeliverable |
STATUS_UNKNOWN | The cause of the failure could not be determined, for example an error at the sending stage. | undeliverable |
| empty array | No additional information: delivered without a read event, or a final SMS failure. | any |