> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Upgrade from Python SDK Legacy to v4.9.0 or Latest Version

> Migrate from legacy Python SDK to v4.9.0+ — code changes required

## Introduction

This is a major application update. Plivo recommends you always use the latest or an active version of our SDKs for guaranteed security, stability, and uptime. The active SDK versions are designed to handle intermittent and regional failures of API requests. In addition, they offer a host of security features, such as protection against DoS attacks and bot detection for suspicious user agents.

<Warning>
  <strong>Deprecation notice:</strong> We’re deprecating Plivo Python SDK legacy versions lower than v4.9.0 on January 31, 2022. If you use a deprecated version of our SDK after that date, your API requests and voice calls may fail intermittently. Plivo will no longer provide bug fixes to these versions, and our support team may ask you to upgrade before debugging issues.
</Warning>

## Migrate your applications

### Python version support

Version 4.x of the Python SDK requires at least Python version 2.7. It will work with later versions, including Python 3.x versions.

Use the command **pip install --upgrade plivo==4.9.0** to upgrade to the active version of the SDK, or **pip install --upgrade plivo** to upgrade to the latest version.

After you upgrade to the latest version of the SDK, you should check every program that depends on it and make changes to the syntax for several kinds of operations. Here are examples of how coding differs between the deprecated legacy version of the SDK and the latest active versions.

### Importing the SDK

<CodeGroup>
  ```py Legacy theme={null}
  import plivo, plivoxml
  ```

  ```py Latest theme={null}
  import plivo
  from plivo import plivoxml
  ```
</CodeGroup>

### Initializing

<CodeGroup>
  ```py Legacy theme={null}
  p = plivo.RestAPI('<auth_id>','<auth_token>')
  ```

  ```py Latest theme={null}
  client = plivo.RestClient('<auth_id>','<auth_token>')
  ```
</CodeGroup>

### Accessing resources

<CodeGroup>
  ```py Legacy theme={null}
  response = p.make_call(params)
  ```

  ```py Latest theme={null}
  response = client.calls.create(params)
  ```
</CodeGroup>

### Making a call

<CodeGroup>
  ```py Legacy theme={null}
  import plivo, plivoxml

  p = plivo.RestAPI('<auth_id>','<auth_token>')

  params = {
      'to': '<destination_number>',  
      'from' : '<caller_id>',
      'answer_url' : 'https://s3.amazonaws.com/static.plivo.com/answer.xml',
      'answer_method' : "GET", 
      }

  response = p.make_call(params)
  print str(response)
  ```

  ```py Latest theme={null}
  import plivo

  client = plivo.RestClient('<auth_id>','<auth_token>')

  response = client.calls.create(
      from_='<caller_id>',
      to_='<destination_number>',
      answer_url='https://s3.amazonaws.com/static.plivo.com/answer.xml',
      answer_method='GET', )
  print(response)
  ```
</CodeGroup>

### Dial XML

<CodeGroup>
  ```py Legacy theme={null}
  from flask import Flask, Response, request
  import plivoxml

  app=Flask(__name__)

  @app.route('/dial/caller_tone/', methods=['GET','POST'])
  def caller_tone():
  	response = plivoxml.Response()
  	params = {
  		'dialMusic' : "https://<yourdomain>.com/dial_music/"
  	}
  	Dial = response.addDial(**params)
  	number = "<destination_number>"
  	Dial.addNumber(number)
  	return Response(str(response), mimetype='text/xml')



  if __name__ == "__main__":
  	app.run(host='0.0.0.0', debug=True)
  ```

  ```py Latest theme={null}
  from flask import Flask, Response, request
  from plivo import plivoxml

  app = Flask(__name__)


  @app.route('/dial/caller_tone/', methods=['GET', 'POST'])
  def caller_tone():

     response = plivoxml.ResponseElement()
     response.add(plivoxml.DialElement(dial_music='https://<yourdomain>.com/dial_music/').add(
             plivoxml.NumberElement('<destination_number>')))
     print(response.to_string())


  if __name__ == "__main__":
     app.run(host='0.0.0.0', debug=True)
  ```
</CodeGroup>

### Conference XML

<CodeGroup>
  ```py Legacy theme={null}
  from flask import Flask, Response, request
  import plivoxml

  app=Flask(__name__)

  @app.route('/conference/moderated/', methods=['GET','POST'])
  def moderated_conference():
  	response = plivoxml.Response()
  	params = {
  	'startConferenceOnEnter' : "false",
  	'endConferenceOnExit' : "true",
      'waitSound' : "https://<yourdomain>.com/waitmusic/"
  	}
  	conference_name = "My Room"
  	response.addConference(conference_name, **params)
  	return Response(str(response), mimetype='text/xml')



  if __name__ == "__main__":
  	app.run(host='0.0.0.0', debug=True)
  ```

  ```py Latest theme={null}
  from flask import Flask, Response, request
  from plivo import plivoxml

  app = Flask(__name__)


  @app.route('/conference/moderated/', methods=['GET', 'POST'])
  def moderated_conference():

     response = plivoxml.ResponseElement()
     response.add(
         plivoxml.ConferenceElement(
             'My Room',
             start_conference_on_enter=False,
             wait_sound='https://<yourdomain>.com/waitmusic/'))

     return(response.to_string())


  if __name__ == "__main__":
     app.run(host='0.0.0.0', debug=True)
  ```
</CodeGroup>

### Record API

<CodeGroup>
  ```py Legacy theme={null}
  import plivo

  p = plivo.RestAPI(auth_id, auth_token)
  params = {'call_uuid' : call_uuid} 
          response = p.record(params)
  print str(response)
  ```

  ```py Latest theme={null}
  import plivo

  client = plivo.RestClient('<auth_id>','<auth_token>')
  response = client.calls.record(
      call_uuid='3a2e4c90-dcee-4931-8a59-f123ab507e60', )
  print(response)
  ```
</CodeGroup>

### Record XML

<CodeGroup>
  ```py Legacy theme={null}
  from flask import Flask, Response, request
  import plivoxml

  app=Flask(__name__)

  @app.route('/record/session/', methods=['GET','POST'])
  def session():
  	response = plivoxml.Response()

  	params = {
  		'startOnDialAnswer' : "true",
  		'action' : "https://<yourdomain>.com/get_recording/",
  		'redirect' : "false"
  	}
  	response.addRecord(**params)
  	dial = response.addDial()
  	dial.addNumber("<destination_number>")
  	
  	return Response(str(response), mimetype='text/xml')

  if __name__ == "__main__":
  	app.run(host='0.0.0.0', debug=True)
  ```

  ```py Latest theme={null}
  from flask import Flask, Response, request
  from plivo import plivoxml

  app = Flask(__name__)


  @app.route('/record/session/', methods=['GET', 'POST'])
  def session():
     response = plivoxml.ResponseElement()
     response.add(
         plivoxml.RecordElement(
             action='https://<yourdomain>.com/get_recording/',
             start_on_dial_answer=True,
             redirect=False))
     response.add(plivoxml.DialElement().add(plivoxml.NumberElement('<destination_number>')))
     return(response.to_string())
  ```
</CodeGroup>
