{"id":19123311,"url":"https://github.com/vonage/vonage-python-code-snippets","last_synced_at":"2025-10-06T08:48:52.400Z","repository":{"id":38310153,"uuid":"64964162","full_name":"Vonage/vonage-python-code-snippets","owner":"Vonage","description":"Python code examples for using Vonage communications APIs","archived":false,"fork":false,"pushed_at":"2025-03-27T16:16:55.000Z","size":467,"stargazers_count":31,"open_issues_count":0,"forks_count":56,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-27T17:25:30.983Z","etag":null,"topics":["developer-destination","messages","nexmo","nexmo-quickstart","phone-call","python","sms","vonage"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Vonage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-04T20:13:31.000Z","updated_at":"2025-03-27T16:13:24.000Z","dependencies_parsed_at":"2023-01-25T21:00:48.791Z","dependency_job_id":"554f6679-e792-4e32-8697-b9b86cbbe6a4","html_url":"https://github.com/Vonage/vonage-python-code-snippets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vonage%2Fvonage-python-code-snippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vonage%2Fvonage-python-code-snippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vonage%2Fvonage-python-code-snippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Vonage%2Fvonage-python-code-snippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Vonage","download_url":"https://codeload.github.com/Vonage/vonage-python-code-snippets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445671,"owners_count":20939958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-destination","messages","nexmo","nexmo-quickstart","phone-call","python","sms","vonage"],"created_at":"2024-11-09T05:25:06.227Z","updated_at":"2025-10-06T08:48:47.359Z","avatar_url":"https://github.com/Vonage.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vonage Code Snippets for Python\n\n![Author](https://img.shields.io/badge/author-Vonage-orange)\n![Issues](https://img.shields.io/github/issues/Vonage/vonage-python-code-snippets)\n![License](https://img.shields.io/github/license/Vonage/vonage-python-code-snippets)\n![Stars](https://img.shields.io/github/stars/Vonage/vonage-python-code-snippets)\n![Forks](https://img.shields.io/github/forks/Vonage/vonage-python-code-snippets)\n![Last Commit](https://img.shields.io/github/last-commit/Vonage/vonage-python-code-snippets)\n![Size](https://img.shields.io/github/repo-size/Vonage/vonage-python-code-snippets)\n\nThe purpose of these Code Snippets is to provide simple examples focused\non one goal. For example, sending an SMS, creating a Vonage Video API session, handling an incoming webhook, or making a Text-to-Speech call.\n\n## Table of Contents\n\n- [Setup](#setup)\n- [Running the Examples](#running-the-examples)\n- [SDK Structure](#sdk-structure)\n- [How the SDK Handles Errors](#how-the-sdk-handles-errors)\n- [Troubleshooting](#troubleshooting)\n- [Useful Resources](#useful-resources)\n- [Request an Example](#request-an-example)\n- [License](#license)\n- [Python Code Snippets](#python-code-snippets)\n\n## Setup\n\nThese code samples are meant to be embedded into pages on [https://developer.vonage.com/](https://developer.vonage.com/). Developers are free to use these code snippets as a reference, but these may require changes to be worked into your specific application. We recommend checking out the [Vonage Developer Website](https://developer.vonage.com/), which displays these code snippets in a more copy/paste fashion.\n\nTo use the examples, you will first need a [Vonage account][sign-up]. Then rename\nthe `.env.dist` file to `.env` and set the values as required.\n\nFor some of the examples you will need to [buy a number][buy-number].\n\n## Running the Examples\n\nIf you would like to run these examples yourself, you will need to do the following:\n\nUse a virtual environment:\n\n```sh\n# Create the virtual environment\npython3 -m venv venv\n\n# Activate the virtual environment in Mac/Linux\n. ./venv/bin/activate\n\n# Or on Windows Command Prompt\nvenv\\Scripts\\activate\n```\n\nInstall the dependencies:\n\n```sh\npip install -r requirements.txt\n```\n\nRun the code:\n\nFor samples that don't use a web server, run with python, e.g.\n\n```sh\npython sms/send-an-sms.py\n```\n\nFor samples that require a web server, run with FastAPI, e.g.\n\n```sh\nfastapi dev messages/inbound-message.py\n```\n\n## SDK Structure\n\nThe SDK is a monorepo - lots of packages in a single place. In the SDK, we have:\n\n1. The top-level package `vonage`, which pulls in all the other packages you need.\n1. A package referring to every API supported in the SDK (`vonage-sms`, `vonage-voice`, `vonage-video` etc.)\n1. Internal packages for making HTTP requests, creating JWTs etc. (`vonage-http-client`, `vonage-jwt` etc.)\n1. A utilities package (`vonage-utils`)\n\nThere are important things to note:\n\n1. The `vonage` package instantiates each of the API packages. For example, you can call `vonage.voice.any_method_from_the_voice_class`. This means you don’t have to instantiate packages that you need separately.\n1. Many of the APIs require input data from the user. This is passed in through data models that you will find in the package for the specific API you want to call. This was intentional so the user doesn’t immediately import every data model from every single API whenever they import the top-level package, which would make it harder to find what is actually needed in an IDE, and allows for models with the same names in different namespaces. \n\nFor example, to use a `VerifyRequest` object from the `vonage-verify` package, you’ll need to first import the `vonage` package to get the `Auth` object and the `Verify` methods, then import `VerifyRequest` from the `vonage-verify` package, like so:\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import VerifyRequest, SmsChannel\n\nclient = Vonage(\n\tAuth(\n    \t\tapplication_id=VONAGE_APPLICATION_ID,\n    \tprivate_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH,\n\t)\n)\n\nverify_request = VerifyRequest(\n\tbrand=BRAND_NAME,\n\tworkflow=[\n    \tSmsChannel(to=TO_NUMBER),\n\t],\n)\n\nresponse = vonage_client.verify.start_verification(verify_request)\n```\n\nThis is explained in more detail in the blog post shared above. You can also find full, working examples [in the Python Code Snippets repo](https://github.com/Vonage/vonage-python-code-snippets).\n\n### Getting the Objects You Need Into Your Namespace\n\nIf you’re working with e.g. the Voice API, if you know you’re likely to use many of the data models, you can import them all into your app’s namespace (making it easier for your autocomplete etc. to find them) with the `*` operator, e.g.\n\n```python\nfrom vonage_voice import *\n\nrequest = CreateCallRequest(...)\n```\n\nIt’s usually considered better practice to import just what you need, but using this method means the data models will all be available to you if you need to do some quick testing.\n\n## How the SDK handles errors\n\nThe Vonage Python SDK has various different classes of errors:\n\n- Some regular Python/package errors that can be raised during the course of SDK operation\n- The top-level `VonageError`, that custom SDK errors inherit from\n- Errors raised when using some packages, e.g. `VerifyError`\n- Errors raised by the HTTP client\n\nIt’s likely that when troubleshooting, you’ll especially see HTTP request errors, so let’s discuss these.\n\n### HTTP Request Errors\n\nThis is a class of errors raised when actually making the HTTP request or when receiving an HTTP response.\n\nThe high-level error here is the `HttpRequestError`. There are other errors which are based on this and have the same properties, but different names that are more specific to [the HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) received from the Vonage server, e.g. an `AuthenticationError` or a `NotFoundError`.\n\nEach error of this type has properties that can be accessed when the error is caught, i.e. if you have a try-except block which catches an error, you can then access the error message and the response object which has additional information. This can be useful for debugging.\n\nTo catch an error in this way, do this:\n\n```python\ntry:\n\tvonage_client.call_vonage_api(...)\nexcept HttpRequestError as e:\n\tprint(‘Request failed:’)\n\tprint(e.message)\n\tprint(e.response.text)  \n```\n\nYou can access any information about the request or the response from the `e.response` object.\n\n## Troubleshooting\n\n### Viewing the last request and response\n\nWhether or not an HTTP request was successful, you can access the last request and response sent by accessing the relevant HTTP client attributes like this:\n\n```python\nvonage_client.http_client.last_request\nvonage_client.http_client.last_response\n```\n\nFor example, to see the last request body and headers sent by the SDK, you can do:\n\n```python\nprint(vonage_client.http_client.last_request.body)\nprint(vonage_client.http_client.last_request.headers)\n```\n\n### Authentication errors\n\nIf the SDK returns an `AuthenticationError`, this is because the Vonage Server was not able to authenticate the SDK user. In this case, you should check the authentication details that were provided.\n\n## Useful Resources\n- [Vonage Python SDK on Github](https://github.com/Vonage/vonage-python-sdk)\n- [Vonage Python SDK on PyPI](https://pypi.org/project/vonage/)\n- [Python SDK introduction blog](https://developer.vonage.com/en/blog/vonage-python-sdk-v4-is-now-live-#getting-started)\n- [Migration guide from old to new SDK](https://github.com/Vonage/vonage-python-sdk/blob/main/V3_TO_V4_SDK_MIGRATION_GUIDE.md)\n\n## Request an Example\n\nPlease [raise an issue](https://github.com/Vonage/vonage-python-code-snippets/issues) to request an example that isn't present within the quickstart. Pull requests will be gratefully received.\n\n## License\n\n[MIT](LICENSE)\n\n[sign-up]: https://dashboard.nexmo.com/sign-up\n[buy-number]: https://dashboard.nexmo.com/buy-numbers\n\n\n## Python Code Snippets\n\nThis is a list of all supported Python code snippets in the repo, organised by category.\n\n### Table of Contents\n\n- [Account](#account)\n- [Application](#application)\n- [Decode Jwt](#decode-jwt)\n- [Messages](#messages)\n- [Number Insight](#number-insight)\n- [Numbers](#numbers)\n- [Sms](#sms)\n- [Subaccounts](#subaccounts)\n- [Users](#users)\n- [Verify](#verify)\n- [Verify_Legacy](#verify_legacy)\n- [Voice](#voice)\n\n### Account\n\n#### Snippets in this Section\n\n- [Configure Account](#configure-account)\n- [Create Secret](#create-secret)\n- [Fetch A Secret](#fetch-a-secret)\n- [Get Balance](#get-balance)\n- [List All Secrets](#list-all-secrets)\n- [Revoke Secret](#revoke-secret)\n\n#### Configure Account\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_account import SettingsResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nsettings: SettingsResponse = client.account.update_default_sms_webhook(\n    mo_callback_url=ACCOUNT_SMS_CALLBACK_URL\n)\n\nprint(settings)\n```\n\n#### Create Secret\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_account import VonageApiSecret\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: VonageApiSecret = client.account.create_secret(ACCOUNT_SECRET)\nprint(response)\n```\n\n#### Fetch A Secret\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_account import VonageApiSecret\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nsecret: VonageApiSecret = client.account.get_secret(ACCOUNT_SECRET_ID)\n\nprint(f'Secret ID: {secret.id}; Created at {secret.created_at}')\n```\n\n#### Get Balance\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_account import Balance\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nbalance: Balance = client.account.get_balance()\n\nprint(f'{balance.value:0.2f} EUR, auto-reload: {balance.auto_reload}')\n```\n\n#### List All Secrets\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_account import VonageApiSecret\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: list[VonageApiSecret] = client.account.list_secrets()\nprint(response)\n```\n\n#### Revoke Secret\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\nclient.account.revoke_secret(ACCOUNT_SECRET_ID)\n```\n\n### Application\n\n#### Snippets in this Section\n\n- [Create Application](#create-application)\n- [Delete Application](#delete-application)\n- [Get Application](#get-application)\n- [List Applications](#list-applications)\n- [Update Application](#update-application)\n\n#### Create Application\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_application import (ApplicationConfig, ApplicationData,\n                                ApplicationUrl, Capabilities, Messages,\n                                MessagesWebhooks, Region, Verify,\n                                VerifyWebhooks, Voice, VoiceUrl, VoiceWebhooks)\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\n# Voice application options\nvoice = Voice(\n    webhooks=VoiceWebhooks(\n        answer_url=VoiceUrl(\n            address='https://example.com/answer',\n            http_method='POST',\n            connect_timeout=500,\n            socket_timeout=3000,\n        ),\n        fallback_answer_url=VoiceUrl(\n            address='https://example.com/fallback',\n            http_method='POST',\n            connect_timeout=500,\n            socket_timeout=3000,\n        ),\n        event_url=VoiceUrl(\n            address='https://example.com/event',\n            http_method='POST',\n            connect_timeout=500,\n            socket_timeout=3000,\n        ),\n    ),\n    signed_callbacks=True,\n    conversations_ttl=8000,\n    leg_persistence_time=14,\n    region=Region.NA_EAST,\n)\n\n# Messages application options\nmessages = Messages(\n    version='v1',\n    webhooks=MessagesWebhooks(\n        inbound_url=ApplicationUrl(\n            address='https://example.com/inbound', http_method='POST'\n        ),\n        status_url=ApplicationUrl(\n            address='https://example.com/status', http_method='POST'\n        ),\n    ),\n    authenticate_inbound_media=True,\n)\n\n# Verify application options\nverify = Verify(\n    webhooks=VerifyWebhooks(\n        status_url=ApplicationUrl(address='https://example.com/status', http_method='GET')\n    ),\n)\n\n# Set the application capabilities\ncapabilities = Capabilities(voice=voice, messages=messages, verify=verify)\n\n# Set the application configuration that will be applied\nparams = ApplicationConfig(\n    name='My Custom Application',\n    capabilities=capabilities,\n)\n\n# Call the API\nresponse: ApplicationData = client.application.create_application(params)\n\nprint(response)\n```\n\n#### Delete Application\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nclient.application.delete_application(VONAGE_APPLICATION_ID)\n```\n\n#### Get Application\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_application import ApplicationData\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: ApplicationData = client.application.get_application(VONAGE_APPLICATION_ID)\n\nprint(response)\n```\n\n#### List Applications\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_application import ListApplicationsFilter\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\napplications, next_page = client.application.list_applications(\n    filter=ListApplicationsFilter(page_size=10, page=1)\n)\n\npprint(f'Applications:\\n{applications}, \\nNext page: {next_page}')\n```\n\n#### Update Application\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_application import (ApplicationConfig, ApplicationData,\n                                ApplicationUrl, Messages, MessagesWebhooks)\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nconfig = ApplicationConfig(\n    name='My Renamed Application',\n    capabilities=Messages(\n        webhooks=MessagesWebhooks(\n            inbound_url=ApplicationUrl(\n                address='https://example.com/inbound_new_url', http_method='GET'\n            ),\n            status_url=ApplicationUrl(\n                address='https://example.com/status_new_url', http_method='GET'\n            ),\n        ),\n        authenticate_inbound_media=False,\n    ),\n)\nresponse: ApplicationData = client.application.update_application(\n    id=VONAGE_APPLICATION_ID, config=config\n)\n\nprint(response)\n```\n\n### Decode Jwt\n\n#### Snippets in this Section\n\n- [Decode Jwt](#decode-jwt)\n\n#### Decode Jwt\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\n# Load the environment\nenvpath = join(dirname(__file__), '../.env')\nload_dotenv(envpath)\n\n\nVONAGE_SIGNATURE_SECRET = os.getenv('VONAGE_SIGNATURE_SECRET')\n\nfrom fastapi import FastAPI, Request\nfrom vonage_jwt.verify_jwt import verify_signature\n\napp = FastAPI()\n\n\n@app.get('/events')\nasync def verify_signed_webhook(request: Request):\n    # Need to get the JWT after \"Bearer \" in the authorization header\n    auth_header = request.headers[\"authorization\"].split()\n    token = auth_header[1].strip()\n\n    if verify_signature(token, VONAGE_SIGNATURE_SECRET):\n        print('Valid signature')\n    else:\n        print('Invalid signature')\n```\n\n### Messages\n\n#### Snippets in this Section\n\n- [Inbound Message](#inbound-message)\n- [Message Status](#message-status)\n- [Messenger Send Audio](#messenger-send-audio)\n- [Messenger Send File](#messenger-send-file)\n- [Messenger Send Image](#messenger-send-image)\n- [Messenger Send Text](#messenger-send-text)\n- [Messenger Send Video](#messenger-send-video)\n- [Mms Send Audio](#mms-send-audio)\n- [Mms Send Image](#mms-send-image)\n- [Mms Send Vcard](#mms-send-vcard)\n- [Mms Send Video](#mms-send-video)\n- [Rcs Revoke Message](#rcs-revoke-message)\n- [Rcs Send File](#rcs-send-file)\n- [Rcs Send Image](#rcs-send-image)\n- [Rcs Send Rich Card Carousel](#rcs-send-rich-card-carousel)\n- [Rcs Send Rich Card Standalone](#rcs-send-rich-card-standalone)\n- [Rcs Send Suggested Action Create Calendar Event](#rcs-send-suggested-action-create-calendar-event)\n- [Rcs Send Suggested Action Dial](#rcs-send-suggested-action-dial)\n- [Rcs Send Suggested Action Multiple](#rcs-send-suggested-action-multiple)\n- [Rcs Send Suggested Action Open Url](#rcs-send-suggested-action-open-url)\n- [Rcs Send Suggested Action Share Location](#rcs-send-suggested-action-share-location)\n- [Rcs Send Suggested Action View Location](#rcs-send-suggested-action-view-location)\n- [Rcs Send Suggested Reply](#rcs-send-suggested-reply)\n- [Rcs Send Text](#rcs-send-text)\n- [Rcs Send Video](#rcs-send-video)\n- [Sandbox Messenger Send_Text](#sandbox-messenger-send_text)\n- [Sandbox Viber Send_Text](#sandbox-viber-send_text)\n- [Sandbox Whatsapp Send_Text](#sandbox-whatsapp-send_text)\n- [Sms Send Sms](#sms-send-sms)\n- [Verify Signed Webhooks](#verify-signed-webhooks)\n- [Viber Send File](#viber-send-file)\n- [Viber Send Image](#viber-send-image)\n- [Viber Send Text](#viber-send-text)\n- [Viber Send Video](#viber-send-video)\n- [Webhook Server](#webhook-server)\n- [Whatsapp Mark As Read](#whatsapp-mark-as-read)\n- [Whatsapp Send Audio](#whatsapp-send-audio)\n- [Whatsapp Send Authentication Template](#whatsapp-send-authentication-template)\n- [Whatsapp Send Button Link](#whatsapp-send-button-link)\n- [Whatsapp Send Button Quick Reply](#whatsapp-send-button-quick-reply)\n- [Whatsapp Send Contact](#whatsapp-send-contact)\n- [Whatsapp Send File](#whatsapp-send-file)\n- [Whatsapp Send Image](#whatsapp-send-image)\n- [Whatsapp Send Location](#whatsapp-send-location)\n- [Whatsapp Send Media Template](#whatsapp-send-media-template)\n- [Whatsapp Send Product Message Multiple Item](#whatsapp-send-product-message-multiple-item)\n- [Whatsapp Send Product Message Single Item](#whatsapp-send-product-message-single-item)\n- [Whatsapp Send Sticker By Id](#whatsapp-send-sticker-by-id)\n- [Whatsapp Send Sticker By Url](#whatsapp-send-sticker-by-url)\n- [Whatsapp Send Template](#whatsapp-send-template)\n- [Whatsapp Send Text](#whatsapp-send-text)\n- [Whatsapp Send Video](#whatsapp-send-video)\n\n#### Inbound Message\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import FastAPI, Request\n\napp = FastAPI()\n\n\n@app.post('/webhooks/inbound-message')\nasync def inbound_message(request: Request):\n    data = await request.json()\n    pprint(data)\n```\n\n#### Message Status\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import FastAPI, Request, status\n\napp = FastAPI()\n\n\n@app.post('/webhooks/message-status', status_code=status.HTTP_200_OK)\nasync def message_status(request: Request):\n    data = await request.json()\n    pprint(data)\n```\n\n#### Messenger Send Audio\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MessengerAudio, MessengerResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MessengerAudio(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    audio=MessengerResource(url=MESSAGES_AUDIO_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Messenger Send File\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MessengerFile, MessengerResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MessengerFile(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    file=MessengerResource(url=MESSAGES_FILE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Messenger Send Image\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MessengerImage, MessengerResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MessengerImage(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    image=MessengerResource(url=MESSAGES_IMAGE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Messenger Send Text\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MessengerText\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MessengerText(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    text='Hello from the Vonage Messages API.',\n)\ntry:\n    response = client.messages.send(message)\n    print(response)\nexcept Exception as e:\n    print(e)\n    print(client.http_client.last_request.url)\n```\n\n#### Messenger Send Video\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MessengerResource, MessengerVideo\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MessengerVideo(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    video=MessengerResource(url=MESSAGES_VIDEO_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Mms Send Audio\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MmsAudio, MmsResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MmsAudio(\n    to=MESSAGES_TO_NUMBER,\n    from_=MMS_SENDER_ID,\n    audio=MmsResource(url=MESSAGES_AUDIO_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Mms Send Image\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MmsImage, MmsResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MmsImage(\n    to=MESSAGES_TO_NUMBER,\n    from_=MMS_SENDER_ID,\n    image=MmsResource(url=MESSAGES_IMAGE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Mms Send Vcard\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MmsResource, MmsVcard\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MmsVcard(\n    to=MESSAGES_TO_NUMBER,\n    from_=MMS_SENDER_ID,\n    vcard=MmsResource(url=MESSAGES_VCARD_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Mms Send Video\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import MmsResource, MmsVideo\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = MmsVideo(\n    to=MESSAGES_TO_NUMBER,\n    from_=MMS_SENDER_ID,\n    video=MmsResource(url=MESSAGES_VIDEO_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Revoke Message\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    auth=Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse = client.messages.revoke_rcs_message(MESSAGES_MESSAGE_ID)\nprint(response)\n```\n\n#### Rcs Send File\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsFile, RcsResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = RcsFile(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    file=RcsResource(url=MESSAGES_FILE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Image\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsImage, RcsResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = RcsImage(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    image=RcsResource(url=MESSAGES_IMAGE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Rich Card Carousel\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"richCard\": {\n            \"carouselCard\": {\n                \"cardWidth\": \"MEDIUM\",\n                \"cardContents\": [\n                    {\n                        \"title\": \"Option 1: Photo\",\n                        \"description\": \"Do you prefer this photo?\",\n                        \"suggestions\": [\n                            {\n                                \"reply\": {\n                                    \"text\": \"Option 1\",\n                                    \"postbackData\": \"card_1\",\n                                }\n                            }\n                        ],\n                        \"media\": {\n                            \"height\": \"MEDIUM\",\n                            \"contentInfo\": {\n                                \"fileUrl\": MESSAGES_IMAGE_URL,\n                                \"forceRefresh\": \"false\",\n                            },\n                        },\n                    },\n                    {\n                        \"title\": \"Option 2: Video\",\n                        \"description\": \"Or this video?\",\n                        \"suggestions\": [\n                            {\n                                \"reply\": {\n                                    \"text\": \"Option 2\",\n                                    \"postbackData\": \"card_2\",\n                                }\n                            }\n                        ],\n                        \"media\": {\n                            \"height\": \"MEDIUM\",\n                            \"contentInfo\": {\n                                \"fileUrl\": MESSAGES_VIDEO_URL,\n                                \"forceRefresh\": \"false\",\n                            },\n                        },\n                    },\n                ],\n            }\n        }\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Rich Card Standalone\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"richCard\": {\n            \"standaloneCard\": {\n                \"thumbnailImageAlignment\": \"RIGHT\",\n                \"cardOrientation\": \"VERTICAL\",\n                \"cardContent\": {\n                    \"title\": \"Quick question\",\n                    \"description\": \"Do you like this picture?\",\n                    \"media\": {\n                        \"height\": \"TALL\",\n                        \"contentInfo\": {\n                            \"fileUrl\": MESSAGES_IMAGE_URL,\n                            \"forceRefresh\": \"false\",\n                        },\n                    },\n                    \"suggestions\": [\n                        {\n                            \"reply\": {\n                                \"text\": \"Yes\",\n                                \"postbackData\": \"suggestion_1\",\n                            }\n                        },\n                        {\n                            \"reply\": {\n                                \"text\": \"I love it!\",\n                                \"postbackData\": \"suggestion_2\",\n                            }\n                        },\n                    ],\n                },\n            }\n        }\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action Create Calendar Event\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Product Launch: Save the date!\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"Save to calendar\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"fallbackUrl\": \"https://www.google.com/calendar\",\n                    \"createCalendarEventAction\": {\n                        \"startTime\": \"2024-06-28T19:00:00Z\",\n                        \"endTime\": \"2024-06-28T20:00:00Z\",\n                        \"title\": \"Vonage API Product Launch\",\n                        \"description\": \"Event to demo Vonage\\'s new and exciting API product\",\n                    },\n                }\n            }\n        ],\n    }\n}\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action Dial\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Call us to claim your free gift!\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"Call now!\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"fallbackUrl\": \"https://www.example.com/contact/\",\n                    \"dialAction\": {\"phoneNumber\": \"+447900000000\"},\n                }\n            }\n        ],\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action Multiple\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Need some help? Call us now or visit our website for more information.\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"Call us\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"fallbackUrl\": \"https://www.example.com/contact/\",\n                    \"dialAction\": {\"phoneNumber\": \"+447900000000\"},\n                }\n            },\n            {\n                \"action\": {\n                    \"text\": \"Visit site\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"openUrlAction\": {\"url\": \"http://example.com/\"},\n                }\n            },\n        ],\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action Open Url\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Check out our latest offers!\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"Open product page\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"openUrlAction\": {\"url\": \"http://example.com/\"},\n                }\n            }\n        ],\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action Share Location\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Your driver will come and meet you at your specified location.\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"Share a location\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"shareLocationAction\": {},\n                }\n            }\n        ],\n    }\n}\n\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Action View Location\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"Drop by our office!\",\n        \"suggestions\": [\n            {\n                \"action\": {\n                    \"text\": \"View map\",\n                    \"postbackData\": \"postback_data_1234\",\n                    \"fallbackUrl\": \"https://www.google.com/maps/place/Vonage/@51.5230371,-0.0852492,15z\",\n                    \"viewLocationAction\": {\n                        \"latLong\": {\n                            \"latitude\": \"51.5230371\",\n                            \"longitude\": \"-0.0852492\",\n                        },\n                        \"label\": \"Vonage London Office\",\n                    },\n                }\n            }\n        ],\n    }\n}\n\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Suggested Reply\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\ncustom_dict = {\n    \"contentMessage\": {\n        \"text\": \"What do you think of Vonage APIs?\",\n        \"suggestions\": [\n            {\n                \"reply\": {\n                    \"text\": \"They\\'re great!\",\n                    \"postbackData\": \"suggestion_1\",\n                }\n            },\n            {\n                \"reply\": {\n                    \"text\": \"They\\'re awesome!\",\n                    \"postbackData\": \"suggestion_2\",\n                }\n            },\n        ],\n    }\n}\n\nmessage = RcsCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    custom=custom_dict,\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Text\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsText\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = RcsText(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    text=\"This is an RCS message sent via the Vonage Messages API.\",\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Rcs Send Video\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import RcsResource, RcsVideo\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = RcsVideo(\n    to=MESSAGES_TO_NUMBER,\n    from_=RCS_SENDER_ID,\n    video=RcsResource(url=MESSAGES_VIDEO_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Sandbox Messenger Send_Text\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\n\nMESSAGES_SANDBOX_HOST = os.environ.get(\"MESSAGES_SANDBOX_HOST\")\nMESSENGER_RECIPIENT_ID = os.environ.get(\"MESSENGER_RECIPIENT_ID\")\nMESSENGER_SENDER_ID = os.environ.get(\"MESSENGER_SENDER_ID\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\nfrom vonage_messages import MessengerText\n\nclient = Vonage(\n    auth=Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host=MESSAGES_SANDBOX_HOST),\n)\n\nmessage = MessengerText(\n    to=MESSENGER_RECIPIENT_ID,\n    from_=MESSENGER_SENDER_ID,\n    text=\"This is a Facebook Messenger text message sent using the Vonage Messages API via the Messages Sandbox\",\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Sandbox Viber Send_Text\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\n\nMESSAGES_SANDBOX_HOST = os.environ.get(\"MESSAGES_SANDBOX_HOST\")\nMESSAGES_TO_NUMBER = os.environ.get(\"MESSAGES_TO_NUMBER\")\nVIBER_SENDER_ID = os.environ.get(\"VIBER_SENDER_ID\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\nfrom vonage_messages import ViberText\n\nclient = Vonage(\n    auth=Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host=MESSAGES_SANDBOX_HOST),\n)\n\nmessage = ViberText(\n    to=MESSAGES_TO_NUMBER,\n    from_=VIBER_SENDER_ID,\n    text=\"This is a Viber Service Message text message sent using the Messages API via the Messages Sandbox\",\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Sandbox Whatsapp Send_Text\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\n\nMESSAGES_SANDBOX_HOST = os.environ.get(\"MESSAGES_SANDBOX_HOST\")\nMESSAGES_TO_NUMBER = os.environ.get(\"MESSAGES_TO_NUMBER\")\nWHATSAPP_SENDER_ID = os.environ.get(\"WHATSAPP_SENDER_ID\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\nfrom vonage_messages import WhatsappText\n\nclient = Vonage(\n    auth=Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host=MESSAGES_SANDBOX_HOST),\n)\n\nmessage = WhatsappText(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    text=\"This is a WhatsApp text message sent using the Vonage Messages API via the Messages Sandbox\",\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Sms Send Sms\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import Sms\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse = client.messages.send(\n    Sms(\n        to=MESSAGES_TO_NUMBER,\n        from_=SMS_SENDER_ID,\n        text='This is an SMS sent using the Vonage Messages API.',\n    )\n)\nprint(response)\n```\n\n#### Verify Signed Webhooks\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\n# Load the environment\nenvpath = join(dirname(__file__), '../.env')\nload_dotenv(envpath)\n\n\nVONAGE_SIGNATURE_SECRET = os.getenv('VONAGE_SIGNATURE_SECRET')\n\nfrom fastapi import FastAPI, Request\nfrom vonage_jwt.verify_jwt import verify_signature\n\napp = FastAPI()\n\n\n@app.get('/inbound')\nasync def verify_signed_webhook(request: Request):\n    # Need to get the JWT after \"Bearer \" in the authorization header\n    auth_header = request.headers[\"authorization\"].split()\n    token = auth_header[1].strip()\n\n    if verify_signature(token, VONAGE_SIGNATURE_SECRET):\n        print('Valid signature')\n    else:\n        print('Invalid signature')\n```\n\n#### Viber Send File\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import ViberFile, ViberFileResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = ViberFile(\n    to=MESSAGES_TO_NUMBER,\n    from_=VIBER_SENDER_ID,\n    file=ViberFileResource(url=MESSAGES_FILE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Viber Send Image\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import ViberImage, ViberImageResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = ViberImage(\n    to=MESSAGES_TO_NUMBER,\n    from_=VIBER_SENDER_ID,\n    image=ViberImageResource(url=MESSAGES_IMAGE_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Viber Send Text\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import ViberText\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = ViberText(\n    to=MESSAGES_TO_NUMBER,\n    from_=VIBER_SENDER_ID,\n    text=\"This is a Viber message sent via the Vonage Messages API.\",\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Viber Send Video\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import ViberVideo, ViberVideoOptions, ViberVideoResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = ViberVideo(\n    to=MESSAGES_TO_NUMBER,\n    from_=VIBER_SENDER_ID,\n    video=ViberVideoResource(url=MESSAGES_VIDEO_URL, thumb_url=MESSAGES_IMAGE_URL),\n    viber_service=ViberVideoOptions(\n        duration=MESSAGES_VIDEO_DURATION,\n        file_size=MESSAGES_VIDEO_FILE_SIZE,\n    ),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Webhook Server\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import FastAPI, Request, status\n\napp = FastAPI()\n\n\n@app.post('/webhooks/message-status', status_code=status.HTTP_200_OK)\nasync def message_status(request: Request):\n    data = await request.json()\n    pprint(data)\n\n\n@app.post('/webhooks/inbound-message')\nasync def inbound_message(request: Request):\n    data = await request.json()\n    pprint(data)\n```\n\n#### Whatsapp Mark As Read\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\nGEOSPECIFIC_MESSAGES_API_URL = os.environ.get(\"GEOSPECIFIC_MESSAGES_API_URL\")\nMESSAGES_MESSAGE_ID = os.environ.get(\"MESSAGES_MESSAGE_ID\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\n\nclient = Vonage(\n    auth=Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host=GEOSPECIFIC_MESSAGES_API_URL),\n)\n\nclient.messages.mark_whatsapp_message_read(\"MESSAGES_MESSAGE_ID\")\n```\n\n#### Whatsapp Send Audio\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\nMESSAGES_TO_NUMBER = os.environ.get(\"MESSAGES_TO_NUMBER\")\nWHATSAPP_SENDER_ID = os.environ.get(\"WHATSAPP_SENDER_ID\")\nMESSAGES_AUDIO_URL = os.environ.get(\"MESSAGES_AUDIO_URL\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\nfrom vonage_messages import WhatsappAudio, WhatsappAudioResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host='messages-sandbox.nexmo.com'),\n)\n\nmessage = WhatsappAudio(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    audio=WhatsappAudioResource(url=MESSAGES_AUDIO_URL, caption=\"Test audio file\"),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Authentication Template\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\ndotenv_path = join(dirname(__file__), \"../../.env\")\nload_dotenv(dotenv_path)\n\nVONAGE_APPLICATION_ID = os.environ.get(\"VONAGE_APPLICATION_ID\")\nVONAGE_PRIVATE_KEY = os.environ.get(\"VONAGE_PRIVATE_KEY\")\nMESSAGES_TO_NUMBER = os.environ.get(\"MESSAGES_TO_NUMBER\")\nWHATSAPP_SENDER_ID = os.environ.get(\"WHATSAPP_SENDER_ID\")\nWHATSAPP_TEMPLATE_NAME = os.environ.get(\"WHATSAPP_TEMPLATE_NAME\")\nWHATSAPP_OTP = os.environ.get(\"WHATSAPP_OTP\")\n\nfrom vonage import Auth, HttpClientOptions, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    ),\n    http_client_options=HttpClientOptions(api_host='messages-sandbox.nexmo.com'),\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"template\",\n        \"template\": {\n            \"name\": WHATSAPP_TEMPLATE_NAME,\n            \"language\": {\"policy\": \"deterministic\", \"code\": \"en\"},\n            \"components\": [\n                {\"type\": \"body\", \"parameters\": [{\"type\": \"text\", \"text\": \"'$OTP'\"}]},\n                {\n                    \"type\": \"button\",\n                    \"sub_type\": \"url\",\n                    \"index\": \"0\",\n                    \"parameters\": [{\"type\": \"text\", \"text\": WHATSAPP_OTP}],\n                },\n            ],\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Button Link\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"template\",\n        \"template\": {\n            \"name\": WHATSAPP_TEMPLATE_NAME,\n            \"language\": {\"policy\": \"deterministic\", \"code\": \"en\"},\n            \"components\": [\n                {\n                    \"type\": \"header\",\n                    \"parameters\": [\n                        {\n                            \"type\": \"image\",\n                            \"image\": {\n                                \"link\": MESSAGES_IMAGE_URL,\n                            },\n                        },\n                    ],\n                },\n                {\n                    \"type\": \"body\",\n                    \"parameters\": [\n                        {\"type\": \"text\", \"text\": \"Joe Bloggs\"},\n                        {\"type\": \"text\", \"text\": \"AB123456\"},\n                    ],\n                },\n                {\n                    \"type\": \"button\",\n                    \"index\": \"0\",\n                    \"sub_type\": \"url\",\n                    \"parameters\": [{\"type\": \"text\", \"text\": \"AB123456\"}],\n                },\n            ],\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Button Quick Reply\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"template\",\n        \"template\": {\n            \"name\": WHATSAPP_TEMPLATE_NAME,\n            \"language\": {\"policy\": \"deterministic\", \"code\": \"en\"},\n            \"components\": [\n                {\n                    \"type\": \"header\",\n                    \"parameters\": [\n                        {\n                            \"type\": \"image\",\n                            \"image\": {\n                                \"link\": MESSAGES_IMAGE_URL,\n                            },\n                        },\n                    ],\n                },\n                {\n                    \"type\": \"body\",\n                    \"parameters\": [\n                        {\n                            \"type\": \"text\",\n                            \"parameter_name\": \"customer_name\",\n                            \"text\": \"Joe Bloggs\",\n                        },\n                        {\n                            \"type\": \"text\",\n                            \"parameter_name\": \"dentist_name\",\n                            \"text\": \"Mr Smith\",\n                        },\n                        {\n                            \"type\": \"text\",\n                            \"parameter_name\": \"appointment_date\",\n                            \"text\": \"2025-02-26\",\n                        },\n                        {\n                            \"type\": \"text\",\n                            \"parameter_name\": \"appointment_location\",\n                            \"text\": \"ACME Dental Practice\",\n                        },\n                    ],\n                },\n                {\n                    \"type\": \"button\",\n                    \"sub_type\": \"quick_reply\",\n                    \"index\": 0,\n                    \"parameters\": [{\"type\": \"payload\", \"payload\": \"Yes-Button-Payload\"}],\n                },\n                {\n                    \"type\": \"button\",\n                    \"sub_type\": \"quick_reply\",\n                    \"index\": 1,\n                    \"parameters\": [{\"type\": \"payload\", \"payload\": \"No-Button-Payload\"}],\n                },\n            ],\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Contact\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"contacts\",\n        \"contacts\": [\n            {\n                \"addresses\": [\n                    {\n                        \"city\": \"Menlo Park\",\n                        \"country\": \"United States\",\n                        \"country_code\": \"us\",\n                        \"state\": \"CA\",\n                        \"street\": \"1 Hacker Way\",\n                        \"type\": \"HOME\",\n                        \"zip\": \"94025\",\n                    },\n                    {\n                        \"city\": \"Menlo Park\",\n                        \"country\": \"United States\",\n                        \"country_code\": \"us\",\n                        \"state\": \"CA\",\n                        \"street\": \"200 Jefferson Dr\",\n                        \"type\": \"WORK\",\n                        \"zip\": \"94025\",\n                    },\n                ],\n                \"birthday\": \"2012-08-18\",\n                \"emails\": [\n                    {\"email\": \"test@fb.com\", \"type\": \"WORK\"},\n                    {\"email\": \"test@whatsapp.com\", \"type\": \"WORK\"},\n                ],\n                \"name\": {\n                    \"first_name\": \"John\",\n                    \"formatted_name\": \"John Smith\",\n                    \"last_name\": \"Smith\",\n                },\n                \"org\": {\n                    \"company\": \"WhatsApp\",\n                    \"department\": \"Design\",\n                    \"title\": \"Manager\",\n                },\n                \"phones\": [\n                    {\"phone\": \"+1 (940) 555-1234\", \"type\": \"HOME\"},\n                    {\n                        \"phone\": \"+1 (650) 555-1234\",\n                        \"type\": \"WORK\",\n                        \"wa_id\": \"16505551234\",\n                    },\n                ],\n                \"urls\": [{\"url\": \"https://www.facebook.com\", \"type\": \"WORK\"}],\n            }\n        ],\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send File\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappFile, WhatsappFileResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappFile(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    file=WhatsappFileResource(url=MESSAGES_FILE_URL, caption=\"Test file\"),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Image\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappImage, WhatsappImageResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappImage(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    image=WhatsappImageResource(url=MESSAGES_IMAGE_URL, caption=\"Test image\"),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Location\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"location\",\n        \"location\": {\n            \"longitude\": -122.425332,\n            \"latitude\": 37.758056,\n            \"name\": \"Facebook HQ\",\n            \"address\": \"1 Hacker Way, Menlo Park, CA 94025\",\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Media Template\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        \"type\": \"template\",\n        \"template\": {\n            \"name\": WHATSAPP_TEMPLATE_NAME,\n            \"language\": {\"policy\": \"deterministic\", \"code\": \"en\"},\n            \"components\": [\n                {\n                    \"type\": \"header\",\n                    \"parameters\": [\n                        {\n                            \"type\": \"image\",\n                            \"image\": {\n                                \"link\": MESSAGES_IMAGE_URL,\n                            },\n                        },\n                    ],\n                },\n                {\n                    \"type\": \"body\",\n                    \"parameters\": [\n                        {\"type\": \"text\", \"text\": \"Joe Bloggs\"},\n                        {\"type\": \"text\", \"text\": \"AB123456\"},\n                    ],\n                },\n            ],\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Product Message Multiple Item\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        'type': 'interactive',\n        'interactive': {\n            'type': 'product_list',\n            'header': {'type': 'text', 'text': 'Our top products'},\n            'body': {'text': 'Check out these great products'},\n            'footer': {'text': 'Sale now on!'},\n            'action': {\n                'catalog_id': WHATSAPP_CATALOG_ID,\n                'sections': [\n                    {\n                        'title': 'Cool products',\n                        'product_items': [\n                            {'WHATSAPP_PRODUCT_ID_1': WHATSAPP_PRODUCT_ID_1},\n                            {'WHATSAPP_PRODUCT_ID_2': WHATSAPP_PRODUCT_ID_2},\n                        ],\n                    },\n                    {\n                        'title': 'Awesome products',\n                        'product_items': [\n                            {'WHATSAPP_PRODUCT_ID_1': WHATSAPP_PRODUCT_ID_1}\n                        ],\n                    },\n                ],\n            },\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Product Message Single Item\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappCustom\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappCustom(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    custom={\n        'type': 'interactive',\n        'interactive': {\n            'type': 'product',\n            'body': {'text' 'Check out this cool product'},\n            'footer': {'text': 'Sale now on!'},\n            'action': {\n                'catalog_id': WHATSAPP_CATALOG_ID,\n                'product_retailer_id': WHATSAPP_PRODUCT_ID_1,\n            },\n        },\n    },\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Sticker By Id\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappSticker, WhatsappStickerId\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappSticker(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    sticker=WhatsappStickerId(id=WHATSAPP_STICKER_ID),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Sticker By Url\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappSticker, WhatsappStickerUrl\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappSticker(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    sticker=WhatsappStickerUrl(url=WHATSAPP_STICKER_URL),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Template\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import (WhatsappTemplate, WhatsappTemplateResource,\n                             WhatsappTemplateSettings)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappTemplate(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    template=WhatsappTemplateResource(\n        name=WHATSAPP_TEMPLATE_NAME,\n        parameters=[\"Vonage Verification\", \"64873\", \"10\"],\n    ),\n    whatsapp=WhatsappTemplateSettings(\n        locale=\"en-GB\",\n        policy=\"deterministic\",\n    ),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Text\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappText\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappText(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    text='Hello from the Vonage Messages API.',\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n#### Whatsapp Send Video\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_messages import WhatsappVideo, WhatsappVideoResource\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nmessage = WhatsappVideo(\n    to=MESSAGES_TO_NUMBER,\n    from_=WHATSAPP_SENDER_ID,\n    video=WhatsappVideoResource(url=MESSAGES_VIDEO_URL, caption=\"Test video file\"),\n)\n\nresponse = client.messages.send(message)\nprint(response)\n```\n\n### Number Insight\n\n#### Snippets in this Section\n\n- [Async Callback](#async-callback)\n- [Ni Advanced](#ni-advanced)\n- [Ni Advanced Async Trigger](#ni-advanced-async-trigger)\n- [Ni Basic](#ni-basic)\n- [Ni Standard](#ni-standard)\n\n#### Async Callback\n\n```python\nfrom fastapi import FastAPI, Request\n\napp = FastAPI()\n\n\n@app.post('/webhooks/insight')\nasync def display_advanced_number_insight_info(request: Request):\n    data = await request.json()\n    print(data)\n```\n\n#### Ni Advanced\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_number_insight import (AdvancedSyncInsightRequest,\n                                   AdvancedSyncInsightResponse)\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\ninsight: AdvancedSyncInsightResponse = client.number_insight.get_advanced_info_sync(\n    AdvancedSyncInsightRequest(number=INSIGHT_NUMBER)\n)\npprint(insight)\n```\n\n#### Ni Advanced Async Trigger\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_number_insight import (AdvancedAsyncInsightRequest,\n                                   AdvancedAsyncInsightResponse)\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\ninsight: AdvancedAsyncInsightResponse = client.number_insight.get_advanced_info_async(\n    AdvancedAsyncInsightRequest(number=INSIGHT_NUMBER, callback=INSIGHT_CALLBACK_URL)\n)\npprint(insight)\n```\n\n#### Ni Basic\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_number_insight import BasicInsightRequest, BasicInsightResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\ninsight: BasicInsightResponse = client.number_insight.get_basic_info(\n    BasicInsightRequest(number=INSIGHT_NUMBER)\n)\npprint(insight)\n```\n\n#### Ni Standard\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_number_insight import (StandardInsightRequest,\n                                   StandardInsightResponse)\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\ninsight: StandardInsightResponse = client.number_insight.get_standard_info(\n    StandardInsightRequest(number=INSIGHT_NUMBER)\n)\npprint(insight)\n```\n\n### Numbers\n\n#### Snippets in this Section\n\n- [Buy](#buy)\n- [Cancel](#cancel)\n- [List](#list)\n- [Search](#search)\n- [Update](#update)\n\n#### Buy\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_numbers import NumberParams, NumbersStatus\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nstatus: NumbersStatus = client.numbers.buy_number(\n    params=NumberParams(\n        country=NUMBER_COUNTRY_CODE,\n        msisdn=NUMBER_MSISDN,\n    )\n)\n\nprint(status.model_dump())\n```\n\n#### Cancel\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_numbers import NumberParams, NumbersStatus\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nstatus: NumbersStatus = client.numbers.cancel_number(\n    NumberParams(country=NUMBER_COUNTRY_CODE, msisdn=NUMBER_MSISDN)\n)\n\nprint(status.model_dump())\n```\n\n#### List\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_numbers import ListOwnedNumbersFilter\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nnumbers, count, next = client.numbers.list_owned_numbers(\n    ListOwnedNumbersFilter(\n        pattern=NUMBER_SEARCH_CRITERIA, search_pattern=NUMBER_SEARCH_PATTERN\n    )\n)\n\npprint(numbers)\nprint(count)\nprint(next)\n```\n\n#### Search\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_numbers import SearchAvailableNumbersFilter\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nnumbers, count, next = client.numbers.search_available_numbers(\n    SearchAvailableNumbersFilter(\n        country=NUMBER_COUNTRY_CODE,\n        size=3,\n        pattern=NUMBER_SEARCH_CRITERIA,\n        search_pattern=NUMBER_SEARCH_PATTERN,\n        type=NUMBER_TYPE,\n        features=NUMBER_FEATURES,\n    )\n)\npprint(numbers)\nprint(count)\nprint(next)\n\nfor number in numbers:\n    print(f'Tel: {number.msisdn} Cost: {number.cost}')\n```\n\n#### Update\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_numbers import NumbersStatus, UpdateNumberParams\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nstatus: NumbersStatus = client.numbers.update_number(\n    UpdateNumberParams(\n        country=NUMBER_COUNTRY_CODE,\n        msisdn=NUMBER_MSISDN,\n        app_id='vonage-application-id',\n        mo_http_url=NUMBER_SMS_CALLBACK_URL,\n        mo_smpp_sytem_type='inbound',\n        voice_callback_value=NUMBER_VOICE_CALLBACK_URL,\n        voice_status_callback=NUMBER_VOICE_STATUS_CALLBACK_URL,\n    )\n)\n\nprint(status.model_dump())\n```\n\n### Sms\n\n#### Snippets in this Section\n\n- [Delivery Receipts](#delivery-receipts)\n- [Receive Sms](#receive-sms)\n- [Send An Sms](#send-an-sms)\n- [Send An Sms With Unicode](#send-an-sms-with-unicode)\n- [Send Signed Sms](#send-signed-sms)\n- [Submit Sms Conversion](#submit-sms-conversion)\n- [Verify Signed Sms](#verify-signed-sms)\n\n#### Delivery Receipts\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import FastAPI, Request\n\napp = FastAPI()\n\n\n@app.post('/webhooks/delivery-receipt')\nasync def get_delivery_receipt(request: Request):\n    data = await request.json()\n    pprint(data)\n```\n\n#### Receive Sms\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import FastAPI, Request\n\napp = FastAPI()\n\n\n@app.post('/webhooks/inbound')\nasync def inbound_message(request: Request):\n    data = await request.json()\n    pprint(data)\n```\n\n#### Send An Sms\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_sms import SmsMessage, SmsResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nmessage = SmsMessage(\n    to=SMS_TO_NUMBER,\n    from_=SMS_SENDER_ID,\n    text=\"A text message sent using the Vonage SMS API.\",\n)\n\nresponse: SmsResponse = client.sms.send(message)\nprint(response)\n```\n\n#### Send An Sms With Unicode\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_sms import SmsMessage, SmsResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nmessage = SmsMessage(\n    to=SMS_TO_NUMBER,\n    from_=SMS_SENDER_ID,\n    text='こんにちは世界',\n    type='unicode',\n)\n\nresponse: SmsResponse = client.sms.send(message)\nprint(response)\n```\n\n#### Send Signed Sms\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_sms import SmsMessage, SmsResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, signature_secret=SMS_SIGNATURE))\n\nmessage = SmsMessage(\n    to=SMS_TO_NUMBER,\n    from_=SMS_SENDER_ID,\n    text=\"A text message sent using the Vonage SMS API.\",\n)\n\nresponse: SmsResponse = client.sms.send(message)\nprint(response)\n```\n\n#### Submit Sms Conversion\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nclient.sms.submit_sms_conversion(\n    message_id='MESSAGE_ID',\n    delivered=True,\n    timestamp='2020-01-01T12:00:00Z',\n)\n\nif client.http_client.last_response.status_code == 200:\n    print('Conversion submitted successfully.')\nelse:\n    print('Conversion not submitted.')\n```\n\n#### Verify Signed Sms\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\n\nenvpath = join(dirname(__file__), '../.env')\nload_dotenv(envpath)\n\nVONAGE_API_KEY = os.getenv(\"VONAGE_API_KEY\")\nVONAGE_SIGNATURE_SECRET = os.getenv(\"VONAGE_SIGNATURE_SECRET\")\n\nfrom fastapi import FastAPI, Request\nfrom vonage import Auth, Vonage\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, signature_secret=VONAGE_SIGNATURE_SECRET))\n\napp = FastAPI()\n\n\n@app.post('/')\nasync def verify_signed_webhook(request: Request):\n    data = await request.json()\n\n    if client.http_client.auth.check_signature(data):\n        print('Valid signature')\n    else:\n        print('Invalid signature')\n```\n\n### Subaccounts\n\n#### Snippets in this Section\n\n- [Create Subaccount](#create-subaccount)\n- [Get Subaccount](#get-subaccount)\n- [List Balance Transfers](#list-balance-transfers)\n- [List Credit Transfers](#list-credit-transfers)\n- [List Subaccounts](#list-subaccounts)\n- [Reactivate Subaccount](#reactivate-subaccount)\n- [Suspend Subaccount](#suspend-subaccount)\n- [Transfer Balance](#transfer-balance)\n- [Transfer Credit](#transfer-credit)\n- [Transfer Number](#transfer-number)\n\n#### Create Subaccount\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import NewSubaccount, SubaccountOptions\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: NewSubaccount = client.subaccounts.create_subaccount(\n    SubaccountOptions(name=SUBACCOUNT_NAME, secret=SUBACCOUNT_SECRET)\n)\n\nprint(response)\n```\n\n#### Get Subaccount\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import Subaccount\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nsubaccount: Subaccount = client.subaccounts.get_subaccount(SUBACCOUNT_KEY)\n\nprint(subaccount)\n```\n\n#### List Balance Transfers\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import ListTransfersFilter, Transfer\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: list[Transfer] = client.subaccounts.list_balance_transfers(\n    ListTransfersFilter(start_date=SUBACCOUNT_START_DATE)\n)\n\nprint(response)\n```\n\n#### List Credit Transfers\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import ListTransfersFilter, Transfer\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: list[Transfer] = client.subaccounts.list_credit_transfers(\n    ListTransfersFilter(start_date=SUBACCOUNT_START_DATE)\n)\n\nprint(response)\n```\n\n#### List Subaccounts\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import ListSubaccountsResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: ListSubaccountsResponse = client.subaccounts.list_subaccounts()\n\nprint(response)\n```\n\n#### Reactivate Subaccount\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import ModifySubaccountOptions, Subaccount\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: Subaccount = client.subaccounts.modify_subaccount(\n    subaccount_api_key=SUBACCOUNT_KEY,\n    options=ModifySubaccountOptions(suspended=False),\n)\n\nprint(response)\n```\n\n#### Suspend Subaccount\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import ModifySubaccountOptions, Subaccount\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: Subaccount = client.subaccounts.modify_subaccount(\n    subaccount_api_key=SUBACCOUNT_KEY,\n    options=ModifySubaccountOptions(suspended=True),\n)\n\nprint(response)\n```\n\n#### Transfer Balance\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import Transfer, TransferRequest\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = TransferRequest(\n    from_=VONAGE_API_KEY, to=SUBACCOUNT_KEY, amount=SUBACCOUNT_BALANCE_AMOUNT\n)\n\ntransfer: Transfer = client.subaccounts.transfer_balance(request)\n\nprint(transfer)\n```\n\n#### Transfer Credit\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import Transfer, TransferRequest\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = TransferRequest(\n    from_=VONAGE_API_KEY, to=SUBACCOUNT_KEY, amount=SUBACCOUNT_CREDIT_AMOUNT\n)\n\nresponse: Transfer = client.subaccounts.transfer_credit(request)\n\nprint(response)\n```\n\n#### Transfer Number\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_subaccounts import TransferNumberRequest, TransferNumberResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = TransferNumberRequest(\n    from_=VONAGE_API_KEY, to=SUBACCOUNT_KEY, number=VONAGE_VIRTUAL_NUMBER\n)\n\nresponse: TransferNumberResponse = client.subaccounts.transfer_number(request)\n\nprint(response)\n```\n\n### Users\n\n#### Snippets in this Section\n\n- [Create User](#create-user)\n- [Delete User](#delete-user)\n- [Get User](#get-user)\n- [List Users](#list-users)\n- [Update User](#update-user)\n\n#### Create User\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_users import Channels, PstnChannel, User\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nuser_options = User(\n    name=USER_NAME,\n    display_name=USER_DISPLAY_NAME,\n    channels=Channels(pstn=[PstnChannel(number=123456)]),\n)\nuser = client.users.create_user(user_options)\n\nprint(user)\n```\n\n#### Delete User\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\nclient.users.delete_user(USER_ID)\n```\n\n#### Get User\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_users import User\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\nuser: User = client.users.get_user(USER_ID)\n\nprint(user)\n```\n\n#### List Users\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nusers_list, next_page_cursor = client.users.list_users()\n\nprint(users_list)\n```\n\n#### Update User\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_users import Channels, PstnChannel, SmsChannel, User\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nuser_params = User(\n    name=USER_NAME,\n    display_name=USER_DISPLAY_NAME,\n    channels=Channels(\n        sms=[SmsChannel(number='1234567890')], pstn=[PstnChannel(number=123456)]\n    ),\n)\nuser: User = client.users.update_user(id=USER_ID, params=user_params)\n\nprint(user)\n```\n\n### Verify\n\n#### Snippets in this Section\n\n- [Cancel Request](#cancel-request)\n- [Check Verification Code](#check-verification-code)\n- [Send Request Email](#send-request-email)\n- [Send Request Silent Auth](#send-request-silent-auth)\n- [Send Request Sms](#send-request-sms)\n- [Send Request Voice](#send-request-voice)\n- [Send Request Whatsapp](#send-request-whatsapp)\n- [Send Request Whatsapp Interactive](#send-request-whatsapp-interactive)\n- [Send Request With Fallback](#send-request-with-fallback)\n\n#### Cancel Request\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nclient.verify.cancel_verification(request_id=VERIFY_REQUEST_ID)\n```\n\n#### Check Verification Code\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import CheckCodeResponse\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse: CheckCodeResponse = client.verify.check_code(\n    request_id=VERIFY_REQUEST_ID, code=VERIFY_CODE\n)\nprint(response)\n```\n\n#### Send Request Email\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (EmailChannel, StartVerificationResponse,\n                           VerifyRequest)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_VERIFY_BRAND_NAME,\n    workflow=[\n        EmailChannel(to=VERIFY_TO_EMAIL),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request Silent Auth\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (SilentAuthChannel, StartVerificationResponse,\n                           VerifyRequest)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[SilentAuthChannel(to=VERIFY_NUMBER)],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request Sms\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import SmsChannel, StartVerificationResponse, VerifyRequest\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[\n        SmsChannel(to=VERIFY_NUMBER),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request Voice\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (StartVerificationResponse, VerifyRequest,\n                           VoiceChannel)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[\n        VoiceChannel(to=VERIFY_NUMBER),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request Whatsapp\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (StartVerificationResponse, VerifyRequest,\n                           WhatsappChannel)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[\n        WhatsappChannel(to=VERIFY_NUMBER, from_=VERIFY_FROM_NUMBER),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request Whatsapp Interactive\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (StartVerificationResponse, VerifyRequest,\n                           WhatsappChannel)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[\n        WhatsappChannel(to=VERIFY_NUMBER, from_=VERIFY_FROM_NUMBER),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n#### Send Request With Fallback\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify import (EmailChannel, SilentAuthChannel,\n                           StartVerificationResponse, VerifyRequest)\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nverify_request = VerifyRequest(\n    brand=VERIFY_BRAND_NAME,\n    workflow=[\n        SilentAuthChannel(to=VERIFY_NUMBER),\n        EmailChannel(to=VERIFY_TO_EMAIL, from_=VERIFY_FROM_EMAIL),\n    ],\n)\n\nresponse: StartVerificationResponse = client.verify.start_verification(verify_request)\npprint(response)\n```\n\n### Verify_Legacy\n\n#### Snippets in this Section\n\n- [Cancel](#cancel)\n- [Check](#check)\n- [Psd2 Request](#psd2-request)\n- [Request](#request)\n- [Search](#search)\n- [Send Psd2 Verification Request With Workflow](#send-psd2-verification-request-with-workflow)\n- [Send Verification Request With Workflow](#send-verification-request-with-workflow)\n- [Trigger Next Step](#trigger-next-step)\n\n#### Cancel\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nclient.verify_legacy.cancel_verification(VERIFY_REQUEST_ID)\n```\n\n#### Check\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import CheckCodeResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: CheckCodeResponse = client.verify_legacy.check_code(\n    VERIFY_REQUEST_ID, VERIFY_CODE\n)\nprint(response)\n```\n\n#### Psd2 Request\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import Psd2Request, StartVerificationResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = Psd2Request(number=VERIFY_NUMBER, payee=VERIFY_PAYEE_NAME, amount=VERIFY_AMOUNT)\n\nresponse: StartVerificationResponse = client.verify_legacy.start_psd2_verification(\n    request\n)\nprint(response)\n```\n\n#### Request\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import StartVerificationResponse, VerifyRequest\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = VerifyRequest(number=VERIFY_NUMBER, brand='AcmeInc')\n\nresponse: StartVerificationResponse = client.verify_legacy.start_verification(request)\nprint(response)\n```\n\n#### Search\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import VerifyStatus\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: VerifyStatus = client.verify_legacy.search(VERIFY_REQUEST_ID)\nprint(response)\n```\n\n#### Send Psd2 Verification Request With Workflow\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import Psd2Request, StartVerificationResponse\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = Psd2Request(\n    number=VERIFY_NUMBER,\n    payee=VERIFY_PAYEE_NAME,\n    amount=VERIFY_AMOUNT,\n    workflow_id=VERIFY_WORKFLOW_ID,\n)\n\nresponse: StartVerificationResponse = client.verify_legacy.start_psd2_verification(\n    request\n)\nprint(response)\n```\n\n#### Send Verification Request With Workflow\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import StartVerificationResponse, VerifyRequest\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nrequest = VerifyRequest(\n    number=VERIFY_NUMBER, brand='AcmeInc', workflow_id=VERIFY_WORKFLOW_ID\n)\n\nresponse: StartVerificationResponse = client.verify_legacy.start_verification(request)\nprint(response)\n```\n\n#### Trigger Next Step\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_verify_legacy import VerifyControlStatus\n\nclient = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))\n\nresponse: VerifyControlStatus = client.verify_legacy.trigger_next_event(VERIFY_REQUEST_ID)\nprint(response)\n```\n\n### Voice\n\n#### Snippets in this Section\n\n- [Connect An Inbound Call](#connect-an-inbound-call)\n- [Connect Callers To A Conference](#connect-callers-to-a-conference)\n- [Earmuff A Call](#earmuff-a-call)\n- [Get Recording](#get-recording)\n- [Handle User Input](#handle-user-input)\n- [Handle User Input With Asr](#handle-user-input-with-asr)\n- [Make An Outbound Call](#make-an-outbound-call)\n- [Make Outbound Call Ncco](#make-outbound-call-ncco)\n- [Mute A Call](#mute-a-call)\n- [Play Audio Stream Into Call](#play-audio-stream-into-call)\n- [Play Dtmf Into Call](#play-dtmf-into-call)\n- [Play Tts Into Call](#play-tts-into-call)\n- [Receive An Inbound Call](#receive-an-inbound-call)\n- [Record A Call](#record-a-call)\n- [Record A Call With Split Audio](#record-a-call-with-split-audio)\n- [Record A Conversation](#record-a-conversation)\n- [Record A Message](#record-a-message)\n- [Retrieve Info For A Call](#retrieve-info-for-a-call)\n- [Retrieve Info For All Calls](#retrieve-info-for-all-calls)\n- [Track Ncco](#track-ncco)\n- [Transfer A Call](#transfer-a-call)\n- [Transfer Call Inline Ncco](#transfer-call-inline-ncco)\n\n#### Connect An Inbound Call\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\nfrom fastapi import FastAPI\nfrom vonage_voice import Connect, PhoneEndpoint\n\ndotenv_path = join(dirname(__file__), '../.env')\nload_dotenv(dotenv_path)\n\nVONAGE_VIRTUAL_NUMBER = os.environ.get('VONAGE_VIRTUAL_NUMBER')\nVOICE_VOICE_TO_NUMBER = os.environ.get('VOICE_VOICE_TO_NUMBER')\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def inbound_call():\n    ncco = [\n        Connect(\n            endpoint=[PhoneEndpoint(number=VOICE_VOICE_TO_NUMBER)],\n            from_=VONAGE_VIRTUAL_NUMBER,\n        ).model_dump(by_alias=True, exclude_none=True)\n    ]\n\n    return ncco\n```\n\n#### Connect Callers To A Conference\n\n```python\nimport os\nfrom os.path import dirname, join\n\nfrom dotenv import load_dotenv\nfrom fastapi import FastAPI\nfrom vonage_voice import Conversation, NccoAction, Talk\n\ndotenv_path = join(dirname(__file__), '../.env')\nload_dotenv(dotenv_path)\n\nVOICE_CONFERENCE_NAME = os.environ.get(\"VOICE_CONFERENCE_NAME\")\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call():\n    ncco: list[NccoAction] = [\n        Talk(text=\"Please wait while we connect you to the conference\"),\n        Conversation(name=VOICE_CONFERENCE_NAME),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n```\n\n#### Earmuff A Call\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nclient.voice.earmuff(VOICE_CALL_ID)\nsleep(3)\nclient.voice.unearmuff(VOICE_CALL_ID)\n```\n\n#### Get Recording\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nclient.voice.download_recording(VOICE_RECORDING_URL, 'recording.mp3')\n```\n\n#### Handle User Input\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import Body, FastAPI, Request\nfrom vonage_voice import Dtmf, Input, NccoAction, Talk\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call(request: Request):\n    ncco: list[NccoAction] = [\n        Talk(text=f'Hello, please press any key to continue.'),\n        Input(\n            type=['dtmf'],\n            dtmf=Dtmf(timeOut=5, maxDigits=1),\n            eventUrl=[str(request.base_url) + 'webhooks/dtmf'],\n        ),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n\n\n@app.post('/webhooks/dtmf')\nasync def answer_dtmf(data: dict = Body(...)):\n    pprint(data)\n    return [\n        Talk(text=f'Hello, you pressed {data['dtmf']['digits']}').model_dump(\n            by_alias=True, exclude_none=True\n        )\n    ]\n```\n\n#### Handle User Input With Asr\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import Body, FastAPI, Request\nfrom vonage_voice import Input, NccoAction, Speech, Talk\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call(request: Request):\n    ncco: list[NccoAction] = [\n        Talk(text=f'Please say something'),\n        Input(\n            type=['speech'],\n            speech=Speech(endOnSilence=1, language='en-US'),\n            eventUrl=[str(request.base_url) + 'webhooks/asr'],\n        ),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n\n\n@app.post('/webhooks/asr')\nasync def answer_asr(data: dict = Body(...)):\n    if data is not None and 'speech' in data:\n        pprint(data)\n        speech = data['speech']['results'][0]['text']\n        return [\n            Talk(text=f'Hello, you said {speech}').model_dump(\n                by_alias=True, exclude_none=True\n            )\n        ]\n    return [\n        Talk(text=f'Sorry, I didn\\'t understand your input.').model_dump(\n            by_alias=True, exclude_none=True\n        )\n    ]\n```\n\n#### Make An Outbound Call\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import CreateCallRequest, Phone, ToPhone\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse = client.voice.create_call(\n    CreateCallRequest(\n        answer_url=[VOICE_ANSWER_URL],\n        to=[ToPhone(number=VOICE_TO_NUMBER)],\n        from_=Phone(number=VONAGE_VIRTUAL_NUMBER),\n    )\n)\n\npprint(response)\n```\n\n#### Make Outbound Call Ncco\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import CreateCallRequest, Phone, Talk, ToPhone\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse = client.voice.create_call(\n    CreateCallRequest(\n        ncco=[Talk(text='This is a text to speech call from Vonage.')],\n        to=[ToPhone(number=VOICE_TO_NUMBER)],\n        from_=Phone(number=VONAGE_VIRTUAL_NUMBER),\n    )\n)\n\npprint(response)\n```\n\n#### Mute A Call\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nclient.voice.mute(VOICE_CALL_ID)\nsleep(5)\nclient.voice.unmute(VOICE_CALL_ID)\n```\n\n#### Play Audio Stream Into Call\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import AudioStreamOptions, CallMessage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse: CallMessage = client.voice.play_audio_into_call(\n    VOICE_CALL_ID,\n    audio_stream_options=AudioStreamOptions(stream_url=[VOICE_STREAM_URL]),\n)\n\npprint(response)\n```\n\n#### Play Dtmf Into Call\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import CallMessage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse: CallMessage = client.voice.play_dtmf_into_call(\n    uuid=VOICE_CALL_ID, dtmf=VOICE_DTMF_DIGITS\n)\n\npprint(response)\n```\n\n#### Play Tts Into Call\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import CallMessage, TtsStreamOptions\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse: CallMessage = client.voice.play_tts_into_call(\n    uuid=VOICE_CALL_ID,\n    tts_options=TtsStreamOptions(text=VOICE_TEXT, language=VOICE_LANGUAGE),\n)\n\npprint(response)\n```\n\n#### Receive An Inbound Call\n\n```python\nfrom fastapi import FastAPI, Query\nfrom vonage_voice import Talk\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call(from_: str = Query(..., alias='from')):\n    from_ = '-'.join(from_)\n    return [\n        Talk(text=f'Thank you for calling from {from_}').model_dump(\n            by_alias=True, exclude_none=True\n        )\n    ]\n```\n\n#### Record A Call\n\n```python\nimport os\nfrom os.path import dirname, join\nfrom pprint import pprint\n\nfrom dotenv import load_dotenv\nfrom fastapi import Body, FastAPI\nfrom vonage_voice import Connect, NccoAction, PhoneEndpoint, Record\n\ndotenv_path = join(dirname(__file__), '../.env')\nload_dotenv(dotenv_path)\n\nVONAGE_VIRTUAL_NUMBER = os.environ.get('VONAGE_VIRTUAL_NUMBER')\nVOICE_TO_NUMBER = os.environ.get('VOICE_TO_NUMBER')\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def inbound_call():\n    ncco: list[NccoAction] = [\n        Record(eventUrl=['https://demo.ngrok.io/webhooks/recordings']),\n        Connect(\n            from_=VONAGE_VIRTUAL_NUMBER, endpoint=[PhoneEndpoint(number=VOICE_TO_NUMBER)]\n        ),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n\n\n@app.post('/webhooks/recordings')\nasync def recordings(data: dict = Body(...)):\n    pprint(data)\n    return {'message': 'webhook received'}\n```\n\n#### Record A Call With Split Audio\n\n```python\nimport os\nfrom os.path import dirname, join\nfrom pprint import pprint\n\nfrom dotenv import load_dotenv\nfrom fastapi import Body, FastAPI\nfrom vonage_voice import Connect, NccoAction, PhoneEndpoint, Record\n\ndotenv_path = join(dirname(__file__), '../.env')\nload_dotenv(dotenv_path)\n\nVONAGE_VIRTUAL_NUMBER = os.environ.get('VONAGE_VIRTUAL_NUMBER')\nVOICE_TO_NUMBER = os.environ.get('VOICE_TO_NUMBER')\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def inbound_call():\n    ncco: list[NccoAction] = [\n        Record(\n            split='conversation',\n            channels=2,\n            eventUrl=['https://demo.ngrok.io/webhooks/recordings'],\n        ),\n        Connect(\n            from_=VONAGE_VIRTUAL_NUMBER, endpoint=[PhoneEndpoint(number=VOICE_TO_NUMBER)]\n        ),\n    ]\n\n    return [step.model_dump(by_alias=True, exclude_none=True) for step in ncco]\n\n\n@app.post('/webhooks/recordings')\nasync def recordings(data: dict = Body(...)):\n    pprint(data)\n    return {'message': 'webhook received'}\n```\n\n#### Record A Conversation\n\n```python\nimport os\nfrom os.path import dirname, join\nfrom pprint import pprint\n\nfrom dotenv import load_dotenv\nfrom fastapi import Body, FastAPI\nfrom vonage_voice import Conversation\n\ndotenv_path = join(dirname(__file__), '../.env')\nload_dotenv(dotenv_path)\n\nVOICE_CONFERENCE_NAME = os.environ.get('VOICE_CONFERENCE_NAME')\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call():\n    ncco = [\n        Conversation(\n            name=VOICE_CONFERENCE_NAME,\n            record=True,\n            eventMethod='POST',\n            eventUrl=['https://demo.ngrok.io/webhooks/recordings'],\n        )\n    ]\n\n    return ncco\n\n\n@app.post('/webhooks/recordings')\nasync def recordings(data: dict = Body(...)):\n    pprint(data)\n    return {'message': 'webhook received'}\n```\n\n#### Record A Message\n\n```python\nfrom pprint import pprint\n\nfrom fastapi import Body, FastAPI, Request\nfrom vonage_voice import NccoAction, Record, Talk\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def answer_call(request: Request):\n    print(request.base_url)\n    ncco: list[NccoAction] = [\n        Talk(\n            text='Please leave a message after the tone, then press #. We will get back to you as soon as we can.'\n        ),\n        Record(\n            endOnSilence=3,\n            endOnKey='#',\n            beepStart=True,\n            eventUrl=[str(request.base_url) + 'webhooks/recordings'],\n        ),\n        Talk(text='Thank you for your message. Goodbye.'),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n\n\n@app.post('/webhooks/recordings')\nasync def recordings(data: dict = Body(...)):\n    pprint(data)\n    return {'message': 'webhook received'}\n```\n\n#### Retrieve Info For A Call\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import CallInfo\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nresponse: CallInfo = client.voice.get_call(VOICE_CALL_ID)\npprint(response)\n```\n\n#### Retrieve Info For All Calls\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import ListCallsFilter\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nnow = datetime.now(timezone.utc)\ndate_end = now.strftime('%Y-%m-%dT%H:%M:%SZ')\nstart = now - timedelta(hours=24)\ndate_start = start.strftime('%Y-%m-%dT%H:%M:%SZ')\n\ncalls, _ = client.voice.list_calls(\n    ListCallsFilter(date_start=date_start, date_end=date_end)\n)\n\nfor call in calls:\n    pprint(call)\n```\n\n#### Track Ncco\n\n```python\nfrom fastapi import FastAPI, Request\nfrom vonage_voice import NccoAction, Notify, Talk\n\napp = FastAPI()\n\n\n@app.get('/webhooks/answer')\nasync def inbound_call(request: Request):\n    ncco: list[NccoAction] = [\n        Talk(text=f'Thanks for calling the notification line.'),\n        Notify(\n            payload={\"foo\": \"bar\"},\n            eventUrl=[str(request.base_url) + 'webhooks/notification'],\n        ),\n        Talk(text=f'You will never hear me as the notification URL will return an NCCO.'),\n    ]\n\n    return [action.model_dump(by_alias=True, exclude_none=True) for action in ncco]\n\n\n@app.post('/webhooks/notification')\nasync def on_notification():\n    return [\n        Talk(text=f'Your notification has been received, loud and clear').model_dump(\n            by_alias=True, exclude_none=True\n        )\n    ]\n```\n\n#### Transfer A Call\n\n```python\nfrom vonage import Auth, Vonage\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nclient.voice.transfer_call_answer_url(VOICE_CALL_ID, VOICE_NCCO_URL)\n```\n\n#### Transfer Call Inline Ncco\n\n```python\nfrom vonage import Auth, Vonage\nfrom vonage_voice import Talk\n\nclient = Vonage(\n    Auth(\n        application_id=VONAGE_APPLICATION_ID,\n        private_key=VONAGE_PRIVATE_KEY,\n    )\n)\n\nncco = [Talk(text='This is a transfer action using an inline NCCO')]\n\nclient.voice.transfer_call_ncco(VOICE_CALL_ID, ncco)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvonage%2Fvonage-python-code-snippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvonage%2Fvonage-python-code-snippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvonage%2Fvonage-python-code-snippets/lists"}