Easily Downloading Voicemails Left To A Specific Active Phone Number


I am not a programmer so please bear with me. I am currently trying to figure out an easy way to download all of the voicemails left to a specific active phone number without having to download each one at a time. Does anybody know an easy way to do this?


  • mcoser
    edited July 15

    Hi @Reed. Matt from Twilio Support here.
    The most effective way is to run a script, but it isn't very complex.

    First, you want to pull a list of Calls to the number in question.

    Then iterate through those call SIDs to download a recording, if present.

    Here is a basic python sample to can expand upon, but you can use the same logic in any language that supports making HTTP requests.

    import requests # needed for http client - https://docs.python-requests.org/en/master/
    from twilio.rest import Client # Twilio!
    # Twilio Account SID and Auth Token - https://www.twilio.com/console
    account_sid = ''
    auth_token = ''
    # initialize the http client
    client = Client(account_sid, auth_token)
    # List all calls to the specified number
    # https://www.twilio.com/docs/voice/api/call-resource
    calls = client.calls.list(
                limit=20 # use a limit to test if you have a lot of calls
    # iterate through the list of calls to check for associated recordings
    for c in calls:
        recordings = client.recordings.list(
        # iterate through the list of recordings to save the media locally
        # https://www.twilio.com/docs/voice/api/recording
        for r in recordings:
            print(r.sid + ' - ' + c.sid)
            url = "https://api.twilio.com/2010-04-01/Accounts/" + account_sid + "/Recordings/" + r.sid + ".wav" # construct the Recording media url
            req = requests.get(url, allow_redirects=True) # make HTTP GET request to Recording media url
            filename = r.sid + ".wav" # name and location where you want to save the file - here we just name it with the Recording SID
            with open(filename, "wb") as file:  # these two lines save the file. here, we are just saving to the same dir as this script - https://docs.python.org/3/tutorial/inputoutput.html
            print("Downloaded and saved...")
  • Hey Matt! Thank you so much this was super insightful and much appreciated. :)

Sign In or Register to comment.