Call forwarding API
Via the Sonetel API you can configure the call forwarding of your phone number.
Optional call forwarding destinations
The API allows you to change so that incoming calls are forwarded to either of these types of destinations.
- Phone numbers
Forward incoming calls to any mobile number or landline worldwide. Call forwarding costs like a local call.
Calls can be forwarded to IVR-menus, voicemail services or announcements that you either create via the API or via the customer portal.
Incoming calls can be forwarded across the Internet to any SIP address of choice.
- Team members
You can add team members in your Sonetel account. Each of them can have their own call forwarding settings, which will apply if you connect the number to them.
Changing call forwarding with NodeJS
Sample code for changing call forwarding of a phone number with NodeJS can be found here.
The function accepts three arguments:
accessToken: This is the Oauth access token generated using the /oauth/token endpoint.
e164Number: This is the phone number for which the call forwarding has to be changed. This must be a phone number you have subscribed to.
settings: The settings object contains the details of where the calls must be forwarded. It must have two properties:
connect_to, which specifies the phone number, SIP address or ID of the voice app where the incoming calls should be forwarded, and
connect_to_type, which specifies the type of the entity specified in
The function first checks that the
e164Number arguments are passed as strings, and that the
settings argument is an object with the required properties. It then parses the
accessToken to get the account ID of the user. It then sets up an HTTP request to the Sonetel API, using the specified
hostname (defaulting to “public-api.sonetel.com” if not provided), the account ID and the phone number, and the
PUT method to update the call forwarding settings. Finally, it sends the request and handles the response.