Some simple bash scripts for deleting all Voicemails, Call Logs, and Messages from your Twilio account.
Adapted from eric-brechemier/how-i-replaced-skype-with-twilio#6 (comment)
Some simple bash scripts for deleting all Voicemails, Call Logs, and Messages from your Twilio account.
Adapted from eric-brechemier/how-i-replaced-skype-with-twilio#6 (comment)
| #!/bin/sh | |
| # Delete all call logs from your Twilio account | |
| # | |
| # Requires: | |
| # * curl - transfer a URL | |
| # * jq - Command-line JSON processor | |
| # | |
| cd "$(dirname "$0")" | |
| accountSID='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # REQUIRED | |
| authToken='TWILIO_AUTH_TOKEN' # REQUIRED | |
| test -f ./auth.sh && . ./auth.sh | |
| if test -z "$accountSID" -o -z "$authToken" | |
| then | |
| cat <<EOF >&2 | |
| accountSID and authToken must be set at the top of this script | |
| or in a file called auth.sh in the same directory as this script. | |
| They can be found in your Twilio dashboard: | |
| https://www.twilio.com/console | |
| EOF | |
| exit 1 | |
| fi | |
| if test -z "$(which curl)" -o -z "$(which jq)" | |
| then | |
| cat <<EOF >&2 | |
| curl and jq are required. | |
| curl: https://curl.haxx.se/ | |
| jq: https://stedolan.github.io/jq/ | |
| EOF | |
| exit 2 | |
| fi | |
| api="https://api.twilio.com/2010-04-01/Accounts/$accountSID" | |
| auth="$accountSID:$authToken" | |
| curl "$api/Calls.json" -u "$auth" -s | | |
| jq '.calls[] | .sid' --raw-output | | |
| while read -r callSID | |
| do | |
| echo "Delete Call $callSID..." | |
| curl -X DELETE "$api/Calls/$callSID.json" -u "$auth" -s | |
| done | |
| echo 'Done.' |
| #!/bin/sh | |
| # Delete all message logs from your Twilio account | |
| # | |
| # Requires: | |
| # * curl - transfer a URL | |
| # * jq - Command-line JSON processor | |
| # | |
| cd "$(dirname "$0")" | |
| accountSID='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # REQUIRED | |
| authToken='TWILIO_AUTH_TOKEN' # REQUIRED | |
| test -f ./auth.sh && . ./auth.sh | |
| if test -z "$accountSID" -o -z "$authToken" | |
| then | |
| cat <<EOF >&2 | |
| accountSID and authToken must be set at the top of this script | |
| or in a file called auth.sh in the same directory as this script. | |
| They can be found in your Twilio dashboard: | |
| https://www.twilio.com/console | |
| EOF | |
| exit 1 | |
| fi | |
| if test -z "$(which curl)" -o -z "$(which jq)" | |
| then | |
| cat <<EOF >&2 | |
| curl and jq are required. | |
| curl: https://curl.haxx.se/ | |
| jq: https://stedolan.github.io/jq/ | |
| EOF | |
| exit 2 | |
| fi | |
| api="https://api.twilio.com/2010-04-01/Accounts/$accountSID" | |
| auth="$accountSID:$authToken" | |
| curl "$api/Messages.json" -u "$auth" -s | | |
| jq '.messages[] | .sid' --raw-output | | |
| while read -r messageSID | |
| do | |
| echo "Delete Message $messageSID..." | |
| curl -X DELETE "$api/Messages/$messageSID.json" -u "$auth" -s | |
| done | |
| echo 'Done.' |
| #!/bin/sh | |
| # Delete all voicemail recordings from your Twilio account | |
| # | |
| # Requires: | |
| # * curl - transfer a URL | |
| # * jq - Command-line JSON processor | |
| # | |
| cd "$(dirname "$0")" | |
| accountSID='ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' # REQUIRED | |
| authToken='TWILIO_AUTH_TOKEN' # REQUIRED | |
| test -f ./auth.sh && . ./auth.sh | |
| if test -z "$accountSID" -o -z "$authToken" | |
| then | |
| cat <<EOF >&2 | |
| accountSID and authToken must be set at the top of this script | |
| or in a file called auth.sh in the same directory as this script. | |
| They can be found in your Twilio dashboard: | |
| https://www.twilio.com/console | |
| EOF | |
| exit 1 | |
| fi | |
| if test -z "$(which curl)" -o -z "$(which jq)" | |
| then | |
| cat <<EOF >&2 | |
| curl and jq are required. | |
| curl: https://curl.haxx.se/ | |
| jq: https://stedolan.github.io/jq/ | |
| EOF | |
| exit 2 | |
| fi | |
| api="https://api.twilio.com/2010-04-01/Accounts/$accountSID" | |
| auth="$accountSID:$authToken" | |
| curl "$api/Recordings.json" -u "$auth" -s | | |
| jq '.recordings[] | .sid' --raw-output | | |
| while read -r recordingSID | |
| do | |
| echo "Delete recording $recordingSID..." | |
| curl -X DELETE "$api/Recordings/$recordingSID.json" -u "$auth" -s | |
| done | |
| echo 'Done.' |