Cancel calls in progress
# support
d
Hello, I have a question. In case I am making 100 calls at the same time and then I want to cancel the calls, is there any way to do it?
v
@Danilo Martinez Yes, you can cancel multiple calls at the same time if you have the necessary functionality set up in your system. Typically, this would involve invoking an API endpoint or function that allows you to terminate active calls. If you're using VAPI, you would need to have a method in place to send a cancel request for each active call. If you provide me with more details on how your calls are managed, I can give you more specific guidance on how to proceed.
You can continue this conversation by mentioning me in the message.
d
I am making the calls from JavaScript one after the other making the request to the API. Then if at a certain moment I want to cancel the calls in progress I should call again to another API or do something similar. @Vapi
v
@Danilo Martinez Yes, that's correct. To cancel the calls in progress, you would typically have to make a separate API request for each call you want to cancel. This request would be to an endpoint designed to terminate an active call. The specifics of how to do this depend on the API you're using. For example, if you're using a Voice API, there might be a
cancelCall
method or similar. You would need to pass the unique identifier for each call you want to cancel to this method. Here's a simplified example of how you might do this in JavaScript:
Copy code
javascript
// Assuming you have an array of call IDs for the calls you want to cancel
let callIdsToCancel = [...];

// Function to cancel a call
function cancelCall(callId) {
  // Make an API request to the cancel endpoint
  // Replace `yourCancelEndpoint` and `yourAPIKey` with your actual endpoint and API key
  fetch(`https://api.yourvoiceprovider.com/calls/${callId}/cancel`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer yourAPIKey`,
      'Content-Type': 'application/json'
    },
  })
  .then(response => response.json())
  .then(data => console.log(`Call ${callId} cancellation response: `, data))
  .catch(error => console.error('Error cancelling call:', error));
}

// Cancel all calls in the array
callIdsToCancel.forEach(callId => {
  cancelCall(callId);
});
Please replace
yourCancelEndpoint
and
yourAPIKey
with the actual endpoint URL and API key provided by your Voice API provider. Also, ensure that you handle the responses and any potential errors appropriately. If you need assistance with a specific Voice API or have any other questions, feel free to ask!
d
Perfect, and in case I want to cancel all the calls in progress I can do it without passing the id? @Vapi
v
@Danilo Martinez In most cases, APIs require an identifier for each call to manage them individually, including for cancellation. However, if you want to cancel all calls without specifying each ID, you would need a feature in your API that supports a bulk cancel operation. If the Voice API you're using has a feature to cancel all calls in progress without specifying individual call IDs, you would follow the documentation for that specific endpoint or function. If such a feature is not available, you would need to keep track of all call IDs and iterate over them to cancel each call individually. If you're using VAPI and such a bulk cancel feature is available, you would make a single API request to the appropriate endpoint. If this feature is not documented, it's likely not supported, and you would need to cancel each call by its ID as previously described. Please check the documentation for your specific Voice API or contact their support to see if they offer a way to cancel all calls at once without individual call IDs. If you need further assistance or have more questions, feel free to ask!
s
Hey @Danilo Martinez you can make a delete request to cancel or delete all the 100 calls request, but you have to do it individually batch cancellation is not available as of now because batch schedule is not available. https://docs.vapi.ai/api-reference/calls/delete
Do let me know if you require further help.
2 Views