The Vonage CLI allows you to create and manage your Vonage applications. To obtain help type
vonage once the CLI has been installed.
The CLI can be installed with the following command:
npm install -g @vonage/cli
The core CLI includes everything to support Application API V2 on the command line. You can check your installed version with the command:
vonage --version vonage -v
For additional help on any feature in the CLI, you can use the help flag:
vonage --help vonage apps -h
Before you can start working with your apps, you will need to set your configuration (API Key and API Secret). This can be done using the
vonage config:set --apiKey=XXXXXX --apiSecret=XXXXXX
Your API Key and API Secret can be obtained via the Dashboard. Once set, you can check your config by running
To list your current applications use:
This displays a list showing the application ID, name and capabilities.
To show the details of a specific application (where the
APP_ID is the application ID of an application that already exists):
vonage apps:show APP_ID
Returns something like:
Application Name: glorious_falcon Application ID: d4bb...7180c Voice Settings Event Webhook: Address: https://example.com/webhook_name HTTP Method: POST Answer Webhook: Address: https://example.com/webhook_name HTTP Method: POST Messages Settings Inbound Webhook: Address: https://example.com/webhook_name HTTP Method: POST Status Webhook: Address: https://example.com/webhook_name HTTP Method: POST RTC Settings Event Webhook: Address: https://www.sample.com/webhook/rtc_event_url HTTP Method: POST VBC Settings Enabled Public Key -----BEGIN PUBLIC KEY----- MIIBI..... -----END PUBLIC KEY-----
First create a new directory for your application and change into it. You can then create an application in interactive mode using the command:
This will present a series of prompts, requesting the necessary information to create your application. Sensible defaults are provided at each prompt.
In any environment where the Vonage CLI is installed, you can also use it in a script. The only required argument is the application
vonage apps:create "Test Application 1" --voice_event_url=http://example.com/webhooks/event --voice_answer_url=http://example.com/webhooks/answer --rtc_event_url=http://example.com/webhooks/rtcevent
This creates the
vonage_app.json file in your project directory containing the Application ID, Application name and private key. This also creates a second file with the private key named
Note that the webhook URLs you are required to set depends on the capabilities you want to use in your application. This is explained in more detail in the application webhooks topic.
You can create an application with your own public key if you have a suitable public/private key pair already.
First you need a suitable public/private key pair. To create one, first enter:
ssh-keygen -t rsa -b 4096 -m PEM -f private.key
Press enter (twice) to not use a passphrase. This generates your private key,
Then enter the following:
openssl rsa -in private.key -pubout -outform PEM -out public.key.pub
public.key.pub. This is the public key you use in creating or updating your Vonage application:
vonage apps:create "Application with Public Key" --public_keyfile=public.key.pub
You can patch/update a previously created application with a command similar to:
vonage apps:update [APP_ID] --voice_event_url=http://example.com/webhooks/event --voice_answer_url=http://example.com/webhooks/answer --rtc_event_url=http://example.com/webhooks/rtcevent
You can change the application name, modify any of the webhooks, or add new capabilities. If you don't provide the
APP_ID argument, it will use interactive mode.
You can delete an application with the following command:
vonage apps:delete APP_ID
When providing the
APP_ID argument, it is assumed that you understand you are deleting and there is no confirmation.
The CLI also provides an interactive method of deletion, which allows for singular or multiple app deletion:
You will need to confirm this action.
NOTE: Deletion cannot be reversed.