Callbacks (Webhook)

Callbacks (Webhook)

Callbacks are notifications that you've asked Routee to send to your endpoint when the status of your Failover messages changes.


Failover Callbacks

Your callback service will receive a POST HTTP request with a JSON body. Example:

{
"trackingId": "30830fad-21ed-49b0-89d0-bbada2fd5640",
"messages": [
{
"type": "Viber",
"trackingId": "0a047b46-a4dd-4ca8-b817-a6a134dd1234",
"to": "+306912345678",
"from": "Routeetest",
"country": "GR",
"ttl": 10,
"expireOnDelivery": false,
"expiredOnDeliveryAt": null,
"status": {
"name": "DELIVERED",
"reason": {
"detailedStatus": "Delivered",
"description": "The message was delivered to its recipient."
},
"updatedDate": "2019-07-05T10:28:44.996Z"
},
"body": {
"text": "This is a test, please ignore!",
"imageUrl": "https://example.com/image.png",
"action": {
"caption": "Go",
"targetUrl": "https://www.routee.net/"
}
},
"label": "labelName",
"failoverOnStatuses": ["EXPIRED", "FAILED", "UNDELIVERED"],
"order": 1,
"inboundUrl": "https://your-server.com/inbound",
"price": 0.035,
"createdAt": "2019-07-05T10:28:44.566Z"
},
{
"type": "Sms",
"messageId": "82a91dc3-e842-41eb-86e5-07d55eb51234",
"smsId": "1274d238-38b7-4c56-b49a-9b70d25c1234",
"to": "+306912345678",
"from": "Routee",
"country": "GR",
"operator": "Vodafone",
"ttl": 15,
"status": {
"name": "Delivered",
"reason": {
"detailedStatus": "Delivered",
"description": "The SMS was sent and it was delivered to its recipient."
},
"updatedDate": "2019-07-05T10:28:49Z"
},
"body": "Hello from failover",
"price": 0.036,
"label": "labelName",
"order": 2,
"part": 1,
"parts": 1,
"latency": 4,
"failoverOnStatuses": ["Undelivered", "Failed"],
"createdAt": "2019-07-05T10:28:45.227Z"
}
],
"terminationChannel": "Sms",
"status": "Succeeded",
"statusCode": null,
"totalPrice": 0.036,
"originatingService": "Failover",
"applicationId": "5b223c27e4b04b9cdaa71234",
"createdAt": "2019-07-05T10:28:44.44Z",
"updatedAt": "2019-07-05T10:28:49.634Z"
}

Notes on the example:

  • Viber: expireOnDelivery and expiredOnDeliveryAt are on the message object (not inside status). The button is under body.action (not body.viberAction). SMS text is in body (not message).
  • statusCode is only present when the root status is "Failed"; then it is one of the strings "0", "1", "2", "3".

Callback payload — parameter reference

KEYDESCRIPTION
Root level
trackingIdThe tracking id of the Failover flow.
messagesArray of message objects (one per step). Each object has type Sms, Viber, or Voice.
terminationChannelThe channel that ended the flow. Values: Sms, Viber, Voice.
statusOverall flow status. Values: Queued, InProgress, Succeeded, Failed.
statusCodePresent only when status is Failed. String: "0" Server error, "1" Insufficient balance, "2" No next step, "3" Not failover triggered.
totalPriceTotal cost of the flow.
originatingServiceThe service that sent the flow (e.g. Failover).
applicationIdThe application id used for the flow.
createdAtWhen the flow was created (ISO 8601).
updatedAtWhen the flow was last updated (ISO 8601).
Per message (all types)
typeChannel type. Values: Sms, Viber, Voice.
toThe recipient.
fromSender id (SMS) or sender name (Viber).
countryRecipient country (ISO 3166-1 alpha-2).
ttlTTL in minutes. Viber: 0.5–1440 (default 10). SMS: 1–1440 (default 1200).
statusMessage delivery status.
status.nameStatus name (e.g. Delivered, Undelivered, Failed for SMS; DELIVERED, EXPIRED, FAILED for Viber).
status.reasonOptional reason details.
status.reason.detailedStatusDetailed status.
status.reason.descriptionHuman-readable description.
status.updatedDateDate of the last status change (ISO 8601).
labelOptional label for the message.
failoverOnStatusesArray of status strings that trigger the next channel. Case-insensitive. Defaults: SMS — Undelivered, Failed; Viber — Expired, Failed, Undelivered; Voice — Busy, NoAnswer.
orderThe order of this step in the Failover sequence.
priceThe cost of this message.
createdAtWhen this message was created (ISO 8601).
Viber only
trackingIdTracking id of this Viber message.
expireOnDeliveryIf true, the messaging provider may set Delivered messages to Expired after TTL if no Seen status is received. Default: false.
expiredOnDeliveryAtISO 8601 date/time when the message was expired after delivery. Present only when expireOnDelivery was true and the message has expired.
bodyObject with message content.
body.textThe text of the Viber message.
body.imageUrlThe image URL.
body.actionOptional button/action.
body.action.captionButton text (1–30 characters).
body.action.targetUrlButton URL.
inboundUrlCallback URL for inbound messages. Optional. See Viber inbound messages docs.
SMS only
bodyThe SMS text (string).
messageIdId of the SMS message (same for all parts of a multipart SMS).
smsIdUnique id of this SMS part.
partCurrent part number (multipart).
partsTotal number of parts (multipart).
operatorThe operator of the recipient.
latencyOverall delivery latency (ms).

Callback strategy

You can choose when callbacks are sent:

  • OnStep — A callback is sent every time the state of the Failover flow changes.
  • OnCompletion — A callback is sent only when the Failover flow has reached a final status (Succeeded or Failed).

Callback retry policy

Your endpoint must respond with HTTP 200 OK within 2 seconds. If Routee does not receive 200 OK within 2 seconds, it will close the connection and retry up to 12 times over 24 hours, with the following delays after the initial attempt:

RetryDelay
1st30 sec
2nd1 min
3rd2 min
4th5 min
5th10 min
6th15 min
7th30 min
8th1 hour
9th2 hours
10th4 hours
11th8 hours
12th24 hours

Whitelist IP for callback service

To receive callbacks from Routee, whitelist all IPs that resolve from:

callbacksallow.routee.net