{"id":13405607,"url":"https://github.com/twilio/twilio-python","last_synced_at":"2026-02-18T06:02:58.862Z","repository":{"id":664386,"uuid":"307447","full_name":"twilio/twilio-python","owner":"twilio","description":"A Python module for communicating with the Twilio API and generating TwiML.","archived":false,"fork":false,"pushed_at":"2026-02-05T12:32:37.000Z","size":157073,"stargazers_count":2036,"open_issues_count":45,"forks_count":802,"subscribers_count":113,"default_branch":"main","last_synced_at":"2026-02-05T22:32:40.023Z","etag":null,"topics":["twilio","twilio-api","twiml"],"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/twilio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2009-09-15T05:33:57.000Z","updated_at":"2026-02-05T16:44:24.000Z","dependencies_parsed_at":"2023-09-23T03:38:26.501Z","dependency_job_id":"3cea15ab-23c2-4ed4-af14-06da89628772","html_url":"https://github.com/twilio/twilio-python","commit_stats":{"total_commits":1448,"total_committers":136,"mean_commits":"10.647058823529411","dds":0.8812154696132597,"last_synced_commit":"2b659e27a287f2e3fbb6e964314be8bd7f009232"},"previous_names":[],"tags_count":362,"template":false,"template_full_name":null,"purl":"pkg:github/twilio/twilio-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twilio","download_url":"https://codeload.github.com/twilio/twilio-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilio%2Ftwilio-python/sbom","scorecard":{"id":903823,"data":{"date":"2025-08-11","repo":{"name":"github.com/twilio/twilio-python","commit":"f408b89da9801da245884d53b47cfa3ac6773090"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.8,"checks":[{"name":"Code-Review","score":3,"reason":"Found 11/30 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"16 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pr-lint.yml:1","Warn: no topLevel permission defined: .github/workflows/test-and-deploy.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-lint.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/pr-lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:89: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:107: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:113: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-and-deploy.yml:123: update your workflow using https://app.stepsecurity.io/secureworkflow/twilio/twilio-python/test-and-deploy.yml/main?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating python:3.7 to python:3.7@sha256:eedf63967cdb57d8214db38ce21f105003ed4e4d0358f02bedc057341bcf92a0","Warn: pipCommand not pinned by hash: Dockerfile:14","Warn: pipCommand not pinned by hash: Dockerfile:15","Warn: pipCommand not pinned by hash: .github/workflows/test-and-deploy.yml:34","Warn: pipCommand not pinned by hash: .github/workflows/test-and-deploy.yml:82","Warn: pipCommand not pinned by hash: .github/workflows/test-and-deploy.yml:83","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   7 third-party GitHubAction dependencies pinned","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   5 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/test-and-deploy.yml:64"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":5,"reason":"SAST tool is not run on all commits -- score normalized to 5","details":["Warn: 6 commits out of 11 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"56 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-8495-4g3g-x7pr","Warn: Project is vulnerable to: GHSA-9548-qrrj-x5pj","Warn: Project is vulnerable to: PYSEC-2024-230 / GHSA-248v-346w-9cwc","Warn: Project is vulnerable to: PYSEC-2023-117 / GHSA-mrwq-x4v8-fh7p","Warn: Project is vulnerable to: PYSEC-2017-24 / GHSA-r9jw-mwhq-wp62","Warn: Project is vulnerable to: PYSEC-2022-202","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-48p4-8xcf-vxj5","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: GHSA-3ww4-gg4f-jr7f","Warn: Project is vulnerable to: GHSA-9v9h-cgj8-h64p","Warn: Project is vulnerable to: PYSEC-2021-62 / GHSA-hggm-jpg3-v476","Warn: Project is vulnerable to: PYSEC-2017-8 / GHSA-q3cj-2r34-2cwc","Warn: Project is vulnerable to: PYSEC-2014-5 / GHSA-296w-6qhq-gf92","Warn: Project is vulnerable to: PYSEC-2011-2 / GHSA-3jqw-crqj-w8qw","Warn: Project is vulnerable to: PYSEC-2012-3 / GHSA-59w8-4wm2-4xw8","Warn: Project is vulnerable to: PYSEC-2012-4 / GHSA-5h2q-4hrp-v9rr","Warn: Project is vulnerable to: PYSEC-2014-6 / GHSA-625g-gx8c-xcmg","Warn: Project is vulnerable to: PYSEC-2015-8 / GHSA-6565-fg86-6jcx","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2012-2 / GHSA-78vx-ggch-wghm","Warn: Project is vulnerable to: PYSEC-2015-9 / GHSA-7fq8-4pv5-5w5c","Warn: Project is vulnerable to: PYSEC-2015-4 / GHSA-7qfw-j7hp-v45g","Warn: Project is vulnerable to: PYSEC-2011-9 / GHSA-7wph-fc4w-wqp2","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2014-2 / GHSA-89hj-xfx5-7q66","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2014-4 / GHSA-f7cm-ccfp-3q4r","Warn: Project is vulnerable to: PYSEC-2016-16 / GHSA-fp6p-5xvw-m74f","Warn: Project is vulnerable to: PYSEC-2011-8 / GHSA-fwr5-q9rx-294f","Warn: Project is vulnerable to: PYSEC-2015-5 / GHSA-gv98-g628-m9x5","Warn: Project is vulnerable to: PYSEC-2015-20 / GHSA-h582-2pch-3xv3","Warn: Project is vulnerable to: PYSEC-2011-5 / GHSA-h95j-h2rv-qrg4","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2015-6 / GHSA-jhjg-w2cp-5j44","Warn: Project is vulnerable to: PYSEC-2016-15 / GHSA-pw27-w7w4-9qc7","Warn: Project is vulnerable to: PYSEC-2015-10 / GHSA-q5qw-4364-5hhm","Warn: Project is vulnerable to: PYSEC-2011-4 / GHSA-rm2j-x595-q9cj","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2014-1 / GHSA-rvq6-mrpv-m6rm","Warn: Project is vulnerable to: PYSEC-2014-7 / GHSA-rw75-m7gp-92m3","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2014-3 / GHSA-wqjj-hx84-v449","Warn: Project is vulnerable to: PYSEC-2011-3 / GHSA-wxg3-mfph-qg9w","Warn: Project is vulnerable to: PYSEC-2011-1 / GHSA-x88j-93vc-wpmp","Warn: Project is vulnerable to: PYSEC-2007-1","Warn: Project is vulnerable to: PYSEC-2008-1","Warn: Project is vulnerable to: PYSEC-2008-2","Warn: Project is vulnerable to: PYSEC-2009-3","Warn: Project is vulnerable to: PYSEC-2015-11","Warn: Project is vulnerable to: PYSEC-2015-7","Warn: Project is vulnerable to: PYSEC-2016-18","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T16:38:22.529Z","repository_id":664386,"created_at":"2025-08-24T16:38:22.529Z","updated_at":"2025-08-24T16:38:22.529Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29569996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T04:18:28.490Z","status":"ssl_error","status_checked_at":"2026-02-18T04:13:49.018Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["twilio","twilio-api","twiml"],"created_at":"2024-07-30T19:02:06.464Z","updated_at":"2026-02-18T06:02:58.847Z","avatar_url":"https://github.com/twilio.png","language":"Python","funding_links":[],"categories":["Python","Third-party Web APIs"],"sub_categories":[],"readme":"# twilio-python\n\n[![Tests](https://github.com/twilio/twilio-python/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/twilio/twilio-python/actions/workflows/test-and-deploy.yml)\n[![PyPI](https://img.shields.io/pypi/v/twilio.svg)](https://pypi.python.org/pypi/twilio)\n[![PyPI](https://img.shields.io/pypi/pyversions/twilio.svg)](https://pypi.python.org/pypi/twilio)\n[![Learn OSS Contribution in TwilioQuest](https://img.shields.io/static/v1?label=TwilioQuest\u0026message=Learn%20to%20contribute%21\u0026color=F22F46\u0026labelColor=1f243c\u0026style=flat-square\u0026logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAASFBMVEUAAAAZGRkcHBwjIyMoKCgAAABgYGBoaGiAgICMjIyzs7PJycnMzMzNzc3UoBfd3d3m5ubqrhfrMEDu7u739/f4vSb/3AD///9tbdyEAAAABXRSTlMAAAAAAMJrBrEAAAKoSURBVHgB7ZrRcuI6EESdyxXGYoNFvMD//+l2bSszRgyUYpFAsXOeiJGmj4NkuWx1Qeh+Ekl9DgEXOBwOx+Px5xyQhDykfgq4wG63MxxaR4ddIkg6Ul3g84vCIcjPBA5gmUMeXESrlukuoK33+33uID8TWeLAdOWsKpJYzwVMB7bOzYSGOciyUlXSn0/ABXTosJ1M1SbypZ4O4MbZuIDMU02PMbauhhHMHXbmebmALIiEbbbbbUrpF1gwE9kFfRNAJaP+FQEXCCTGyJ4ngDrjOFo3jEL5JdqjF/pueR4cCeCGgAtwmuRS6gDwaRiGvu+DMFwSBLTE3+jF8JyuV1okPZ+AC4hDFhCHyHQjdjPHUKFDlHSJkHQXMB3KpSwXNGJPcwwTdZiXlRN0gSp0zpWxNtM0beYE0nRH6QIbO7rawwXaBYz0j78gxjokDuv12gVeUuBD0MDi0OQCLvDaAho4juP1Q/jkAncXqIcCfd+7gAu4QLMACCLxpRsSuQh0igu0C9Svhi7weAGZg50L3IE3cai4IfkNZAC8dfdhsUD3CgKBVC9JE5ABAFzg4QL/taYPAAWrHdYcgfLaIgAXWJ7OV38n1LEF8tt2TH29E+QAoDoO5Ve/LtCQDmKM9kPbvCEBApK+IXzbcSJ0cIGF6e8gpcRhUDogWZ8JnaWjPXc/fNnBBUKRngiHgTUSivSzDRDgHZQOLvBQgf8rRt+VdBUUhwkU6VpJ+xcOwQUqZr+mR0kvBUgv6cB4+37hQAkXqE8PwGisGhJtN4xAHMzrsgvI7rccXqSvKh6jltGlrOHA3Xk1At3LC4QiPdX9/0ndHpGVvTjR4bZA1ypAKgVcwE5vx74ulwIugDt8e/X7JgfkucBMIAr26ndnB4UCLnDOqvteQsHlgX9N4A+c4cW3DXSPbwAAAABJRU5ErkJggg==)](https://twil.io/learn-open-source)\n\n## Documentation\n\nThe documentation for the Twilio API can be found [here][apidocs].\n\nThe Python library documentation can be found [here][libdocs].\n\n## Versions\n\n`twilio-python` uses a modified version of [Semantic Versioning](https://semver.org) for all changes. [See this document](VERSIONS.md) for details.\n\n### Supported Python Versions\n\nThis library supports the following Python implementations:\n\n- Python 3.7\n- Python 3.8\n- Python 3.9\n- Python 3.10\n- Python 3.11\n\n## Installation\n\nInstall from PyPi using [pip](https://pip.pypa.io/en/latest/), a\npackage manager for Python.\n\n```shell\npip3 install twilio\n```\n\nIf pip install fails on Windows, check the path length of the directory. If it is greater 260 characters then enable [Long Paths](https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation) or choose other shorter location.\n\nDon't have pip installed? Try installing it, by running this from the command\nline:\n\n```shell\ncurl https://bootstrap.pypa.io/get-pip.py | python\n```\n\nOr, you can [download the source code\n(ZIP)](https://github.com/twilio/twilio-python/zipball/main 'twilio-python\nsource code') for `twilio-python`, and then run:\n\n```shell\npython3 setup.py install\n```\n\n\u003e **Info**\n\u003e If the command line gives you an error message that says Permission Denied, try running the above commands with `sudo` (e.g., `sudo pip3 install twilio`).\n\n### Test your installation\n\nTry sending yourself an SMS message. Save the following code sample to your computer with a text editor. Be sure to update the `account_sid`, `auth_token`, and `from_` phone number with values from your [Twilio account](https://console.twilio.com). The `to` phone number will be your own mobile phone.\n\n```python\nfrom twilio.rest import Client\n\n# Your Account SID and Auth Token from console.twilio.com\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token  = \"your_auth_token\"\n\nclient = Client(account_sid, auth_token)\n\nmessage = client.messages.create(\n    to=\"+15558675309\",\n    from_=\"+15017250604\",\n    body=\"Hello from Python!\")\n\nprint(message.sid)\n```\n\nSave the file as `send_sms.py`. In the terminal, `cd` to the directory containing the file you just saved then run:\n\n```shell\npython3 send_sms.py\n```\n\nAfter a brief delay, you will receive the text message on your phone.\n\n\u003e **Warning**\n\u003e It's okay to hardcode your credentials when testing locally, but you should use environment variables to keep them secret before committing any code or deploying to production. Check out [How to Set Environment Variables](https://www.twilio.com/blog/2017/01/how-to-set-environment-variables.html) for more information.\n\n## OAuth Feature for Twilio APIs\nWe are introducing Client Credentials Flow-based OAuth 2.0 authentication. This feature is currently in beta and its implementation is subject to change.\n\nAPI examples [here](https://github.com/twilio/twilio-python/blob/main/examples/public_oauth.py)\n\nOrganisation API examples [here](https://github.com/twilio/twilio-python/blob/main/examples/organization_api.py)\n\n## Use the helper library\n\n### API Credentials\n\nThe `Twilio` client needs your Twilio credentials. You can either pass these directly to the constructor (see the code below) or via environment variables.\n\nAuthenticating with Account SID and Auth Token:\n\n```python\nfrom twilio.rest import Client\n\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token  = \"your_auth_token\"\nclient = Client(account_sid, auth_token)\n```\n\nAuthenticating with API Key and API Secret:\n\n```python\nfrom twilio.rest import Client\n\napi_key = \"XXXXXXXXXXXXXXXXX\"\napi_secret = \"YYYYYYYYYYYYYYYYYY\"\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nclient = Client(api_key, api_secret, account_sid)\n```\n\nAlternatively, a `Client` constructor without these parameters will\nlook for `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` variables inside the\ncurrent environment.\n\nWe suggest storing your credentials as environment variables. Why? You'll never\nhave to worry about committing your credentials and accidentally posting them\nsomewhere public.\n\n```python\nfrom twilio.rest import Client\nclient = Client()\n```\n\n### Specify Region and/or Edge\n\nTo take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/docs/global-infrastructure), specify the target Region and Edge for the client:\n\n\u003e **Note:** When specifying a `region` parameter for a helper library client, be sure to also specify the `edge` parameter. For backward compatibility purposes, specifying a `region` without specifying an `edge` will result in requests being routed to US1.\n\n```python\nfrom twilio.rest import Client\n\nclient = Client(region='au1', edge='sydney')\n```\n\nA `Client` constructor without these parameters will also look for `TWILIO_REGION` and `TWILIO_EDGE` variables inside the current environment.\n\nAlternatively, you may specify the edge and/or region after constructing the Twilio client:\n\n```python\nfrom twilio.rest import Client\n\nclient = Client()\nclient.region = 'au1'\nclient.edge = 'sydney'\n```\n\nThis will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`.\n\n### Make a Call\n\n```python\nfrom twilio.rest import Client\n\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token  = \"your_auth_token\"\nclient = Client(account_sid, auth_token)\n\ncall = client.calls.create(to=\"9991231234\",\n                           from_=\"9991231234\",\n                           url=\"http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient\")\nprint(call.sid)\n```\n\n### Get data about an existing call\n\n```python\nfrom twilio.rest import Client\n\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token  = \"your_auth_token\"\nclient = Client(account_sid, auth_token)\n\ncall = client.calls.get(\"CA42ed11f93dc08b952027ffbc406d0868\")\nprint(call.to)\n```\n\n### Iterate through records\n\nThe library automatically handles paging for you. Collections, such as `calls` and `messages`, have `list` and `stream` methods that page under the hood. With both `list` and `stream`, you can specify the number of records you want to receive (`limit`) and the maximum size you want each page fetch to be (`page_size`). The library will then handle the task for you.\n\n`list` eagerly fetches all records and returns them as a list, whereas `stream` returns an iterator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the `page` method.\n\n`page_size` as a parameter is used to tell how many records should we get in every page and `limit` parameter is used to limit the max number of records we want to fetch.\n\n#### Use the `list` method\n\n```python\nfrom twilio.rest import Client\n\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token = \"your_auth_token\"\nclient = Client(account_sid, auth_token)\n\nfor sms in client.messages.list():\n  print(sms.to)\n```\n\n```python\nclient.messages.list(limit=20, page_size=20)\n```\nThis will make 1 call that will fetch 20 records from backend service.\n\n```python\nclient.messages.list(limit=20, page_size=10)\n```\nThis will make 2 calls that will fetch 10 records each from backend service.\n\n```python\nclient.messages.list(limit=20, page_size=100)\n```\nThis  will make 1 call which will fetch 100 records but user will get only 20 records.\n\n### Asynchronous API Requests\n\nBy default, the Twilio Client will make synchronous requests to the Twilio API. To allow for asynchronous, non-blocking requests, we've included an optional asynchronous HTTP client. When used with the Client and the accompanying `*_async` methods, requests made to the Twilio API will be performed asynchronously.\n\n```python\nfrom twilio.http.async_http_client import AsyncTwilioHttpClient\nfrom twilio.rest import Client\n\nasync def main():\n    account_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n    auth_token  = \"your_auth_token\"\n    http_client = AsyncTwilioHttpClient()\n    client = Client(account_sid, auth_token, http_client=http_client)\n\n    message = await client.messages.create_async(to=\"+12316851234\", from_=\"+15555555555\",\n                                                 body=\"Hello there!\")\n\nasyncio.run(main())\n```\n\n### Enable Debug Logging\n\nLog the API request and response data to the console:\n\n```python\nimport logging\n\nclient = Client(account_sid, auth_token)\nlogging.basicConfig()\nclient.http_client.logger.setLevel(logging.INFO)\n```\n\nLog the API request and response data to a file:\n\n```python\nimport logging\n\nclient = Client(account_sid, auth_token)\nlogging.basicConfig(filename='./log.txt')\nclient.http_client.logger.setLevel(logging.INFO)\n```\n\n### Handling Exceptions\n\nVersion 8.x of `twilio-python` exports an exception class to help you handle exceptions that are specific to Twilio methods. To use it, import `TwilioRestException` and catch exceptions as follows:\n\n```python\nfrom twilio.rest import Client\nfrom twilio.base.exceptions import TwilioRestException\n\naccount_sid = \"ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nauth_token  = \"your_auth_token\"\nclient = Client(account_sid, auth_token)\n\ntry:\n  message = client.messages.create(to=\"+12316851234\", from_=\"+15555555555\",\n                                   body=\"Hello there!\")\nexcept TwilioRestException as e:\n  print(e)\n```\n\n### Generating TwiML\n\nTo control phone calls, your application needs to output [TwiML][twiml].\n\nUse `twilio.twiml.Response` to easily create such responses.\n\n```python\nfrom twilio.twiml.voice_response import VoiceResponse\n\nr = VoiceResponse()\nr.say(\"Welcome to twilio!\")\nprint(str(r))\n```\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cResponse\u003e\u003cSay\u003eWelcome to twilio!\u003c/Say\u003e\u003c/Response\u003e\n```\n\n### Other advanced examples\n\n- [Learn how to create your own custom HTTP client](./advanced-examples/custom-http-client.md)\n\n### Docker Image\n\nThe `Dockerfile` present in this repository and its respective `twilio/twilio-python` Docker image are currently used by Twilio for testing purposes only.\n\n### Getting help\n\nIf you need help installing or using the library, please check the [Twilio Support Help Center](https://support.twilio.com) first, and [file a support ticket](https://twilio.com/help/contact) if you don't find an answer to your question.\n\nIf you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!\n\n[apidocs]: https://www.twilio.com/docs/api\n[twiml]: https://www.twilio.com/docs/api/twiml\n[libdocs]: https://twilio.github.io/twilio-python\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Ftwilio-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilio%2Ftwilio-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilio%2Ftwilio-python/lists"}