Working with the Voximplant's API

Call the Voximplant Management API directly from a VoxEngine scenario
View as Markdown

VoxEngine allows developers to make Voximplant’s Management API requests from within the scenario. For example, you can send an SMS message, or request a call history. Normally you can do one of these actions by calling one of Management API methods.

How to use

To make Management API requests from a scenario, first prepare your account:

  1. Generate a private API key in the Voximplant control panel. See Service accounts for more information.
  2. Bind the API key to the routing rule by calling the SetRuleInfo Management API method and specifying it in the bind_key_id parameter.

In the scenario, first require the VoximplantApi module:

1require(Modules.VoximplantAPI);

And create the Voximplant.Client instance:

1const client = new VoximplantApi.Client();

Now you are ready to make a request from your scenario.

You can find the list of available requests in the API reference.

Request examples

Here you can find examples of how to perform management API requests from a scenario.

This example sends an SMS message containing a “Test message” text from the 447443332211 phone number to the 447443332212 phone number:

Send an SMS
1client.SMS.sendSmsMessage({
2 source: '447443332211',
3 destination: '447443332212',
4 smsBody: 'Test message'
5})
6 .then((ev) => Logger.write(ev))
7 .catch((err) => Logger.write(err));

This example gets the first call session history record from the 2012-01-01 00:00:00 UTC to the 2014-01-01 00:00:00 UTC:

Get a call history item
1client.History.getCallHistory({
2 fromDate: new Date('2012-01-01 00:00:00 GMT'),
3 toDate: new Date('2014-01-01 00:00:00 GMT'),
4 count: '1',
5 timezone: 'Etc/GMT'
6})
7 .then((ev) => Logger.write(ev))
8 .catch((err) => Logger.write(err));