Remove a number from your SIP trunk with Node.js

You can manage your Elastic SIP trunks with the API and remove a phone number from your SIP trunk.

In this guide you will learn:

What you need to know before you start

Before you can get started, you need the following already set up:

Set up your Node.js application

Create and then navigate to a new folder where you want to store your project. Create a new node app with npm.

Copy
Copied
npm init

Accept the defaults for the application.

Install your dependencies

We will be using the axios package to make HTTP requests.

Use the following command to install the axios package:

Copy
Copied
npm install axios

Create your file

In your project folder, create a new file named index.js in the project and paste the provided "index.js" code into the file.

This code makes a DELETE request to the EST API /trunks/{SIP_TRUNK_ID}/phoneNumbers endpoint which removes the phone number you specified in the PHONE_NUMBER 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:

ParameterYour value
PROJECT_IDThe project ID to which your SIP trunk belongs. You can find this on your Sinch dashboard.
SIP_TRUNK_IDThe ID of the SIP trunk to which you want to assign the number.
USERNAMEThe application key found on your Sinch dashboard.
PASSWORDThe application secret found on your Sinch dashboard.
PHONE_NUMBERThis should be a number you own or have access to.

Save the file.

Remove your phone number

Now you can execute the code and remove your phone number. Run the following command:

Copy
Copied
node index.js

In your console, you should see a success response showing that the phone number was removed from the SIP trunk.

Additional resources

We'd love to hear from you!
Rate this content:
Still have a question?
 
Ask the community.