{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/voice-2.0/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["partial"]},"product":"Voice v2 (preview)","type":"markdown"},"seo":{"title":"Python SDK Reference | Voice v2 API | Sinch","siteUrl":"https://developers.sinch.com","llmstxt":{"title":"Sinch Developer Documentation","description":"LLMs.txt containing a map of all the documentation files for Sinch.","sections":[{"title":"Numbers API","description":"The Numbers API enables you to search for, view, and activate numbers. It's considered a precursor to other APIs in the Sinch product family. The numbers API can be used in tandem with any of our APIs that perform messaging or calling.","includeFiles":["docs/numbers/**/*.md","docs/numbers/**/*.yaml"],"excludeFiles":["docs/numbers/index.md"]},{"title":"Conversation API","description":"Send and receive messages globally on many popular channels with ease and confidence when using Sinch's Conversation API. Conversation API is the preferred API for sending mobile messages on SMS and other social channels with Sinch. It is a simple API with unified error messages, consistent request payloads, and common webhook payloads that are channel-agnostic.","includeFiles":["docs/conversation/**/*.md","docs/conversation/**/*.yaml"],"excludeFiles":["docs/conversation/index.md"]},{"title":"Voice API","description":"The Voice API works as a big telephony switch. The Voice API handles incoming phone calls (also known as incoming call “legs”), sets up outgoing phone calls (or outgoing call “legs”), and bridges the two. The incoming call leg may come in over a data connection (from a smartphone or web application using the Sinch SDKs) or through a local phone number (from the PSTN network). Similarly, the outgoing call leg can be over data (to another smartphone or web application using the Sinch SDKs) or the PSTN network.","includeFiles":["docs/voice/**/*.md","docs/voice/**/*.yaml"],"excludeFiles":["docs/voice/index.md"]},{"title":"Voice API v2","description":"The Voice API works as a big telephony switch. The Voice API handles incoming phone calls (also known as incoming call “legs”), sets up outgoing phone calls (or outgoing call “legs”), and bridges the two. The incoming call leg may come in over a data connection (from a smartphone or web application using the Sinch SDKs) or through a local phone number (from the PSTN network). Similarly, the outgoing call leg can be over data (to another smartphone or web application using the Sinch SDKs) or the PSTN network.","includeFiles":["docs/voice-2.0/**/*.md","docs/voice-2.0/**/*.yaml"],"excludeFiles":["docs/voice-2.0/index.md"]},{"title":"Verification API","description":"The Verification API is a platform for phone number verification. It consists of the API and different software development kits (the Sinch SDKs) that you integrate with your smartphone or web application and cloud based back-end services. Together they enable SMS, Flashcall, Phone Call and Data verification in your application.","includeFiles":["docs/verification/**/*.md","docs/verification/**/*.yaml"],"excludeFiles":["docs/verification/index.md"]},{"title":"Provisioning API","description":"Provisioning API allows you to programmatically set up your senders, accounts and templates on your favorite messaging platforms on the Conversation API. For now, you can create your first WhatsApp channel through Meta's Embedded sign up, you can configure your first SMS App and configure your webhooks. As development continues, we will be adding the most commonly used channels.","includeFiles":["docs/provisioning-api/**/*.md","docs/provisioning-api/**/*.json"],"excludeFiles":["docs/provisioning-api/index.md"]},{"title":"Elastic SIP Trunking API","description":"With Elastic SIP Trunking you can create and manage your SIP trunks and phone numbers programmatically.","includeFiles":["docs/est/**/*.md","docs/est/**/*.yaml"],"excludeFiles":["docs/est/index.md"]},{"title":"Fax API","description":"Send and receive HIPAA compliant faxes on our modern fax platform using our developer-friendly API.","includeFiles":["docs/fax/**/*.md","docs/fax/**/*.yaml"],"excludeFiles":["docs/fax/index.md"]},{"title":"In-app Voice and Video SDK","description":"The In-app Voice and Video SDK enables you to add voice and video calling capabilities directly into your mobile or web application using the Sinch SDKs.","includeFiles":["docs/in-app-calling/**/*.md"],"excludeFiles":["docs/in-app-calling/index.md"]},{"title":"Number Lookup API","description":"The Number Lookup API is designed to provide in-depth information about phone numbers, helping enterprises enhance their communication strategies and prevent fraud. By identifying the type of phone line (for example, mobile, landline, VoIP) and the associated carrier, the API allows businesses to optimize routing, reduce unnecessary costs, and improve customer engagement.","includeFiles":["docs/number-lookup-api-v2/**/*.md","docs/number-lookup-api-v2/**/*.yaml"],"excludeFiles":["docs/number-lookup-api-v2/index.md"]},{"title":"Functions","description":"Serverless compute for voice and messaging. Deploy your code and Sinch routes live calls and messages to it — no infrastructure to run.","includeFiles":["docs/functions/functions/**/*.md","docs/functions/concepts/**/*.md","docs/functions/reference/**/*.md"],"excludeFiles":["docs/functions/functions/index.md"]},{"title":"CLI","description":"One command line for every Sinch API and the full Functions lifecycle — scaffold, run locally, deploy, and manage.","includeFiles":["docs/functions/cli/**/*.md"],"excludeFiles":["docs/functions/cli/index.md"]}]},"description":"Learn the syntax of the Sinch Python SDK for Voice v2 API."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"sinch-python-sdk-for-voice-v2","__idx":0},"children":["Sinch Python SDK for Voice v2"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"ConnectButton","attributes":{"title":"Sinch Agentic Tools","icon":"aiCode","option":[{"title":"Sinch Plugins","description":"Install Sinch Plugins","icon":"connection","link":"https://github.com/sinch/sinch-plugins#installation"},{"title":"Sinch Skills","description":"Install Sinch Skills","icon":"ai","link":"https://github.com/sinch/skills#installation"}]},"children":[]}," ",{"$$mdtype":"Tag","name":"ConnectButton","attributes":{"title":"Sinch SDKs","icon":"code","option":[{"title":"Sinch Node.js SDK","description":"Install Sinch Node.js SDK","icon":"node","link":"/docs/sdks/node#installation"},{"title":"Sinch Java SDK","description":"Install Sinch Java SDK","icon":"java","link":"/docs/sdks/java#installation"},{"title":"Sinch .NET SDK","description":"Install Sinch .NET SDK","icon":"dotnet","link":"/docs/sdks/dotnet#installation"},{"title":"Sinch Python SDK","description":"Install Sinch Python SDK","icon":"python","link":"/docs/sdks/python#installation"}]},"children":[]}," ",{"$$mdtype":"Tag","name":"ConnectButton","attributes":{"title":"Sinch CLI & Functions","icon":"window","option":[{"title":"Sinch CLI","description":"Install Sinch CLI","icon":"cli","link":"/docs/functions/cli/installation"},{"title":"Sinch Functions","description":"Quickstart Sinch Functions","icon":"code","link":"/docs/functions/functions/quickstart"}]},"children":[]}," ",{"$$mdtype":"Tag","name":"ConnectMCP","attributes":{"placement":"bottom","alignment":"start","options":["cursor","vscode","copy"]},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Sinch Python SDK allows you to quickly interact with the ",null," from inside your Python applications. When using the Python SDK, the code representing requests and queries sent to and responses received from the ",null," are structured similarly to those that are sent and received using the ",null,"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The fastest way to get started with the SDK is to check out our ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/voice-2.0/getting-started"},"children":["getting started"]}," guides. There you'll find all the instructions necessary to download, install, set up, and start using the SDK."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"syntax","__idx":1},"children":["Syntax"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Note:"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide describes the syntactical structure of the Python SDK for the Voice v2 API, including any differences that may exist between the API itself and the SDK. For a full reference on Voice v2 API calls and responses, see the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/voice-2.0/api-reference/voice"},"children":["Voice v2 API Reference"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The code sample below is an example of how to use the Python SDK to to make a text to speech phone call to a phone number. We've also provided an example that accomplishes the same task using the REST API."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"SDK","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"file":"/code-snippets/python_sdk/voice-v2/make-call.sample.py","language":"python","title":"snippet.py","header":{"title":"snippet.py","controls":{"copy":{}}},"lang":"python","source":"\"\"\"\nSinch Python Snippet\n\nThis snippet is available at https://github.com/sinch/sinch-sdk-python/tree/main/examples/snippets\n\"\"\"\n\nimport os\n\nfrom dotenv import load_dotenv\n\nfrom sinch import SinchClient\n\nload_dotenv()\n\nsinch_client = SinchClient(\n    project_id=os.environ.get(\"SINCH_PROJECT_ID\") or \"MY_PROJECT_ID\",\n    key_id=os.environ.get(\"SINCH_KEY_ID\") or \"MY_KEY_ID\",\n    key_secret=os.environ.get(\"SINCH_KEY_SECRET\") or \"MY_KEY_SECRET\",\n)\n\n# The Sinch phone number to call from\nfrom_phone_number = (\n    os.environ.get(\"SINCH_PHONE_NUMBER\") or \"MY_SINCH_PHONE_NUMBER\"\n)\n\n# The phone number of the recipient to call\nto_phone_number = \"RECIPIENT_PHONE_NUMBER\"\n\n# The command dialing out to the recipient\ndial_command = {\n    \"command\": \"dial\",\n    \"call_name\": \"Python_SDK_Snippet_Call\",\n    \"from_\": {\"type\": \"PHONE\", \"phone\": {\"number\": from_phone_number}},\n    \"to\": {\"type\": \"PHONE\", \"phone\": {\"number\": to_phone_number}},\n    \"events\": {\n        \"on_answer\": [\n            {\n                \"command\": \"messages\",\n                \"messages\": [\n                    {\n                        \"type\": \"SAY\",\n                        \"say\": {\n                            \"text\": \"Hello, your call is now connected.\",\n                            \"voice_name\": \"Emma\",\n                        },\n                    }\n                ],\n            }\n        ],\n        \"on_hangup\": [{\"command\": \"hangup\"}],\n    },\n}\n\n# The SVAML commands describing the call flow\ncommands = [dial_command]\n\nresponse = sinch_client.voice.v2.calls.start(commands=commands)\n\nprint(f\"Call Successfully started.\\n{response}\")\n"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"REST API","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\nproject_id = \"YOUR_projectId_PARAMETER\"\nurl = \"https://voice.api.sinch.com/v2/projects/\" + project_id + \"/calls\"\n\nquery = {\n  \"serviceId\": \"6e124178-c29d-46a5-943c-5c2ae544aade\"\n}\n\npayload = {\n  \"commands\": [\n    {\n      \"command\": \"dial\",\n      \"callName\": \"origin\",\n      \"from\": {\n        \"type\": \"PHONE\",\n        \"phone\": {\n          \"number\": \"+15551234567\"\n        }\n      },\n      \"to\": {\n        \"type\": \"PHONE\",\n        \"phone\": {\n          \"number\": \"+15559876543\"\n        }\n      },\n      \"dialTimeoutDurationSeconds\": 30,\n      \"maxCallDurationSeconds\": 3600,\n      \"events\": {\n        \"onAnswer\": [\n          {\n            \"command\": \"messages\",\n            \"messages\": [\n              {\n                \"type\": \"SAY\",\n                \"say\": {\n                  \"text\": \"Hello, your call is now connected.\",\n                  \"voiceName\": \"Emma\"\n                }\n              }\n            ]\n          }\n        ],\n        \"onHangup\": [\n          {\n            \"command\": \"hangup\"\n          }\n        ]\n      }\n    }\n  ]\n}\n\nheaders = {\n  \"Content-Type\": \"application/json\",\n  \"Idempotency-Key\": \"stringstringstri\"\n}\n\nresponse = requests.post(url, json=payload, headers=headers, params=query, auth=('<username>','<password>'))\n\ndata = response.json()\nprint(data)\n","lang":"python"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This example highlights the following required to successfully make a Voice v2 API call using the Sinch Python SDK:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#client"},"children":["Client initialization"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#voice-v2-domain"},"children":["Voice v2 domain access"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#endpoint-categories"},"children":["Endpoint usage"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#request-and-query-parameters"},"children":["Field population"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"client","__idx":2},"children":["Client"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When using the Sinch Python SDK, you initialize communication with the Sinch backend by initializing the Python SDK's main client class. This client allows you to access the functionality of the Sinch Python SDK."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"initialization","__idx":3},"children":["Initialization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To start using the SDK, you need to initialize the main client class with your credentials from your Sinch ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://dashboard.sinch.com"},"children":["dashboard"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from sinch import SinchClient\n\nsinch_client = SinchClient(key_id=\"key_id\", key_secret=\"key_secret\", project_id=\"YOUR_project_id\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For testing purposes on your local environment it's fine to use hardcoded values, but before deploying to production we strongly recommend using environment variables to store the credentials, as in the following example:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import os\nfrom sinch import SinchClient\n\nsinch_client = SinchClient(\n    key_id=os.getenv(\"KEY_ID\"),\n    key_secret=os.getenv(\"KEY_SECRET\"),\n    project_id=os.getenv(\"PROJECT_ID\")\n)\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"voice-v2-domain","__idx":4},"children":["Voice v2 domain"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The Sinch Python SDK organizes different functionalities in the Sinch product suite into domains. These domains are accessible through the client. For example, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["sinch_client.voice.v2.[endpoint_category].[method]"]},". You can also create a domain-specific client from a general client. For example:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"Python","header":{"controls":{"copy":{}}},"source":"\nfrom sinch import SinchClient\nfrom sinch.domains.voice.v2 import Voice\n\nsinch_client = SinchClient(key_id=\"YOUR_key_id\", key_secret=\"YOUR_key_secret\",\nproject_id=\"YOUR_project_id\")\n\nvoice_client = Voice(sinch_client)\n","lang":"Python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"endpoint-categories","__idx":5},"children":["Endpoint categories"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In the Sinch Python SDK, Voice v2 API endpoints are accessible through the client (either a general client or a Voice-specific client). The naming convention of the endpoint's representation in the SDK matches the API:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.batches_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.batches"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.calls_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.calls"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.services_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.services"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.sessions_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.sessions"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.sinch_events_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.sinch_events"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://developers.sinch.com/sdk/sinch-sdk-python/2.2.0/api/sinch.domains.voice.api.v2.svaml_apis.html"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["voice.v2.svaml"]},{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/external-blue.5a59beb5e5a442f78b530509ddf6b5d0fa705285ff8181e59adf96b5c2c73e25.33310b29.svg","alt":"external"},"children":[]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"Python","header":{"controls":{"copy":{}}},"source":"\ndial_command = {\n    \"command\": \"dial\",\n    \"call_name\": \"Python_SDK_Snippet_Call\",\n    \"from_\": {\"type\": \"PHONE\", \"phone\": {\"number\": from_phone_number}},\n    \"to\": {\"type\": \"PHONE\", \"phone\": {\"number\": to_phone_number}},\n    \"events\": {\n        \"on_answer\": [\n            {\n                \"command\": \"messages\",\n                \"messages\": [\n                    {\n                        \"type\": \"SAY\",\n                        \"say\": {\n                            \"text\": \"Hello, your call is now connected.\",\n                            \"voice_name\": \"Emma\",\n                        },\n                    }\n                ],\n            }\n        ],\n        \"on_hangup\": [{\"command\": \"hangup\"}],\n    },\n}\n\ncommands = [dial_command]\n\nresponse = sinch_client.voice.v2.calls.start(commands=commands)\n\n","lang":"Python"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"request-and-query-parameters","__idx":6},"children":["Request and query parameters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Requests and queries made using the Python SDK are similar to those made using the Voice v2 API. Many of the fields are named and structured similarly."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"field-name-differences","__idx":7},"children":["Field name differences"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When translating field names from the Voice v2 API to the Python SDK, remember that many of the API field names are in ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["camelCase"]},", whereas the Python SDK field names are in ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["snake_case"]},". This pattern change manages almost all field name translations between the API and the SDK."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"nested-objects","__idx":8},"children":["Nested objects"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When making calls directly to the API, we use JSON objects, including (in some cases) nested JSON objects. When using the Python SDK, we use dictionaries instead of nested JSON objects. For example, consider the callout ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["from"]}," configuration objects below. One is represented in JSON, the other as a Python dictionary:"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"SDK","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"\"from_\": {\"type\": \"PHONE\", \"phone\": {\"number\": from_phone_number}}\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JSON","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"JSON","header":{"controls":{"copy":{}}},"source":"\"from\": {\n    \"type\": \"PHONE\",\n    \"phone\": {\n        \"number\": \"YOUR_phone_number\"\n    }\n}\n","lang":"JSON"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Note that, in both cases, the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["from"]}," object is structured in exactly the same way as they would be in a normal Python call to the Voice v2 API. When using the Python SDK, any argument that represents a nested JSON object will be represented as a Python dictionary at the top level, but the contents of that dictionary must be represented as JSON objects."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"responses","__idx":9},"children":["Responses"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Response fields match the API responses. They are delivered as Python objects, with each top-level field represented as a property. Note that any nested objects normally returned by the Voice v2 API are returned as dictionaries by the Python SDK. Additionally, if there are any responses that differ significantly from the API responses, we note them in the endpoint category documentation."]}]},"headings":[{"value":"Sinch Python SDK for Voice v2","id":"sinch-python-sdk-for-voice-v2","depth":1},{"value":"Syntax","id":"syntax","depth":2},{"value":"Client","id":"client","depth":2},{"value":"Initialization","id":"initialization","depth":3},{"value":"Voice v2 domain","id":"voice-v2-domain","depth":2},{"value":"Endpoint categories","id":"endpoint-categories","depth":2},{"value":"Request and query parameters","id":"request-and-query-parameters","depth":2},{"value":"Field name differences","id":"field-name-differences","depth":3},{"value":"Nested objects","id":"nested-objects","depth":3},{"value":"Responses","id":"responses","depth":2}],"frontmatter":{"seo":{"title":"Python SDK Reference | Voice v2 API | Sinch","description":"Learn the syntax of the Sinch Python SDK for Voice v2 API."}},"lastModified":"2026-09-23T21:36:29.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/voice-2.0/sdk/python/syntax-reference","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}