Skip to main content

Vonage Messages Package

This package contains the code to use Vonage's Messages API in Python.

Usage

It is recommended to use this as part of the main vonage package. The examples below assume you've created an instance of the vonage.Vonage class called vonage_client.

How to Construct a Message

In order to send a message, you must construct a message object of the correct type.

from vonage_messages import Sms

message = Sms(
    from_='Vonage APIs',
    to='1234567890',
    text='This is a test message sent from the Vonage Python SDK',
)

This message can now be sent with

vonage_client.messages.send(message)

All possible message types from every message channel have their own message model. They are named following this rule: {Channel}{MessageType}, e.g. Sms, MmsImage, RcsFile, MessengerAudio, WhatsappSticker, ViberVideo, etc.

The different message models are listed at the bottom of the page.

Some message types have submodels with additional fields. In this case, import the submodels as well and use them to construct the overall options.

e.g.

from vonage_messages import MessengerImage, MessengerOptions, MessengerResource

messenger = MessengerImage(
    to='1234567890',
    from_='1234567890',
    image=MessengerResource(url='https://example.com/image.jpg'),
    messenger=MessengerOptions(category='message_tag', tag='invalid_tag'),
)

Send a message

To send a message, access the Messages.send method via the main Vonage object, passing in an instance of a subclass of BaseMessage like this:

from vonage import Auth, Vonage
from vonage_messages import Sms

vonage_client = Vonage(Auth(application_id='my-application-id', private_key='my-private-key'))

message = Sms(
    from_='Vonage APIs',
    to='1234567890',
    text='This is a test message sent from the Vonage Python SDK',
)

vonage_client.messages.send(message)

Mark a WhatsApp Message as Read

Note: to use this method, update the api_host attribute of the vonage_http_client.HttpClientOptions object to the API endpoint corresponding to the region where the WhatsApp number is hosted.

For example, to use the EU API endpoint, set the api_host attribute to 'api-eu.vonage.com'.

from vonage import Vonage, Auth, HttpClientOptions

auth = Auth(application_id='MY-APP-ID', private_key='MY-PRIVATE-KEY')
options = HttpClientOptions(api_host='api-eu.vonage.com')

vonage_client = Vonage(auth, options)
vonage_client.messages.mark_whatsapp_message_read('MESSAGE_UUID')

Revoke an RCS Message

Note: as above, to use this method you need to update the api_host attribute of the vonage_http_client.HttpClientOptions object to the API endpoint corresponding to the region where the WhatsApp number is hosted.

For example, to use the EU API endpoint, set the api_host attribute to 'api-eu.vonage.com'.

from vonage import Vonage, Auth, HttpClientOptions

auth = Auth(application_id='MY-APP-ID', private_key='MY-PRIVATE-KEY')
options = HttpClientOptions(api_host='api-eu.vonage.com')

vonage_client = Vonage(auth, options)
vonage_client.messages.revoke_rcs_message('MESSAGE_UUID')

Message Models

To send a message, instantiate a message model of the correct type as described above. This is a list of message models that can be used:

Sms
MmsImage, MmsVcard, MmsAudio, MmsVideo
RcsText, RcsImage, RcsVideo, RcsFile, RcsCustom
WhatsappText, WhatsappImage, WhatsappAudio, WhatsappVideo, WhatsappFile, WhatsappTemplate, WhatsappSticker, WhatsappCustom
MessengerText, MessengerImage, MessengerAudio, MessengerVideo, MessengerFile
ViberText, ViberImage, ViberVideo, ViberFile

Metadata

Release files for vonage-messages 1.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vonage-messages 1.9.0
File Size Uploaded Provenance Actions
vonage_messages-1.9.0.tar.gz 15.7 kB Without provenance Details for vonage_messages-1.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vonage-messages 1.9.0
File Interpreter ABI Platform Actions
vonage_messages-1.9.0-py3-none-any.whl Python 3 none any Details for vonage_messages-1.9.0-py3-none-any.whl

Total release size: 36.1 kB

Release files / vonage_messages-1.9.0.tar.gz

Download URL vonage_messages-1.9.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bad424a0bf8ef3d39f16671e1eef2de7d9c67c645ea3a2c703f662f1b3d7f2a6
BLAKE2b-256 checksum
How to use checksums
000ee4ca2920b8b3181a24fe7d6aa14d41539605df9161f2f2c8593defe4e8b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.13.18

Release files / vonage_messages-1.9.0-py3-none-any.whl

Download URL vonage_messages-1.9.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b75f826abfa1cb7045908c96effdbcd032a29a294628f2c4d0bafb48540d5de
BLAKE2b-256 checksum
How to use checksums
202975d281cab121efea07ac418f9656569c7b321be2cda06852162dcc16010c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.13.18

Security for vonage-messages 1.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page