This topic provides some background information on using the code snippets.
Code snippets are short pieces of code you can reuse in your own applications.
Please read this information carefully, so you can best use the code snippets.
- Create a Vonage API Account
- Install Node JS - required for using the Vonage Command Line Interface (CLI).
- Install the Vonage CLI
- Install or update the Beta version of the Node Server SDK - only required if using Node.
- Configure webhooks.
- Know how to write a webhook server
- Know how to test your webhook server locally
The following replaceable information depends on the library and specific call:
||Your Vonage API key (see it on your dashboard).|
||Your Vonage API secret (also available on your dashboard).|
||Private key path.|
||The Vonage Application ID.|
All phone numbers are in E.164 format.
||Your Vonage Number. E.g.
||Replace with number you are sending from. E.g.
||Replace with the number you are sending to. E.g.
Some code snippets have more specialized variables, such as Facebook Page IDs, that will need to be replaced by actual values. Where required, these are specified on a per-code snippet basis.
The main ones you will meet here are:
/webhooks/inbound-message- You will receive a callback here when Vonage receives a message.
/webhooks/message-status- You will receive a callback here when Vonage receives a message status update.
If you are testing locally using Ngrok you will set your webhook URLs in the Vonage Application object using a format similar to the following examples:
demo in the above with whatever Ngrok generates for you, unless you have paid for a reusable URL.
NOTE: Make sure your webhook URLs are configured and your webhooks server is running before testing your application.
TIP: You only need to do this step if you are testing with Curl, as the client libraries generate JWTs as needed for you.
Once you have created a Vonage API Application you can use the Application ID and the private key file,
private.key, to generate a JWT.
TIP: If you are using the Server SDK for Node (or other languages when supported), the dynamic creation of JWTs is done for you.
If you're using the Vonage CLI, the command to create the JWT is:
JWT="$(vonage jwt --key_file=private.key --app_id=APPLICATION_ID)"
You can then view the JWT with:
Alternatively, you can use our JWT web app to generate a JWT.
TIP: You can test your generated JWT at jwt.io