{"templateId":"markdown","sharedDataIds":{},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"product":"SMS","type":"markdown"},"seo":{"title":"Sending SMS With Python | SMS 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":"SMS API","description":"The SMS API allows you to send and receive SMS messages with a few easy steps. You can also send bulk SMS messages to multiple customers using the Sinch SMS service.","includeFiles":["docs/sms/**/*.md","docs/sms/**/*.yaml"],"excludeFiles":["docs/sms/index.md"]},{"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":"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"]}],"hide":false,"excludeFiles":[]},"description":"In this tutorial, you will use the Sinch SMS Python module to send SMS messages and to template your messages. Learn more here."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"sending-the-xms-sms-api-using-python","__idx":0},"children":["Sending the XMS SMS API using Python"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Heads up!"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You're on an older page that may not be updated with the latest info. ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/sms/getting-started"},"children":["Click here to get started"]}," with the latest version of the SMS REST API."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this tutorial we're going to utilize our HTTP REST Messaging API. Wow that's a beautiful name, right? Let us just call it ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["XMS API"]},", that feels a lot better!"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You have created your Sinch account, if you don't have one, create one ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://dashboard.sinch.com/signup/"},"children":["here"]}," and get some free credits to try the API out :fire:"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["You have ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["python"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip"]}," installed. If you don't, you can read about how to do it on your system ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://www.python.org/downloads/"},"children":["here"]}," and for ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip"]}," ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://pip.pypa.io/en/stable/installing/"},"children":["here"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Install the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://pypi.org/project/clx-sdk-xms/"},"children":["Sinch Library"]}," (clx-sdk-sms, it's a legacy name :cocktail:)."," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip install clx-sdk-xms"]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"credentials","__idx":2},"children":["Credentials"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you don't already have an API configured, go to your API Overview and click on the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Add new REST API"]}," button. Your credentials will be generated and shown within seconds!"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://dashboard.sinch.com/login"},"children":["Login"]}," to the dashboard."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Go to your ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://dashboard.sinch.com/sms/api/rest"},"children":["API Overview"]}," and find your ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Service Plan ID"]}," and ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["API Token"]},". Keep them close, we'll need them later."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"time-to-code","__idx":3},"children":["Time to code!"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Let us first set up our # Variables for the requestbody"," ","sender_phonenumber = '24321432'"," ","recipients_phonenumbers = ['213353455','+4623454645']"," ","body = 'Hello, ${name}!'"," ","parameters = {"," ","'name': {"," ","'+46722324894' : 'John',"," ","'default' : 'valued customer'"," ","}"," ","}"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["try:"," ","message_params = api.MtBatchTextSmsCreate()"," ","message_params.sender = sender_phonenumber"," ","message_params.recipients = recipients_phonenumbers"," ","message_params.parameters = parameters"," ","message_params.body = body"," ","batch = client.create_batch(message_params)"," ","print('The batch was given ID %s' % batch.batch_id)"," ","except Exception as ex:"," ","print('Error creating batch: %s' % str(ex))"]},{"$$mdtype":"Tag","name":"div","attributes":{},"children":[]}]},"headings":[{"value":"Sending the XMS SMS API using Python","id":"sending-the-xms-sms-api-using-python","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Credentials","id":"credentials","depth":3},{"value":"Time to code!","id":"time-to-code","depth":2}],"frontmatter":{"seo":{"title":"Sending SMS With Python | SMS API | Sinch","description":"In this tutorial, you will use the Sinch SMS Python module to send SMS messages and to template your messages. Learn more here."},"excludeFromSearch":true},"lastModified":"2025-09-29T03:59:51.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/sms/tutorials/python/sending-sms-with-python-xms","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}