# Search for a virtual number using Python Use this guide to setup your Python application for use with the Numbers API to rent the first available Sinch virtual number and provision it with your SMS service plan. Note: Before you can get started, you need the following already set up: - - [Python](https://www.python.org/) and a familiarity with how to create a new file. - [PIP (package installer for Python)](https://pypi.org/project/pip/) and a familiarity with how to install Python modules. Steps: 1. [Install](#installing-the-sdk) the Sinch Python SDK. 2. [Set up](#set-up-your-python-application) your Python application 3. [Rent the first available virtual number](#rent-the-first-available-virtual-number) and provisoning it for use with SMS. ## Installing the SDK The easiest way to install the SDK is using [`pip`](https://pypi.org/project/pip/): 1. Open a command prompt or terminal to the local repository folder. 2. Execute the following command: ```shell pip install sinch ``` ## Set up your Python application Create a new file named `rent-any-number.py` and paste the provided code found on this page into the file. rent-any-number.py from sinch import SinchClient sinch_client = SinchClient( key_id="YOUR_key_id", key_secret="YOUR_key_secret", project_id="YOUR_project_id" ) activate_number_response = sinch_client.numbers.available.rent_any( region_code="YOUR_region_code", type_="YOUR_number_type", sms_configuration={ "servicePlanId": "YOUR_service_plan_id" } ) print(activate_number_response) ### Modify your application The code provided includes placeholder parameters. You'll need to update the parameters detailed in the following subsections with your values. #### Initialize the client Before initializing a client using this SDK, you'll need three pieces of information: - Your Project ID - An access key ID - An access key Secret These values can be found on the [Access Keys](https://dashboard.sinch.com/settings/access-keys) page of the Sinch Build Dashboard. You can also [create new access key IDs and Secrets](https://community.sinch.com/t5/Conversation-API/How-to-get-your-access-key-for-Conversation-API/ta-p/8120), if required. Note If you have trouble accessing the above link, ensure that you have gained access to the [Conversation API](https://dashboard.sinch.com/convapi/overview) by accepting the corresponding terms and conditions. #### Fill in remaining parameters 1. Assign your values to the following required parameters: | Parameter | Your value | | --- | --- | | `YOUR_region_code` | The two letter abbreviation of the country for which you'd like a number. [ISO 3166–1 alpha–2. ](https://en.wikipedia.org/wiki/ISO_3166-2) | | `YOUR_number_type` | The type of number you would like to rent. Available options are: `MOBILE`, `LOCAL`, or `TOLL_FREE`. Note that 10DLC numbers should be set to `LOCAL`. | | `YOUR_service-plan-id` | Your [SMS service plan ID](https://dashboard.sinch.com/sms/api/rest). This is required for SMS configuration. | 1. Save the file. ## Rent the first available virtual number Execute the code to rent the first available number. Open a command prompt or terminal to the location where your Python file is saved and run the following command: ```shell python rent-any-number.py ``` ### Response These steps should return a response that looks like the following: ```shell RentAnyNumberResponse( phone_number='YOUR_response_phone_number', project_id='YOUR_project_id', region_code='US', type='LOCAL', capability=['SMS', 'VOICE'], money={'currencyCode': 'USD', 'amount': '1.00'}, payment_interval_months=1, next_charge_date='2024-01-08T16:47:05.720759Z', expire_at=None, sms_configuration={'servicePlanId': '', 'scheduledProvisioning': {'servicePlanId': 'YOUR_service_plan_id', 'status': 'WAITING', 'lastUpdatedTime': '2023-12-08T16:47:07.167258Z', 'campaignId': '', 'errorCodes': []}, 'campaignId': ''}, voice_configuration={'appId': '', 'scheduledVoiceProvisioning': None, 'lastUpdatedTime': None}, callback_url='' ) ``` ## Next steps Send a message to yourself using the SMS API to verify that the configuration was successful. - [Send an SMS message](/docs/sms/getting-started). ## Additional resources - Explore the [API specification](/docs/numbers/api-reference/numbers) to test more endpoints. - Prefer a UI to search for a number? Follow the entire number searching and renting process [in the Sinch Build Dashboard](https://dashboard.sinch.com/numbers/buy-numbers).