Getting started overview

Initiating development with Nexmo, now part of Vonage APIs, involves a series of steps to ensure secure access and successful integration. This guide focuses on the foundational process: setting up your account, obtaining the necessary API credentials, and executing a basic API call to confirm your setup. Understanding these initial steps is crucial for leveraging Nexmo's programmable communication capabilities, such as SMS, Voice, and Verify APIs.

The developer experience with Nexmo is designed to be accessible, offering clear documentation and multi-language SDKs to facilitate quick adoption. By following the outlined procedure, developers can move from account registration to sending their first message or making a voice call efficiently. This includes navigating the Vonage Dashboard to locate API keys and secrets, which are fundamental for authenticating all requests to the Nexmo platform. For a comprehensive overview of Vonage APIs, refer to the Vonage developer documentation.

Quick Reference Table

Step What to do Where
1. Sign Up Create a new Vonage API account Vonage Sign-up Page
2. Get Credentials Locate your API Key and API Secret Vonage Dashboard Settings
3. Install SDK (Optional) Install your preferred language SDK Vonage SDK Documentation
4. Make First Request Send a test SMS or make a test call Send your first SMS guide or Make your first call guide
5. Verify Success Check logs and message delivery status Vonage Dashboard Message Logs

Create an account and get keys

Accessing Nexmo APIs requires a Vonage API account. The registration process typically involves providing an email address, setting a password, and verifying your account. Upon successful registration, new accounts often receive a free credit to facilitate initial testing and development without immediate cost, as detailed on the Vonage pricing page.

Once your account is active, your primary interaction will be with the Vonage Dashboard. This centralized portal is where you manage your applications, monitor usage, and, critically, retrieve your API credentials. The two essential pieces of information for authenticating API requests are your API Key and API Secret. These are unique identifiers that link your requests to your account.

To locate your API Key and API Secret:

  1. Navigate to the Vonage Dashboard and log in.
  2. From the dashboard, look for the "Settings" or "API Settings" section.
  3. Your API Key and API Secret will be displayed there. The API Secret is often hidden by default for security purposes and may require you to click a "Show" button.

It is imperative to treat your API Secret with the same security considerations as a password. Exposing it publicly could lead to unauthorized use of your account and associated charges. Best practices recommend storing API keys securely, such as in environment variables, and never hardcoding them directly into your application's source code. For robust security practices, consider implementing OAuth 2.0 for more advanced authentication flows, though for basic programmatic access, API keys suffice.

Your first request

After obtaining your API Key and Secret, you can proceed to make your first API call. A common starting point is sending an SMS message, as it provides a clear and immediate result. Nexmo offers SDKs in several languages, including Python, Node.js, PHP, .NET, Java, and Ruby, which simplify interaction with the API. While direct HTTP requests are possible, using an SDK is generally recommended for ease of use and error handling.

Here's an example using the Node.js SDK to send an SMS. First, ensure you have Node.js and npm installed. Then, install the Vonage Node.js SDK:

npm install @vonage/server-sdk

Next, create a JavaScript file (e.g., send-sms.js) and add the following code, replacing placeholders with your actual API Key, API Secret, and phone numbers:

const { Vonage } = require('@vonage/server-sdk');

const vonage = new Vonage({
  apiKey: "YOUR_API_KEY",
  apiSecret: "YOUR_API_SECRET"
});

const from = "YOUR_VIRTUAL_NUMBER"; // Your Vonage virtual number
const to = "RECIPIENT_PHONE_NUMBER"; // Recipient's phone number
const text = "Hello from Nexmo!";

async function sendSMS() {
  try {
    const responseData = await vonage.sms.send({
      to: to,
      from: from,
      text: text
    });
    console.log('Message sent successfully:');
    responseData.messages.forEach(msg => {
      console.log(`  Message ID: ${msg['message-id']}, Status: ${msg.status}`);
    });
  } catch (error) {
    console.error('Error sending message:', error);
  }
}

sendSMS();

To execute this code, run node send-sms.js in your terminal. You should receive an SMS on the recipient's phone number, and the console will log the message ID and status. Ensure that your Vonage virtual number is correctly configured and has SMS capabilities, which you can manage in your Vonage Dashboard.

For Python developers, the process is similar. Install the SDK via pip:

pip install vonage

Then, use the following Python script:

import vonage

client = vonage.Client(key="YOUR_API_KEY", secret="YOUR_API_SECRET")
sms = vonage.Sms(client)

from_number = "YOUR_VIRTUAL_NUMBER"
to_number = "RECIPIENT_PHONE_NUMBER"
text_message = "Hello from Nexmo (Python)!"

responseData = sms.send_message({
    "from": from_number,
    "to": to_number,
    "text": text_message,
})

if responseData["messages"][0]["status"] == "0":
    print("Message sent successfully.")
else:
    print(f"Message failed with error: {responseData['messages'][0]['error-text']}")

Execute with python send_sms.py. These examples demonstrate the fundamental pattern for interacting with Nexmo APIs, involving initialization with credentials and calling a specific service method.

Common next steps

Once you've successfully sent your first message, several common next steps can deepen your integration with Nexmo APIs:

  • Explore other APIs: Beyond SMS, Nexmo offers Voice, Video, Verify, and Messages APIs. Each serves different communication needs, from programmatic calls to two-factor authentication. Refer to the Vonage API reference for detailed documentation on each service.
  • Implement webhooks: For real-time updates on message delivery status, incoming SMS, or call events, implement webhooks. Nexmo sends HTTP POST requests to your specified URL when an event occurs, allowing your application to react dynamically. This is a standard practice in event-driven API architectures for services like Stripe Payments webhooks.
  • Handle delivery receipts and errors: Integrate logic to process delivery receipts (DLRs) and potential error codes. This ensures you can track message success rates and troubleshoot issues effectively.
  • Secure your applications: Beyond secure API key storage, consider implementing more advanced security practices, especially for production environments. This includes using TLS for all communications and validating incoming webhook requests using signatures provided by Nexmo. The Vonage security concepts documentation offers further guidance.
  • Manage numbers: Acquire and manage virtual numbers through the Vonage Dashboard. These numbers are essential for sending and receiving messages and making calls programmatically.
  • Monitor usage and billing: Regularly check your usage and billing information in the Vonage Dashboard to manage costs and understand your API consumption. The Vonage pricing page provides details on pay-as-you-go rates.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some frequent problems and their solutions:

  • Invalid API Key or Secret: Double-check that your API Key and Secret are copied correctly from the Vonage Dashboard settings. Ensure there are no leading or trailing spaces.
  • Incorrect Phone Number Format: Phone numbers must be in international E.164 format (e.g., +12015550123). Omit any leading zeros, parentheses, or dashes.
  • Insufficient Funds/Credit: If you are using a trial account or have consumed your free credit, your API calls may fail. Check your balance in the Vonage Dashboard.
  • Virtual Number Not Purchased/Configured: To send SMS or make calls, you need a Vonage virtual number associated with your account and capable of the desired service (e.g., SMS-enabled). Verify this in the Vonage Dashboard numbers section.
  • Network Issues: Ensure your development environment has an active internet connection and no firewalls are blocking outbound connections to Nexmo API endpoints.
  • SDK Configuration Errors: If using an SDK, ensure it's correctly installed and initialized. Consult the specific Vonage SDK documentation for your chosen language for correct usage patterns.
  • API Rate Limits: While less common for a first call, be aware that APIs have rate limits. Repeated rapid requests might temporarily block your calls. For details, consult the Vonage API throttling documentation.
  • Check Server Logs: If your application is running on a server, review the server logs for any error messages returned by the Nexmo API. These often provide specific details about the failure.

For further assistance, the Vonage Support portal and developer community forums are valuable resources for troubleshooting and seeking help.