Vonage Application API (via Vonage Python SDK)

raw JSON →
4.7.2 verified Tue May 12 auth: no python install: verified quickstart: verified

The `vonage` Python SDK (currently v4.x.x) provides a streamlined interface to interact with various Vonage APIs, including the Application API. Vonage Applications are a core concept for configuring security and capabilities (like Voice, Messages, RTC) for your Vonage services. This SDK is actively maintained with a regular release cadence, with version 4.x.x being a significant rewrite of previous major versions. While a `vonage-application` PyPI package exists (v2.0.1), the recommended and actively supported way to manage Vonage Applications programmatically in Python is through the main `vonage` SDK.

pip install vonage
error AttributeError: 'Client' object has no attribute 'application'
cause Attempting to use v4.x.x application API methods on a v3.x.x `vonage.Client` instance or trying to access the application functionality incorrectly in v4.
fix
Ensure you are using vonage.Vonage for v4.x.x, and access application methods via vonage_client.application.method_name(). If on v3, the methods were often directly on the client (e.g., client.create_application()), but upgrading to v4 is recommended.
error ModuleNotFoundError: No module named 'vonage_application'
cause Attempting to import data models from `vonage_application` but the main `vonage` SDK (v4.x.x) or its sub-packages are not correctly installed or accessible.
fix
Ensure pip install vonage has been run. The vonage package in v4 is a monorepo that includes vonage_application as a dependency. If running in an isolated environment, verify the virtual environment is activated and dependencies are correctly installed. Also, check for typos in the import path.
error Error: Invalid credentials for API request
cause Incorrect API Key/Secret or Application ID/Private Key provided, or using the wrong authentication type for the specific API endpoint being called.
fix
Verify VONAGE_API_KEY and VONAGE_API_SECRET are correct from your Vonage Dashboard. If using application-based authentication (e.g., for Voice), ensure VONAGE_APPLICATION_ID and the path to VONAGE_PRIVATE_KEY are correct, and use the Auth object appropriately for JWT authentication.
breaking Vonage Python SDK v4.x.x is a complete rewrite of v3.x.x. The main client class changed from `vonage.Client` to `vonage.Vonage`, and API methods are now accessed via attributes (e.g., `client.application.create_application()` instead of `client.create_application()`). Data models are now Pydantic-based and imported from specific sub-packages (e.g., `vonage_application.ApplicationConfig`).
fix Refer to the official v3 to v4 migration guide. Update client initialization, method calls, and data model imports. For example, `client = vonage.Vonage(auth=Auth(api_key=..., api_secret=...))` and `from vonage_application import ApplicationConfig`.
gotcha Confusing 'vonage-application' PyPI package with the main SDK. The `vonage-application` package (v2.0.1) is likely an older or highly specialized component, and the primary way to manage Vonage Applications is through the comprehensive `vonage` Python SDK (v4.x.x).
fix Always install and use the `vonage` package (e.g., `pip install vonage`) for general Vonage API interactions, including application management. Consult the official Vonage Developer documentation for Python SDK usage, which focuses on the `vonage` package.
gotcha Authentication for certain APIs (like Voice) requires an Application ID and its private key, not just API Key and Secret. Mixing these can lead to authentication errors.
fix When creating the `Auth` object for `vonage.Vonage`, use `Auth(application_id='your_app_id', private_key='path/to/private.key')` for application-specific APIs requiring JWT authentication. Ensure the private key file exists and the path is correct.
pip install 'vonage<4'
python os / libc variant status wheel install import disk
3.10 alpine (musl) 'vonage<4' - - - -
3.10 alpine (musl) vonage - - 2.10s 48.6M
3.10 slim (glibc) 'vonage<4' - - - -
3.10 slim (glibc) vonage - - 1.43s 48M
3.11 alpine (musl) 'vonage<4' - - - -
3.11 alpine (musl) vonage - - 2.60s 52.1M
3.11 slim (glibc) 'vonage<4' - - - -
3.11 slim (glibc) vonage - - 2.24s 52M
3.12 alpine (musl) 'vonage<4' - - - -
3.12 alpine (musl) vonage - - 2.46s 43.6M
3.12 slim (glibc) 'vonage<4' - - - -
3.12 slim (glibc) vonage - - 2.38s 43M
3.13 alpine (musl) 'vonage<4' - - - -
3.13 alpine (musl) vonage - - 2.00s 43.3M
3.13 slim (glibc) 'vonage<4' - - - -
3.13 slim (glibc) vonage - - 1.99s 43M
3.9 alpine (musl) 'vonage<4' - - - -
3.9 alpine (musl) vonage - - 1.88s 48.7M
3.9 slim (glibc) 'vonage<4' - - - -
3.9 slim (glibc) vonage - - 1.68s 48M

This quickstart demonstrates how to initialize the Vonage client using API key and secret, then create a new Vonage Application with voice capabilities, and finally list all existing applications. It uses the `vonage` SDK (v4.x.x) which is the current recommended approach for interacting with the Application API. Ensure `VONAGE_API_KEY` and `VONAGE_API_SECRET` environment variables are set or replaced.

import os
from vonage import Vonage, Auth
from vonage_application import ApplicationConfig

VONAGE_API_KEY = os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY')
VONAGE_API_SECRET = os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')

# Initialize Vonage client with API key and secret
auth = Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET)
vonage_client = Vonage(auth=auth)

# Create a new Vonage Application
try:
    application_data = vonage_client.application.create_application(
        ApplicationConfig(name='MyTestPythonApp', capabilities={'voice': {'webhooks': {'answer_url': {'address': 'https://example.com/answer', 'http_method': 'GET'}}}}) # Example with voice capability
    )
    print(f"Application created successfully: {application_data.name} (ID: {application_data.id})")
    
    # List applications (demonstrates another API call)
    applications = vonage_client.application.list_applications()
    print("\nAll Applications:")
    for app in applications.embedded.applications:
        print(f"- {app.name} (ID: {app.id})")

except Exception as e:
    print(f"Error creating or listing application: {e}")