{"id":9393,"library":"vonage-messages","title":"Vonage Messages API Python Client","description":"The `vonage-messages` library is an extension for the main `vonage` Python SDK, providing access to the Vonage Messages API for sending SMS, MMS, and WhatsApp messages. It is currently at version 1.6.2 and is actively maintained with regular updates.","status":"active","version":"1.6.2","language":"en","source_language":"en","source_url":"https://github.com/Vonage/vonage-python-sdk","tags":["messaging","sms","mms","whatsapp","vonage","api","sdk"],"install":[{"cmd":"pip install vonage-messages","lang":"bash","label":"Install vonage-messages"},{"cmd":"pip install vonage","lang":"bash","label":"Install core Vonage SDK (required)"}],"dependencies":[{"reason":"The `vonage-messages` library extends the core `vonage.Client` object, so the main `vonage` SDK is a mandatory runtime dependency.","package":"vonage"}],"imports":[{"note":"The `vonage-messages` package extends the `vonage.Client` object with the `.messages` attribute; it is not meant for direct import.","wrong":"from vonage_messages import Client","symbol":"Client","correct":"from vonage import Client"}],"quickstart":{"code":"import os\nfrom vonage import Client\n\nVONAGE_API_KEY = os.environ.get('VONAGE_API_KEY', 'YOUR_API_KEY')\nVONAGE_API_SECRET = os.environ.get('VONAGE_API_SECRET', 'YOUR_API_SECRET')\n\nif not VONAGE_API_KEY or not VONAGE_API_SECRET:\n    print(\"Please set VONAGE_API_KEY and VONAGE_API_SECRET environment variables or replace placeholders.\")\nelse:\n    client = Client(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET)\n\n    try:\n        response_data = client.messages.send(\n            {\n                \"channel\": \"sms\",\n                \"to\": \"YOUR_RECIPIENT_NUMBER\", # e.g., \"447900000000\"\n                \"from\": \"VONAGE_NUMBER\",       # Your Vonage virtual number\n                \"text\": \"Hello from Vonage Python SDK!\"\n            }\n        )\n\n        if response_data[\"messages\"][0][\"status\"] == \"0\":\n            print(\"Message sent successfully.\")\n        else:\n            print(f\"Message failed with error: {response_data['messages'][0]['error_text']}\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates sending an SMS message using the Vonage Messages API. It initializes the `vonage.Client` (which is extended by `vonage-messages`) and then uses the `client.messages.send` method. Remember to replace placeholder numbers and either set API key/secret as environment variables or directly in the code."},"warnings":[{"fix":"Ensure both `pip install vonage` and `pip install vonage-messages` are executed in your environment.","message":"The `vonage-messages` package is an extension and requires the core `vonage` package to be installed alongside it. Without `vonage`, you will encounter import errors or `AttributeError`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the Vonage API documentation to determine if you need the Messages API or the legacy SMS API. For the Messages API, use `client.messages.send()`. For legacy SMS, use `client.sms.send_message()`.","message":"This library is designed for the modern Vonage Messages API, which handles SMS, MMS, and WhatsApp via a unified endpoint. It does not directly support the older, legacy Vonage (formerly Nexmo) SMS API. If you need the legacy SMS API, refer to the `vonage.Sms` client.","severity":"breaking","affected_versions":"All versions"},{"fix":"Thoroughly review the official Vonage Python SDK migration guide. Update all imports from `nexmo` to `vonage` and adapt API calls to the new `vonage.Client` structure, especially for authentication and message sending.","message":"Users migrating from the deprecated `nexmo-python` SDK to `vonage-python-sdk` will encounter significant breaking changes, including package renames (`nexmo` to `vonage`), module paths, and method signatures.","severity":"breaking","affected_versions":"All versions (relative to `nexmo-python`)"},{"fix":"Always verify your `VONAGE_API_KEY` and `VONAGE_API_SECRET` are correctly set as environment variables or explicitly passed to the `Client` constructor with valid credentials. Handle potential `VonageError` exceptions.","message":"For convenience, the `vonage.Client` can automatically pick up `VONAGE_API_KEY` and `VONAGE_API_SECRET` from environment variables. If you pass empty strings or incorrect values, authentication will fail silently until an API call is made.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the `vonage-messages` package: `pip install vonage-messages`.","cause":"The `vonage-messages` package, which adds the `.messages` attribute to the `vonage.Client`, has not been installed.","error":"AttributeError: 'Client' object has no attribute 'messages'"},{"fix":"Install the `vonage` package: `pip install vonage`.","cause":"The core `vonage` Python SDK, which is a required dependency for `vonage-messages`, is not installed.","error":"ModuleNotFoundError: No module named 'vonage'"},{"fix":"Update your import statement to `from vonage import Client` and refactor subsequent API calls according to the `vonage` SDK documentation.","cause":"Attempting to use an old import path from the deprecated `nexmo-python` SDK instead of the current `vonage-python-sdk`.","error":"from nexmo import Client"},{"fix":"Verify that your `VONAGE_API_KEY` and `VONAGE_API_SECRET` are correctly set in your environment variables or passed to the `Client` constructor, and that they are valid for your Vonage account.","cause":"Invalid or missing Vonage API Key or API Secret used for authentication.","error":"vonage.errors.VonageError: HTTP error: 401 Client Error: Unauthorized for url: ..."}]}