﻿{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-docs/sms/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["partial","admonition"]},"product":"SMS","type":"markdown"},"seo":{"title":"User consent | 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":"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"]},{"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":"In this tutorial, you will use the Python SDK to create an application that allows users to consent to receiving SMS campaigns."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"creating-a-user-consent-application-using-the-python-sdk","__idx":0},"children":["Creating a user consent application using the Python SDK"]},{"$$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":["SMS marketing campaigns are a great way to engage customers. However it's vital to obtain consent before doing this. Countries such as the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://community.sinch.com/t5/SMS/Standard-opt-out-keywords-and-advanced-alternatives-for-USA-and/ta-p/14159?attachment-id=1430"},"children":["US and Canada"]}," and the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://community.sinch.com/t5/Glossary/GDPR/ta-p/7548"},"children":["EU GDPR framework"]}," require customers to explicitly consent to receiving messages before organizations can contact them. This means it is vital for any SMS campaign to provide recipients the ability to opt themselves in or out of receiving messages."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":" Note:"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To complete this tutorial, you need to have completed the following prerequisites:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Set all SMS API ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/sms/getting-started"},"children":["configuration settings"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.python.org/"},"children":["Python"]}," and a familiarity with how to create a new app."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://pypi.org/project/pip/"},"children":["PIP (package installer for Python)"]}," and a familiarity with how to install Python modules."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/sms/getting-started/python/receive-sms-sdk/"},"children":["Receive an SMS Message Guide"]},"."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this tutorial we will build on what we learned from the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Receive an SMS Message"]}," guide to create a console application that allows users to sign up to receiving SMS notifications. This application will create a new group called ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Sinch Pirates"]},". It will then allow a user to do the following:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Join the group by texting the keyword ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["SUBSCRIBE"]},". The application will add their phone number to ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Sinch Pirates"]},". It will then send a confirmation message thanking them for joining and telling them the  keyword for leaving the group."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["If they are already a member, leave the group by texting the keyword ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["STOP"]},". The application will remove their phone number from ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Sinch Pirates"]},". It will then send a confirmation message expressing regret at their wish to leave and telling them the keyword for joining."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In the event they text the group number but aren't a member, the application will send a reply thanking them for their interest and telling them the join keyword."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To make this all work, several cool features of Sinch's SMS API will be leveraged. First, there is the ability, which we've already seen, to receive an inbound message and send a response using the SDK ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["send"]}," method. Additionally, we'll use the SDK to create a group and automatically add and remove phone numbers from it."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Note:"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["While this tutorial provides more real-world context and supporting material than some of our other guides, it is still intended for demonstrative purposes. In a production environment, you will have to modify any provided code samples to ensure that you maintain the security, efficacy, and stability of your solutions."]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Contents"},"children":[{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/sms/tutorials/python-sdk/user-consent/set-up"},"children":["Set up your application"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/sms/tutorials/python-sdk/user-consent/create-app"},"children":["Creating the application"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/docs/sms/tutorials/python-sdk/user-consent/testing-app"},"children":["Testing your application"]}]}]}]},{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}]},"headings":[{"value":"Creating a user consent application using the Python SDK","id":"creating-a-user-consent-application-using-the-python-sdk","depth":1}],"frontmatter":{"seo":{"title":"User consent | SMS API | Sinch","description":"In this tutorial, you will use the Python SDK to create an application that allows users to consent to receiving SMS campaigns."},"excludeFromSearch":true},"lastModified":"2026-07-31T20:21:28.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/sms/tutorials/python-sdk/user-consent","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}