Skip to content

Instantly share code, notes, and snippets.

@craigsdennis
Last active December 12, 2019 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigsdennis/de6c4e66d0b31ab759a189fa6cbab86c to your computer and use it in GitHub Desktop.
Save craigsdennis/de6c4e66d0b31ab759a189fa6cbab86c to your computer and use it in GitHub Desktop.
Delete all calls and messages from your Twilio logs
import os
import sys
# TODO: pip install twilio
from twilio.rest import Client
# TODO: Set environment variables TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN
client = Client()
# TODO: Flip this to False to turn off the safety.
SAFETY_ON = True
answer = input(
f"Are you sure you want to delete all calls and messages from your logs for account {os.environ['TWILIO_ACCOUNT_SID']}? (y/N) > ")
if answer.lower() != "y":
print("Exiting")
sys.exit()
print("Gathering calls...")
for call in client.calls.list():
print(f"Deleting call {call.sid}")
if SAFETY_ON:
print("SAFETY is on")
else:
call.delete()
print("Gathering messages...")
for message in client.messages.list():
print(f"Deleting message {message.sid}")
if SAFETY_ON:
print("SAFETY is on")
else:
message.delete()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment