# Search for virtual number using PHP Use this guide to setup your PHP application for use with the Numbers API and search for an available Sinch virtual number. Note: Before you can get started, you need the following already set up: - - [PHP](https://www.php.net/manual/en/install.php) 7.3.0 or later and a familiarity with how to create a new file. - cURL 7.61.0 or later installed Steps: 1. [Set up](#set-up-your-php-file) your PHP application 2. [Search for an available virtual number](#search-for-an-available-virtual-number) for SMS, Voice or both. ## Set up your PHP file Create a file (example: `search-number.php`) and add the supplied sample code. search-number.php "US", "type" => "LOCAL" ); $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_HTTPHEADER => [ "Authorization: Basic " . base64_encode(":") ], CURLOPT_URL => "https://numbers.api.sinch.com/v1/projects/" . projectId . "/availableNumbers?" . http_build_query($query), CURLOPT_RETURNTRANSFER => true, CURLOPT_CUSTOMREQUEST => "GET", ]); $response = curl_exec($curl); $error = curl_error($curl); curl_close($curl); if ($error) { echo "cURL Error #:" . $error; } else { echo $response; } ?> ### Fill in your parameters 1. Assign your values to the following parameters: | Parameter | Your value | | --- | --- | | `YOUR_username` | your `client_id` or `key_id` found in the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys). | | `YOUR_password` | Your `client_secret` or `key_secret`. This is generated upon new key creation. Generate a new key if you have lost your secret key. | | `YOUR_ProjectID` | The project ID found in the [Sinch Build Dashboard](https://dashboard.sinch.com/settings/access-keys). | | `regionCode` | 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) | | `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`. | 1. Save the file. ## Search for an available virtual number Execute the code to search for an available number: ```bash php search-number.php ``` ### Response These steps should return a JSON list of numbers available to rent. ```json { "availableNumbers": [ { "phoneNumber": "+12089087284", "regionCode": "US", "type": "LOCAL", "capability": ["SMS"], "setupPrice": { "currencyCode": "USD", "amount": "0.00" }, "monthlyPrice": { "currencyCode": "USD", "amount": "2.00" }, "paymentIntervalMonths": 1 } ] } ``` ## Next steps Copy the `phoneNumber` you would like to use and [rent your virtual number using the Numbers API](/docs/numbers/getting-started/php/rentandconfig). ## 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).