Assign a number to your SIP trunk with ASP.NET Core 6.0
You can manage your Elastic SIP trunks with the API and assign a phone number to your SIP trunk.
In this guide you will learn:
- How to set up your ASP.NET Core console application.
- How to assign a phone number
What you need to know before you start
Before you can get started, you need the following already set up:
- Set all Elastic SIP Trunk API configuration settings.
- ASP.NET Core 6.0 or later SDK and ASP.NET Core Runtime and a familiarity with how to create an app.
- A created SIP trunk.
Set up your ASP.NET Core 6.0 application
Create a new project folder and open a command prompt. Execute the following command to create a new ASP.NET Core 6.0 console application:
dotnet new console
Modify your application
In your project folder, open the Program.cs file and paste the provided "Program.cs" code into the file, replacing all the existing content.
This code makes a POST request to the EST API /trunks/{SIP_TRUNK_ID}/phoneNumbers endpoint which assigns the phone number you specified in the_phoneNumber
variable.Fill in your parameters
Before you can run the code, you need to update some values so you can connect to your Sinch account. Update the following parameters with your own values:
Parameter | Your value |
---|---|
_projectId | The project ID to which your SIP trunk belongs. You can find this on your Sinch dashboard. |
_sipTrunkId | The ID of the SIP trunk to which you want to assign the number. |
_key | The application key found on your Sinch dashboard. |
_secret | The application secret found on your Sinch dashboard. |
_phoneNumber | This should be a number you own or have access to. |
Save the file.
Assign your phone number
Now you can execute the code and assign your phone number. Run the following command:
dotnet run
In your console, you should see a success response showing that the phone number was added to the SIP trunk.