Help Center Delivery callbacks (bat/messagelist)

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, undeliverable or permanenterror.
  • Read callback: Viber Business only. An optional second callback after the final one, if the recipient read the message.

Format

FieldTypePresentDescription
messagelistIdstringalwaysBatch identifier (UUID).
messageIdstringalwaysMessage identifier from the request.
deliverystatusstringalwaysdelivered, undeliverable or permanenterror.
partscountintalwaysParts in the channel that delivered: for SMS the text parts (for example 2), for Viber 1.
fallbacksarray of stringalwaysFallback channels that were actually sent, in the order tried. [] if there were no fallbacks.
extendedStatusesarray of stringalwaysAdditional statuses or reasons, see the table below. Can be [].
costnumberdelivered onlyDelivery cost.
ratenumberdelivered onlyRate per unit.
rateAmountnumberdelivered onlyAmount at the rate.
rateCurrencystringdelivered onlyRate currency.
billAmountnumberdelivered onlyAmount charged.
billCurrencystringdelivered onlyCurrency charged.

undeliverable or permanenterror. Both mean “not delivered” and are handled the same way by the system. The difference is informational:

  • undeliverable is a general failure: TTL expired, recipient not found, no device and so on. A retry may succeed.
  • permanenterror is 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

ScenarioCallbacks
Viber delivered1: delivered, extendedStatuses: []
Viber delivered, then read2: delivered, [], then delivered, ["VIBER_SEEN"]
Viber failed, no fallbacks1: undeliverable, [reason]
Viber failed, SMS delivered1: delivered, [] (the Viber reason is not included)
Viber failed, SMS failed1: undeliverable, []

extendedStatuses values

ValueMeaningWith deliverystatus
VIBER_SEENThe recipient read the message in Viber.delivered
VIBER_EXPIREDThe Viber message expired before delivery.undeliverable
VIBER_BLOCKED_BY_USERThe recipient blocked the sender in Viber.undeliverable
VIBER_USER_NOT_FOUNDThe recipient was not found in Viber.undeliverable
VIBER_NO_DEVICEThe recipient has no device with Viber or no active session.undeliverable
STATUS_UNKNOWNThe cause of the failure could not be determined, for example an error at the sending stage.undeliverable
empty arrayNo additional information: delivered without a read event, or a final SMS failure.any