Use Client Callback for Failover

There are two ways to use the Callback Profile ID in Failover API requests.

  1. Adding the Callback Profile ID on the Create Configuration page. See the Failover Configuration page for more information.
  2. Adding your callback profile ID to the callback_profile_id key in your failover API requests.

👍

Base URL

https://api.kaleyra.io/v1/SID

Request Format with Callback_ProfileID

curl --location --request POST '{{URL}}/v1/{{SID}}/failover' \
--header 'api-key: {{api-key}}' \
--header 'Content-Type: {{content_type}}' \
--data-raw '{
    "config_id": "{{config_id}}",
    "recipient": [{
        "to": "{{to_number}}",
        "email": "{{email_id}}",
    }],
"callback_profile_id": "{{callback_profile_id}}",
 "ref": "{{ref}}",
 "ref1": "{{ref1}}",
 "ref2": "{{ref2}}"
    "replacables": {
        "global": "{{global_value}}",
        "whatsapp": {
            "params": "{{params}}",
            "media_url": "{{media_url}}",
            "param_header": "{{param_header}}",
            "ip": "{{ip}}",
            "param_url": "{{param_url}}",
            "caption": "{{caption}}",
            "lang_code": "{{lang_code}}",
            "preview_url": "{{preview_url}}",
            "param_lat": "{{param_lat}}",
            "param_long": "{{param_long}}",
            "param_address": "{{param_address}}",
            "param_name": "{{param_name}}",
            "language": "{{language}}",
            "type": "{{type}}",
            "header": "{{header}}",
            "footer": "{{footer}}"
        },
        "sms": {
            "body": "{{body}}",
            "params": "{{params}}"
        },
        "soip": {
            "params": "{{params}}",
            "campaign_name": "{{campaign_name }}"
        },
    }
}'

Parameters and Data Types

For more information, see Parameters and Data Types table. The fields listed in the table are sent in Callbacks.

📘

Note:

If you enter the callback_profile_id in the request, then the callback_profile_id will replace the existing Failover Configuration ProfileID.

Sample Request Format with Callback_ProfileID

curl --location --request POST '{{URL}}/v1/HXXXXXXX071US/failover' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--header 'Content-Type: application/json' \
--data-raw '{
    "config_id": "de86fe5d-02ab-455a-9893-ce6e2afxxxff",
    "recipient": [{
        "to": "9199XXXXXX40",
        "email": "[email protected]"
    }],
"callback_profile_id":"test2398xyz",
    "ref":"abc",
    "ref1":"123",
    "ref2":"123",
    "replacables": { 
        "global": null,
        "whatsapp": {
            "params": ["Jhn", "Kaleyra", "Mr John"],
            "media_url": "https://s3.ap-south-1.amazonaws.com/stage-hexa/docs/16566xxx57Screenshot_from_2022-07-01_10-54-58.png",
            "param_header": "abcd",
            "ip": "1XX.X.X.1",
            "param_url": "login",
            "caption":"test image",
            "lang_code": "",
            "preview_url": true,
            "param_lat": 38.846xxx,
            "param_long": -94.547xxx,
            "param_address": "The Pavilion, 1st Floor #175 & 176, Bannerghatta Main Rd, JP Nagar 4th Phase, Bilekahalli, Bengaluru, Karnataka 560076",
            "param_name": "Home",
            "language": "en",
            "type": "location",
            "header": "promotional message",
            "footer": "contact customer support for further details"
        },
        "sms": {
            "body": "Testing body content",
            "params": ["Jhn", "Kaleyra", "Mr John"]
        },
        "soip": {
            "params": ["Jhn", "Kaleyra", "Mr John"],
            "campaign_name": "26th Jul21 - 10:48 AM Campaign"
        },
    }
}'

Sample Callback Response

{
  "ref": "abc",
  "ref1": "123",
  "ref2": "testing ref",
  "kid": "91ee2661-7cd4-4028-8xxx-60f12728xxxx",
  "config_id": "3b36acc2-868d-410a-9fb2-b4e10xxx6e30",
  "delivered": "2",
  "channel_status_id": "8f76e83f-6d94-4e9f-a213-6efd10d0xxx6",
  "failover_id": "91ee2661-7cd4-4028-898f-60f12xxxxx7a:0",
  "channel": "whatsapp",
  "mobile": "91XXXXXXXX4",
  "email": "[email protected]",
  "channel_priority": "1",
  "status_trace": ""
} 

For information related to the Callback Response fields, see Parameters and Data Types table.

Error Codes

For information related to the Failover error code, see Failover Error Codes page.