Update active Call
Update properties of an active phone call.
Request URL
POST
https://voice.bandwidth.com/api/v2/accounts/{accountId}/calls/{callId}
Basic Authentication
Bandwidth's Voice API leverages Basic Authentication with your Dashboard API Credentials. Read more about how Bandwidth secures endpoints in the Security & Credentials document.
Supported Parameters
Parameter | Description | Mandatory |
---|---|---|
state | (optional) The call state. Possible values: active to redirect the call (default)completed to hangup the call |
No |
redirectUrl | (optional) The URL to send the Redirect event to which will provide new BXML Required if state is active Not allowed if state is completed |
No |
redirectMethod | (optional) The HTTP method to use for the request to redirectUrl . GET or POST. Default value is POST.Not allowed if state is completed |
No |
username | (optional) The username to send in the HTTP request to answerUrl and disconnectUrl . |
No |
password | (optional) The password to send in the HTTP request to answerUrl and disconnectUrl . |
No |
tag | (optional) A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or <Tag> verb, or cleared.May be cleared by setting tag="" Max length 256 characters. Not allowed if state is completed |
No |
redirectFallbackUrl | (optional) A fallback url which, if provided, will be used to retry the redirect callback delivery in case redirectUrl fails to respond |
No |
redirectFallbackMethod | (optional) The HTTP method to use to deliver the redirect callback to redirectFallbackUrl . GET or POST. Default value is POST. |
No |
fallbackUsername | (optional) The username to send in the HTTP request to redirectFallbackUrl |
No |
fallbackPassword | (optional) The password to send in the HTTP request to redirectFallbackUrl |
No |
Example 1 of 2 : Redirect an existing phone call to a new URL
curl -X POST \
--url 'https://voice.bandwidth.com/api/v2/accounts/{accountId}/calls/{callId}' \
-u '{username}:{password}' \
-H 'Content-type: application/json' \
--data-raw '
{
"state" : "active",
"redirectUrl" : "http://www.myapp.com/new"
}'
try {
ApiModifyCallRequest modifyCallRequest = new ApiModifyCallRequest();
modifyCallRequest.setRedirectUrl("");
modifyCallRequest.setState(StateEnum.ACTIVE);
ApiResponse<Void> response = voiceClient.modifyCall(VOICE_ACCOUNT_ID, "callId", modifyCallRequest);
} catch (ApiException | IOException e) {
e.printStackTrace();
}
ApiModifyCallRequest apiModifyCallRequest = new ApiModifyCallRequest();
apiModifyCallRequest.RedirectUrl = "http://www.myapp.com/new";
apiModifyCallRequest.State = StateEnum.ACTIVE;
voiceClient.ModifyCall(VOICE_ACCOUNT_ID, callId, apiModifyCallRequest);
body = ApiModifyCallRequest.new
body.redirect_url = "http://www.myapp.com/new"
body.state = "active"
begin
voice_client.modify_call(account_id, call_id, :body => body)
rescue Exception => e
puts e
end
body = ApiModifyCallRequest()
body.redirect_url = "http://www.myapp.com/new"
body.state = "active"
try:
voice_client.modify_call(account_id, call_id, body)
except Exception as e:
print(e)
var body = new BandwidthVoice.ApiModifyCallRequest({
"redirectUrl": "http://www.myapp.com/new",
"state": "active"
});
try {
await voiceController.modifyCall(accountId, callId, body);
} catch (error) {
console.error(error);
}
$body = new BandwidthLib\Voice\Models\ApiModifyCallRequest();
$body->state = "active";
$body->redirectUrl = "http://www.myapp.com/new";
try {
$response = $voiceClient->modifyCall($accountId, $callId, $body);
print_r($response);
} catch (BandwidthLib\APIException $e) {
print_r($e);
}
Example 2 of 2: Hang Up a Phone Call
curl -X POST \
--url 'https://voice.bandwidth.com/api/v2/accounts/{accountId}/calls/{callId}' \
-u '{username}:{password}' \
-H 'Content-type: application/json' \
--data-raw '
{
"state": "completed"
}'
ApiModifyCallRequest apiModifyCallRequest = new ApiModifyCallRequest();
apiModifyCallRequest.State = StateEnum.COMPLETED;
voiceClient.ModifyCall(VOICE_ACCOUNT_ID, callId, apiModifyCallRequest);
body = ApiModifyCallRequest.new
body.state = "completed"
begin
voice_client.modify_call(VOICE_ACCOUNT_ID, "callId", body: body)
rescue Exception => e
puts e
end
body = ApiModifyCallRequest()
body.state = "completed"
try:
voice_client.modify_call(VOICE_ACCOUNT_ID, "callId", body)
except Exception as e:
print(e)
var body = new BandwidthVoice.ApiModifyCallRequest({
"state": "completed"
});
await voiceController.modifyCall(accountId, "callId", body);
$body = BandwidthLib\Voice\Models\ApiModifyCallRequest();
$body->state = "completed";
try {
$response = $voiceClient->modifyCall($accountId, "callId", $body);
print_r($response);
} catch (BandwidthLib\APIException $e) {
print_r($e);
}