Deletes all recorded media files (audio, video, transcripts) associated with a bot. This is useful for managing storage and ensuring sensitive data is removed.
Method Signature
bot.deleteBotMedia(params: BaseBotParams): Promise<void>
Parameters
The unique identifier of the bot whose media should be deleted
Response
Returns void on successful deletion. All media files associated with the bot will be permanently deleted.
Example
import { Recall } from '@recall.ai/sdk';
const client = new Recall({
apiKey: 'your-api-key',
region: 'us-west-2'
});
// Delete bot media
await client.bot.deleteBotMedia({
id: 'bot_1234567890'
});
console.log('All media files deleted');
Example: Delete Old Recordings
async function deleteOldRecordings(daysOld: number) {
const cutoffDate = new Date();
cutoffDate.setDate(cutoffDate.getDate() - daysOld);
// Get all bots older than cutoff date
const bots = await client.bot.list({
join_at_before: cutoffDate
});
console.log(`Found ${bots.results.length} bots older than ${daysOld} days`);
let deletedCount = 0;
for (const bot of bots.results) {
if (bot.status === 'done' || bot.status === 'media_expired') {
try {
await client.bot.deleteBotMedia({ id: bot.id });
deletedCount++;
console.log(`Deleted media for bot ${bot.id}`);
} catch (error) {
console.error(`Failed to delete media for bot ${bot.id}:`, error.message);
}
}
}
console.log(`Deleted media for ${deletedCount} bots`);
}
// Delete recordings older than 30 days
await deleteOldRecordings(30);
Example: Delete After Processing
async function processAndDeleteMedia(botId: string) {
// Wait for bot to complete
let bot;
while (true) {
bot = await client.bot.retrieve({ id: botId });
if (bot.status === 'done') break;
await new Promise(resolve => setTimeout(resolve, 10000));
}
console.log('Bot processing complete');
// Download or process media as needed
const transcript = await client.bot.getTranscript({ id: botId });
const intelligence = await client.bot.getBotIntellienge({ id: botId });
// Save important data elsewhere
console.log('Saving transcript and intelligence...');
// ... save to your database ...
// Delete media files
await client.bot.deleteBotMedia({ id: botId });
console.log('Media files deleted, metadata retained');
}
await processAndDeleteMedia('bot_1234567890');
Example: Conditional Deletion
async function deleteMediaIfConditionMet(botId: string) {
const bot = await client.bot.retrieve({ id: botId });
// Only delete if certain conditions are met
if (bot.status === 'done') {
const intelligence = await client.bot.getBotIntellienge({ id: botId });
// Example: Don't delete if there are action items
if (intelligence.action_items && intelligence.action_items.length > 0) {
console.log('Keeping media - action items present');
return false;
}
// Example: Don't delete if meeting was recent
const joinDate = new Date(bot.join_at);
const daysSinceJoin = (Date.now() - joinDate.getTime()) / (1000 * 60 * 60 * 24);
if (daysSinceJoin < 7) {
console.log('Keeping media - meeting was less than 7 days ago');
return false;
}
// All conditions met - delete media
await client.bot.deleteBotMedia({ id: botId });
console.log('Media deleted');
return true;
}
console.log('Bot not ready for deletion');
return false;
}
await deleteMediaIfConditionMet('bot_1234567890');
Example: Bulk Deletion with Progress
async function bulkDeleteMedia(botIds: string[]) {
console.log(`Deleting media for ${botIds.length} bots...`);
const results = {
success: 0,
failed: 0,
skipped: 0
};
for (const [index, botId] of botIds.entries()) {
console.log(`Processing ${index + 1}/${botIds.length}: ${botId}`);
try {
const bot = await client.bot.retrieve({ id: botId });
if (bot.status === 'media_expired') {
console.log(' Media already expired');
results.skipped++;
continue;
}
await client.bot.deleteBotMedia({ id: botId });
console.log(' Media deleted');
results.success++;
} catch (error) {
console.error(` Failed: ${error.message}`);
results.failed++;
}
// Rate limiting
await new Promise(resolve => setTimeout(resolve, 500));
}
console.log('\nDeletion Summary:');
console.log(` Successful: ${results.success}`);
console.log(` Failed: ${results.failed}`);
console.log(` Skipped: ${results.skipped}`);
return results;
}
const botIds = ['bot_123', 'bot_456', 'bot_789'];
await bulkDeleteMedia(botIds);
Example: Safe Deletion with Confirmation
async function safeDeleteMedia(botId: string, confirm: boolean = false) {
if (!confirm) {
console.error('Deletion not confirmed. Set confirm=true to proceed.');
return false;
}
try {
const bot = await client.bot.retrieve({ id: botId });
console.log('Bot Details:');
console.log(` ID: ${bot.id}`);
console.log(` Status: ${bot.status}`);
console.log(` Meeting: ${bot.meeting_url.platform}`);
console.log(` Date: ${new Date(bot.join_at).toLocaleString()}`);
await client.bot.deleteBotMedia({ id: botId });
console.log('\n✓ Media deleted successfully');
console.log('Note: Bot metadata is retained, only media files are deleted');
return true;
} catch (error) {
console.error('Failed to delete media:', error.message);
return false;
}
}
// Must explicitly confirm
await safeDeleteMedia('bot_1234567890', true);
Notes
- This operation is permanent and cannot be undone
- Only media files are deleted - bot metadata and logs are retained
- The bot’s status may change to
media_expired after deletion
- Attempting to access media URLs after deletion will result in errors
- Consider downloading or backing up important media before deletion
- This is useful for compliance with data retention policies