Messaging
Calls
This enables you to execute SMS campaigns (outbound or inbound) by invoking a Konnect REST API or a set of APIs. The following sections provide details on the same.
Base URIhttps://konnect.kirusa.com/api/v1/Accounts/{account_id}/
Authentication and AuthorizationThe Konnect APIs make use of authentication as follows
Field | Type | Mandatory | Description |
---|---|---|---|
id | String | Yes | Unique transaction id for the request |
to | String | Yes | The destination phone number, multiple phone numbers should be passed as a JSON array separated by comma. |
from | String | No | The sender phone number. If not specified, the default sender id is used. |
direction | String | No | The direction of the message, it can be ‘inbound’, ‘outbound’ or ‘2way’. If values is not specified then ‘outbound’ is set as default. |
sender_mask | String | No | The string to mask the sender. |
body | String | Yes | The full text of the message |
expiry | Integer | No | The message expiry in seconds. E.g. if the message is valid for 5 minutes then the value needs to be set as 300. |
priority | String | No | Defines the priority of message delivery, the value can be set to ‘normal’ or ‘high’. The message with ‘high’ priority is charged at premium rate than ‘normal’ priority messages. If this parameter is not set, the default priority will be ‘normal’. |
callback_url | String | No | The URL where status of message is notified, the fields passed in the response is covered in table given below. The callback notification is provided for each SMS sent. |
track_url | Boolean | No | Flag to turn on tracking of URL clicks in case URL is present in the SMS content. The actual URL is changed to track the click. |
url_to_track | String | No | URL that is to be tracked. This URL should be present in the actual SMS content also. |
Note: Sender mask needs to be selected by the user from the Konnect user interface. The selection goes through an approval process by the Kirusa country manager. If the sender mask is not selected, then the default sender mask is used. There is a default sender mask for every Carrier. |
{ "id": "A10579090909090", "to": ["919886038842”,”919886038843”], "from": "919886000085", "body": "Welcome to Konnect !", “callback_url”: “http://myapp.com/notify” }
{ "status":"ok" }
{ "status":"error", “error_code”:”3003”, “error_reason”:”Low Balance” }
{ “id”:” A10579090909090”, "status":"accepted", "ref_ids": [{“phone_number”:” 919886038842”,”ref_id”:"AC5ef8732a3c49700934481addd5ce1659”},{“phone_number”:” 919886038843”,”ref_id”:”BD6ef8732a3c49700934481addd5ce16560”}] }
{ "id" : "A10579090909090", "ref_id" : "AC5ef8732a3c49700934481addd5ce1659", "to" : "919886038842", "url_access_time" : "May 9, 2019 5:33:30 PM IST" }
Field | Type | Mandatory | Description |
---|---|---|---|
ref_id | String | Yes | Unique reference generated by Konnect Platform. |
status | String | Yes | The status can be any of the following:- rejected, sent, failed, delivered and undelivered. In case of MO SMS it is set as received |
to | String | No | The phone number to which the message was sent. |
from | String | No | The phone number from which the message originated. |
price | String | No | The amount billed for the message |
balance | String | No | The amount remaining in the account |
body | String | No | This is only applicable when the text is received from MO SMS. |
error_code | String | Yes | The error code is set when the status is either failed; rejected or undelivered else it is blank. |
error_reason | String | Yes | The error reason is set when the status is either failed; rejected or undelivered else it is blank. |
timestamp | String | Yes | The start time of this event/status |
event_timestamp | String | Yes | The end time of this event, in case of delivery it is the delivery time |
url_access_time | String | No | The time at which the URL in the SMS body is clicked |
Field | Type | Mandatory | Description |
---|---|---|---|
id | String | Yes | Unique transaction id for the request. |
phone_number | String | Yes | The phone number to be configured for receiving incoming SMS. The phone number to be configured should be purchased from the Konnect Portal. |
callback_url | String | No | The URL where status of inbound phone number configuration as well as any incoming SMS text is notified. |
{ "id": "A10579090909090", "phone_number": "919886038842", “callback_url”: “http://myapp.com/notify” }
{ "status":"accepted", "ref_id": "AC5ef8732a3c49700934481addd5ce1659" }In case of error response looks as follows
{ "status":"rejected", "ref_id": "AC5ef8732a3c49700934481addd5ce1659", "error_code": “3050”, “error_reason”:”Invalid Parameter Value” }
Field | Type | Mandatory | Description |
---|---|---|---|
ref_id | String | Yes | Unique reference generated by Konnect Platform. |
status | String | Yes | The status is set to either “done”, “received” or “failed”. |
body | String | No | This is only applicable when the text is received from MO SMS. The status for such cases is set to “received”. |
error_code | String | Yes | The error_code is set to blank when the status is set to “done”. Please refer the table below for error_code. |
error_reason | String | Yes | The error reason is blank if the status is “done” or “received” |
timestamp | String | Yes | The start time of this event/status |
event_timestamp | String | Yes | The end time of this event, in case of delivery it is the delivery time |
{ "mode":"paid", "account_balance":"Rs.4,801", "name":"Abhirup", "status":"ok" }
Field | Type | Description |
---|---|---|
mode | String | Trial account or Paid account |
account_balance | String | Account balance of the user |
name | String | Display name of the user |
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Messages", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\r\"id\":\"your_unique_id_for_request\",\r\"from\":\"91888200XXXX\",\r\"to\":[\"91888100XXXX\",\"91888100XXXX\"],\r\"sender_mask\":\"KONNECT\",\r\"body\":\"Your charging for Subscription is successful, you are subscribed for a period of 30 days\"\r}\r", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token", "Content-Type: application/json" ) )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/InboundPhoneNumbers", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\r \"id\": \"your_unique_id_for_request\",\r \"phone_number\": \"91888300XXXX\",\r \"callback_url\": \"your_callback_url\"\r }", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "DELETE", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?>
public static void RequestToKonnect() throws JSONException { HttpURLConnection urlConnection; JSONObject json = new JSONObject(); json.put("id", "your_unique_id_for_request"); json.put("from", "91888200XXXX"); JSONArray jsonArray = new JSONArray(); jsonArray.put("91888100XXXX"); jsonArray.put("91888100XXXX"); json.put("to", jsonArray); json.put("sender_mask", "KONNECT"); json.put("body", "Your charging for Subscription is successful, you are subscribed for a period of 30 days"); String data = json.toString(); String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Messages").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("POST"); urlConnection.connect(); //Write OutputStream outputStream = urlConnection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writer.write(data); writer.close(); outputStream.close(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response); }
public static void RequestToKonnect() throws JSONException { HttpURLConnection urlConnection; JSONObject json = new JSONObject(); json.put("id", "your_unique_id_for_request"); json.put("phone_number", "91888300XXXX"); json.put("callback_url", "your_callback_url"); String data = json.toString(); String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/api/v1/Accounts/your_account_id/InboundPhoneNumbers").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("POST"); urlConnection.connect(); //Write OutputStream outputStream = urlConnection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writer.write(data); writer.close(); outputStream.close(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response); }
HttpURLConnection urlConnection; String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("DELETE"); urlConnection.connect(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response);
curl --request POST \ --url https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Messages \ --header 'Authorization: your_api_token' \ --header 'Content-Type: application/json' \ --data '{ "id":"your_unique_id_for_request", "from":"91888200XXXX", "to":["91888100XXXX","91888100XXXX"], "sender_mask":"KONNECT", "body":"Your charging for Subscription is successful, you are subscribed for a period of 30 days" }'
curl --request POST \ --url https://konnect.kirusa.com/api/v1/Accounts/your_account_id/InboundPhoneNumbers \ --header 'Authorization: your_api_token'' \ --header 'Content-Type: application/json' \ --data '{ "id": "your_unique_id_for_request", "phone_number": "91888300XXXX", "callback_url": "your_callback_url" }'
curl --location --request DELETE "https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/ InboundPhoneNumbers/91888300XXXX" \ --header "Authorization: your_api_token"
import requests url = "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Messages" payload = "{\r\"id\":\"your_unique_id_for_request\",\r\"from\":\"91888200XXXX\",\r\"to\":[\"91888100XXXX\",\"91888100XXXX\"],\r\"sender_mask\":\"KONNECT\",\r\"body\":\"Your charging for Subscription is successful, you are subscribed for a period of 30 days\"\r}\r" headers = { 'Content-Type': "application/json", 'Authorization': "your_api_token" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
import requests url = "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/InboundPhoneNumbers" payload = "{\r \"id\": \"your_unique_id_for_request\",\r \"phone_number\": \"91888300XXXX\",\r \"callback_url\": \"your_callback_url\"\r }" headers = { 'Content-Type': "application/json", 'Authorization': "your_api_token" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
import requests url = 'https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX' payload = {} headers = { 'Authorization': 'your_api_token' } response = requests.request('DELETE', url, headers = headers, data = payload, allow_redirects=False, timeout=undefined, allow_redirects=false) print(response.text)
This enables you to execute outbound voice campaigns (OBD) and Interactive Voice Response (IVR) campaigns through the Konnect platform by invoking a REST API.
Base URIhttps://konnect.kirusa.com/api/v1/Accounts/{account_id}/
Authentication and AuthorizationThe Konnect APIs make use of authentication as follows
Field | Type | Mandatory | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | String | Yes | Unique transaction id for the request. | ||||||||||||
ref_id | String | No | This reference id (preconfigured voice callflow id) is used for executing the preconfigured voice callflow. The reference id is returned in the response of callflow creation API. This can be re-used for subsequent campaigns with the same call flow, but with different/same set of recipients. | ||||||||||||
recipient | String | No | The destination phone numbers, each phone numbers must be separated by “,” delimiter.
This parameter is mandatory if the direction is ‘outbound’ or ‘2way’, for ‘inbound’ campaigns it is not required |
||||||||||||
direction | String | No | The value can be ‘inbound’, ‘outbound’ or ‘2way’. If no value is specified then default string is ‘outbound’. E.g. for premium OBD the value is set to ‘2way’. | ||||||||||||
expiry | String | No | [ Not currently supported ] The expiry in seconds, it is applicable for outbound Calls, e.g. if the message is valid for 5 minutes then the value needs to be the value needs to be set as 300. |
||||||||||||
priority | String | No | [ Not currently supported ] Defines the priority of outbound Calls delivery, the value can be set to ‘normal’ or ‘high’. The message with ‘high’ priority is charged at premium rate than ‘normal’ priority messages. If this parameter is not set, the default priority will be ‘normal’. |
||||||||||||
media_url | String | No | The URL for the media to be played in outbound call. The media file format needs to be in A-law, 64 kbps, mono.Please note that if ref_id is passed, the media_url should be null. This parameter is ignored if the doc_url is specified. | ||||||||||||
caller_id | String | No | The phone number of the OBD initiator/sender. If not specified the default caller_id is used. | ||||||||||||
ivr_number | String | No | The dial-in phone number used when the call_type is defined as ‘premium’ or direction is defined as ‘inbound’.
Premium OBD: If this number is not specified then the caller_id is configured as dial-in number for premium OBD. Inbound Calls: This parameter is mandatory for calls with direction ‘inbound’ |
||||||||||||
callback_url | String | No | The URL to be notified for the status of OBD/Inbound call. The callback notification is provided for each call. | ||||||||||||
doc_url | String | No | The fully qualified URL containing KML instructions for the call. Konnect invokes this URL when the call gets connected. The response details are covered in the section 5 Kirusa Markup Language. This parameter is ignored if the ref_id is specified.
The call_id, campaign_id, phone_number,key_pressed and call_status parameters are passed in the query string while invoking the doc_url:- The description of the parameters are as follows:-
|
||||||||||||
alt_doc_url | String | No | The fully qualified URL containing KML instructions, an alternative to the doc_url. This URL gets invoked if there is an error in accessing the doc_url. |
{ "id": "A10579090909090", "recipient": ["919886038842",”9198860347”], "caller_id": "919886000085", "media_url": "http://somewebsite.com/audio.wav", “callback_url”, “http://myapp.com/notify” }
{ "id": "A10579090909091", "media_url": "http://somewebsite.com/audio.wav", "callback_url": "http://myapp.com/notify", "ivr_number":"919977000043", "direction":"inbound" }
// If caller_id is not a 2-way number { "id":"A10579090909092", "caller_id":"919886000085", "ivr_number":"919977000042", "recipient":["919886038842",”919886038848”], "media_url": "http://somewebsite.com/audio.wav", "callback_url": "http://myapp.com/notify", "direction":"2way" } // If caller_id is a 2-way number { "id":"A10579090909092", "caller_id":"919886000085", "ivr_number":"919886000085", "recipient":["919886038842",”919886038848”], "media_url": "http://somewebsite.com/audio.wav", "callback_url": "http://myapp.com/notify", "direction":"2way" }
{ "status":"ok" }
{ "status":"error", “error_code”:”3003”, “error_reason”:”Low Balance” }
{ “id”:” A10579090909090”, "status":"accepted", "ref _ids": [{“phone_number”: “919886038842”,”ref_id”:”AC5ef8732a3c49700934481addd5ce1659"},{“phone_number”: “9198860347”,”ref_id”,”BD6ef8732a3c49700934481addd5ce1660”}] }
{ "status":"ok" }
Field | Type | Mandatory | Description |
---|---|---|---|
ref_id | String | Yes | Unique reference generated by Konnect Platform. |
recipient | String | Yes | The phone number of the recipient. |
caller_id | String | No | The phone number of the OBD initiator. |
status | String | Yes | The list of status is mentioned in the API documentation. |
price | String | Yes | The amount billed for the OBD |
balance | String | Yes | The remaining balance in the account |
error_code | String | Yes | The list of error code is mentioned in the API documentation. |
error_reason | String | Yes | The list of error reason is mentioned in the API documentation. |
call_start_time | String | No | The start time of an OBD/IVR Call. The time format is in MMM D, YYYY H:M:S AM/PM time zone of the user e.g. Nov 22, 2018 6:07:12 PM IST. |
call_end_time | String | No | The end time of an OBD/IVR Call. The time format is in MMM D, YYYY H:M:S AM/PM time zone of the user. |
call_connect_time | String | No | The time when the call was picked up. The time format is in MMM D, YYYY H:M:S AM/PM time zone of the user. |
media_duration | String | No | The length of the audio listened in seconds. |
key_pressed | String | No | The DTMF key pressed by the user in the IVR. If user presses multiple keys then each key is delimited with “,” (comma). |
media_url | String | No | If the user had recorded any audio in the callflow then the audio is sent to the user |
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"id\":\"your_unique_id_for_request\",\n\"caller_id\":\"91922100XXXX\",\n\"recipient\":[\"91888122XXXX,91888122XXXX\"],\n\"media_url\":\"your_media_url\",\n\"direction\":\"outbound\"\n}", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"id\":\"your_unique_id_for_request\",\n\"caller_id\":\"91922100XXXX\",\n\"ivr_number\":\"91997700XXXX\",\n\"recipient\":[\"91888122XXXX,91888122XXXX\"],\n\"doc_url\":\"your_kml_url\",\n\"direction\":\"2way\"\n}", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\n\"id\":\"your_unique_id_for_request\",\n\"ivr_number\":\"91922100XXXX\",\n\"media_url\":\"your_media_url\",\n\"direction\":\"inbound\"\n}", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token", "Content-Type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "DELETE", CURLOPT_HTTPHEADER => array( "Authorization: your_api_token" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?>
public static void RequestToKonnect() throws JSONException { HttpURLConnection urlConnection; JSONObject json = new JSONObject(); json.put("id", "your_unique_id_for_request"); json.put("caller_id", "91922100XXXX"); JSONArray jsonArray = new JSONArray(); jsonArray.put("91888122XXXX"); jsonArray.put("91888122XXXX"); json.put("recipient", jsonArray); json.put("media_url", "your_media_url"); json.put("direction", "outbound"); String data = json.toString(); String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("POST"); urlConnection.connect(); //Write OutputStream outputStream = urlConnection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writer.write(data); writer.close(); outputStream.close(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response); }
public static void RequestToKonnect() throws JSONException { HttpURLConnection urlConnection; JSONObject json = new JSONObject(); json.put("id", "your_unique_id_for_request"); json.put("caller_id", "91922100XXXX"); json.put("ivr_number", "91997700XXXX"); JSONArray jsonArray = new JSONArray(); jsonArray.put("91888122XXXX"); jsonArray.put("91888122XXXX"); json.put("recipient", jsonArray); json.put("doc_url", "your_kml_url"); json.put("direction", "2way"); String data = json.toString(); String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("POST"); urlConnection.connect(); //Write OutputStream outputStream = urlConnection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writer.write(data); writer.close(); outputStream.close(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response); }
public static void RequestToKonnect() throws JSONException { HttpURLConnection urlConnection; JSONObject json = new JSONObject(); json.put("id", "your_unique_id_for_request"); json.put("ivr_number", "91922100XXXX"); json.put("media_url", "your_media_url"); json.put("direction", "inbound"); String data = json.toString(); String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Content-Type", "application/json"); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("POST"); urlConnection.connect(); //Write OutputStream outputStream = urlConnection.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); writer.write(data); writer.close(); outputStream.close(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response); }
HttpURLConnection urlConnection; String response = null; try { //Connect urlConnection = (HttpURLConnection)((new URL("https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX").openConnection())); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("Authorization", "your_api_token"); urlConnection.setRequestMethod("DELETE"); urlConnection.connect(); //Read BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), "UTF-8")); String line = null; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) { sb.append(line); } bufferedReader.close(); response = sb.toString(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } System.out.println(response);
curl --request POST \ --url https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls \ --header 'Authorization: your_api_token' \ --header 'Content-Type: application/json' \ --data '{ "id":"your_unique_id_for_request", "caller_id":"91922100XXXX", "recipient":["91888122XXXX","91888122XXXX"], "media_url":"your_media_url", "direction":"outbound" }'
curl --request POST \ --url https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls \ --header 'Authorization: your_api_token' \ --header 'Content-Type: application/json' \ --data '{ "Id":"your_unique_id_for_request", "caller_id":"91922100XXXX", "ivr_number":"91997700XXXX", "recipient":["91888122XXXX","91888122XXXX"], "doc_url":"your_kml_url", "direction":"2way" }'
curl --request POST \ --url https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls \ --header 'Authorization: your_api_token' \ --header 'Content-Type: application/json' \ --data '{ "id":"your_unique_id_for_request", "ivr_number":"91922100XXXX", "media_url":"your_media_url", "direction":"inbound" }'
curl --location --request DELETE "https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/ InboundPhoneNumbers/91888300XXXX" \ --header "Authorization: your_api_token"
import requests url = "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls" payload = "{\n\"id\":\"your_unique_id_for_request\",\n\"caller_id\":\"91922100XXXX\",\n\"recipient\":[\"91888122XXXX,91888122XXXX\"],\n\"media_url\":\"your_media_url\",\n\"direction\":\"outbound\"\n}" headers = { 'Content-Type': "application/json", 'Authorization': "your_api_token" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
import requests url = "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls" payload = "{\n\"id\":\"your_unique_id_for_request\",\n\"caller_id\":\"91922100XXXX\",\n\"ivr_number\":\"91997700XXXX\",\n\"recipient\":[\"91888122XXXX,91888122XXXX\"],\n\"doc_url\":\"your_kml_url\",\n\"direction\":\"2way\"\n}" headers = { 'Content-Type': "application/json", 'Authorization': "your_api_token" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
import requests url = "https://konnect.kirusa.com/api/v1/Accounts/your_account_id/Calls" payload = "{\n\"id\":\"your_unique_id_for_request\",\n\"ivr_number\":\"91922100XXXX\",\n\"media_url\":\"your_media_url\",\n\"direction\":\"inbound\"\n}" headers = { 'Content-Type': "application/json", 'Authorization': "your_api_token" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text)
import requests url = 'https://konnect.kirusa.com/admin/api/v1/Accounts/your_account_id/InboundPhoneNumbers/91888300XXXX' payload = {} headers = { 'Authorization': 'your_api_token' } response = requests.request('DELETE', url, headers = headers, data = payload, allow_redirects=False, timeout=undefined, allow_redirects=false) print(response.text)