Transfer a call
This API enables an in-progress or ongoing call to fetch and execute a XML from a different URL. If the call (the A leg) is in a Dial, you can also transfer the other party (the B leg) at the same time or only transfer the B leg to an URL. This is useful for many applications where you want to asynchronously change the behavior of a live call. For example, you can play music while the call is on hold, queue calls, transfer calls etc.
API Endpoint
POST
https://api.plivo.com/v1/Account/{auth_id}/Call/{call_uuid}/
Arguments
legs optional | Valid values are aleg, bleg or both. aleg will transfer calluuid. bleg will transfer the bridged leg of calluuid. both will transfer both aleg and bleg. |
aleg_url optional | The URL to fetch XML from for the aleg. This need to be specified in case the legs parameter is either aleg or both |
aleg_method optional | The HTTP verb to invoke the aleg_url. This defaults to POST |
bleg_url optional | The URL to fetch XML from for the bleg. This need to be specified in case the legs parameter is either bleg or both |
bleg_method optional | The HTTP verb to invoke the bleg_url. This defaults to POST |
Returns
Returns an acknowledgement that the call is transferred.
Response
HTTP Status Code: 202
{
"message": "call transfered",
"api_id": "08c94608-58bd-11e1-86da-adf28403fe48"
}
Example Request
1
2
3
4
5
6
7
8
9
import plivo
client = plivo.RestClient()
response = client.calls.transfer(
legs='aleg',
aleg_url='http://aleg.url',
call_uuid='1ed7fd89-df77-4ebf-8196-d5cf7222c918', )
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# Example for Call Update
#
require 'rubygems'
require 'plivo'
include Plivo
include Plivo::Exceptions
api = RestClient.new("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
begin
response = api.calls.update(
'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
legs: 'aleg',
aleg_url: 'http://aleg.url'
)
puts response
rescue PlivoRESTError => e
puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Example for Call update
var plivo = require('plivo');
(function main() {
'use strict';
// As the auth_id and auth_token are unspecified, Plivo will fetch them from the PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN environment variables.
var client = new plivo.Client();
client.calls.transfer(
"eba53b9e-8fbd-45c1-9444-696d2172fbc8", // call uuid
{
legs: "aleg",
alegUrl: "http://aleg.url",
},
).then(function (response) {
console.log(response);
}, function (err) {
console.error(err);
});
})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/**
* Example for Call update
*/
require 'vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoRestException;
$client = new RestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
try {
$response = $client->calls->transfer(
'eba53b9e-8fbd-45c1-9444-696d2172fbc8',
[
'legs' => 'aleg',
'aleg_url' => 'http://ALEG.URL'
]
);
print_r($response);
}
catch (PlivoRestException $ex) {
print_r($ex);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.plivo.api.samples.call;
import java.io.IOException;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.call.Call;
import com.plivo.api.models.call.CallUpdateResponse;
import com.plivo.api.models.call.LegSpecifier;
/**
* Example for Call update
*/
class CallUpdate {
public static void main(String [] args) {
Plivo.init();
try {
CallUpdateResponse response = Call.updater("eba53b9e-8fbd-45c1-9444-696d2172fbc8")
.legs(LegSpecifier.ALEG)
.alegUrl("http://aleg.url")
.update();
System.out.println(response);
} catch (PlivoRestException | IOException e) {
e.printStackTrace();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Example for Call Update
*/
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;
namespace PlivoExamples
{
internal class Program
{
public static void Main(string[] args)
{
var api = new PlivoApi("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
try
{
var response = api.Call.Transfer(
alegUrl:"http://aleg.url",
callUuid:"eba53b9e-8fbd-45c1-9444-696d2172fbc8",
legs:"aleg"
);
Console.WriteLine(response);
}
catch (PlivoRestException e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
}
1
2
3
4
curl -i --user AUTH_ID:AUTH_TOKEN \
-H "Content-Type: application/json" \
-d '{"legs": "optional_param"}' \
https://api.plivo.com/v1/Account/{auth_id}/Call/{call_uuid}/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Example for Call update
package main
import "fmt"
import "github.com/plivo/plivo-go"
func main() {
client, err := plivo.NewClient("", "", &plivo.ClientOptions{})
if err != nil {
panic(err)
}
response, err := client.Calls.Update(
"eba53b9e-8fbd-45c1-9444-696d2172fbc8",
plivo.CallUpdateParams{
Legs: "aleg",
AlegURL: "http://aleg.url",
},
)
if err != nil {
panic(err)
}
fmt.Printf("Response: %#v\n", response)
}