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.
Important: Accessing the recording URL requires authorization credentials. See Recording Access for information about Ringba’s recording access policy and step-by-step instructions for accessing call recording URLs.
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
const USERNAME = process.env.RINGBA_USERNAME; // <-- your basic auth username
const PASSWORD = process.env.RINGBA_PASSWORD; // <-- your basic auth password
async function resolveUrl() {
try {
const response = await axios.get(RECORDING_URL, {
maxRedirects: 0,
validateStatus: (status) => status >= 200 && status < 400,
auth: {
username: USERNAME,
password: PASSWORD,
},
});
const finalUrl = response.headers.location;
if (!finalUrl) {
console.error(`No redirect returned (status ${response.status})`);
return;
}
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.