When Ringba records a call, you can download the recording by finding the Recording URL in the Call Details report or by getting the call logs using the Ringba API.
The URL you retrieve, however, is not the location of the recording file. Instead, it redirects to the current location of the recording. Fortunately, you can process the redirect URL to get the location of the recording file so you can use it in your API code.
The following code sample demonstrates how to send the redirect URL to the process that returns the final URL. Note: This example is written in Node.js, but you can implement the same approach in any language or environment that supports making HTTP requests and following redirects.
const axios = require("axios");
const RECORDING_URL = "https://media.ringba.com/recording-public?v=v1&k=<very long ID>"; // <-- replace with your URL
async function resolveUrl() {
try {
// Resolve redirects
const response = await axios.get(RECORDING_URL, {
maxRedirects: 5,
responseType: "stream",
});
// Final resolved URL after redirects
const finalUrl = response.request.res.responseUrl;
// console.log("Original URL:", RECORDING_URL);
console.log("Final URL:", finalUrl);
} catch (err) {
console.error("Failed to resolve URL");
console.error(err.message);
}
}
resolveUrl();To help automate this process, you can use a Ringba pixel to send the redirect URL to your outside system that runs this code. Then your API can use the final URL to retrieve the recording.
Note: You should write your code to retrieve the current recording location URL each time you need it since that URL may be good for as little as 6 hours. However, the redirect link you initially use is good indefinitely since call recordings are a part of the call log, and Ringba does not change or delete call logs by policy.