# Rent and configure your virtual number using .NET SDK After searching for a number, rent and configure that number for SMS, Voice or both. Note: Before you can get started, you need the following already set up: - - [.NET 7 SDK](https://dotnet.microsoft.com/download) or later and a familiarity with how to create a new app. - [Your .NET application](/docs/numbers/getting-started/dotnet-sdk/searchavailable) for use with the Numbers API. - A virtual number you have [confirmed to be available](/docs/numbers/getting-started/dotnet-sdk/searchavailable). ## Rent and configure your virtual number Open the `Program.cs` from your Search Available Numbers .NET project. Program.cs // Use this code to rent and configure a virtual number with the .NET SDK. using System.Text.Json; using Sinch; using Sinch.Numbers; using Sinch.Numbers.Available.Rent; var sinch = new SinchClient("YOUR_project_id", "YOUR_access_key", "YOUR_access_secret"); var response = await sinch.Numbers.Available.Rent("YOUR_phone_number", new RentActiveNumberRequest() { SmsConfiguration = new SmsConfiguration { ServicePlanId = "YOUR_service_plan_id", }, VoiceConfiguration = new VoiceConfiguration { AppId = "YOUR_app_id" } }); Console.WriteLine(JsonSerializer.Serialize(response, new JsonSerializerOptions() { WriteIndented = true })); Paste the `Rent and configure a virtual number` code in place of the `search for a virtual number` code in the `Program.cs` file. ### 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 Replace following parameter values on your `Program.cs` file: | Parameter | Your value | | --- | --- | | `YOUR_service_plan_id` | Your [SMS service plan ID](https://dashboard.sinch.com/sms/api/rest)This is only required for SMS configuration. | | `YOUR_app_id` | The Voice app ID or voice API `key`. Found in the [Sinch Build Dashboard.](https://dashboard.sinch.com/voice/apps) | | `YOUR_phone_number` | The virtual phone number that you previously searched for and would like to rent. | 1. Save the file. ### Build and run your project 1. Before executing your code, you must first compile your application. Execute the following command: ```shell dotnet build ``` 1. Now you can execute the code. Run the following command: ```shell dotnet run ``` #### Response You should get a response similar to this one: ```json { "phoneNumber": "+12025550134", "projectId": "51bc3f40-f266-4ca8-8938-a1ed0ff32b9a", "displayName": "string", "regionCode": "US", "type": "MOBILE", "capability": [ "SMS" ], "money": { "currencyCode": "USD", "amount": "2.00" }, "paymentIntervalMonths": 0, "nextChargeDate": "2019-08-24T14:15:22Z", "expireAt": "2019-08-24T14:15:22Z", "smsConfiguration": { "servicePlanId": "82b42acf74924bd687ef9fb212f2060c", "scheduledProvisioning": { "servicePlanId": "82b42acf74924bd687ef9fb212f20611", "status": "WAITING", "lastUpdatedTime": "2019-08-24T14:15:22Z", "campaignId": "string", "errorCodes": [ "INTERNAL_ERROR" ] }, "campaignId": "string" }, "voiceConfiguration": { "appId": "string", "scheduledVoiceProvisioning": { "appId": "string", "status": "WAITING", "lastUpdatedTime": "2019-08-24T14:15:22Z" }, "lastUpdatedTime": "2019-08-24T14:15:22Z" } } ``` ## Next steps Send a message to yourself using the SMS API or the Voice API (after setting each up accordingly) to verify that the configuration was successful. - [Send an SMS message](/docs/sms/getting-started). - [Make a call](/docs/voice/getting-started/dotnet_sdk/make-phone-call). ## Additional resources - Explore the [API specification](/docs/numbers/api-reference/numbers) to test more endpoints. - Follow the number rental process [in the Sinch Build Dashboard](https://dashboard.sinch.com/numbers/buy-numbers) UI rather than through this API.