Registry / http-networking / telnyx

telnyx

JSON →
library4.176.0pypypi✓ verified 21d ago

The Telnyx Python library provides convenient access to the Telnyx REST API from any Python 3.9+ application. It includes type definitions for all request parameters and response fields, offering both synchronous and asynchronous clients powered by `httpx`. The library is actively maintained with frequent updates, often daily, reflecting API changes and new features.

pip install telnyx
INSTALL
IMPORT
SIG · TELNYX
T
telnyx
http-networkingpythonv4.176.0
Install
7.1s avg
Import
3752ms
Disk
80MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.176.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 3.871s · 78.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 7.1s · import 3.633s · 80MB
80MB installed
● package 80MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Telnyx
from telnyx import Telnyx
For synchronous API calls.
AsyncTelnyx
from telnyx import AsyncTelnyx
For asynchronous API calls.

Initializes the Telnyx client using an API key from an environment variable and attempts to list messaging profiles to verify connectivity and authentication. Replace `YOUR_TELNYX_API_KEY_HERE` with an actual key or ensure the `TELNYX_API_KEY` environment variable is set.

import os import telnyx # It is recommended to set TELNYX_API_KEY as an environment variable # export TELNYX_API_KEY="YOUR_TELNYX_API_KEY" api_key = os.environ.get("TELNYX_API_KEY", "YOUR_TELNYX_API_KEY_HERE") if not api_key or api_key == "YOUR_TELNYX_API_KEY_HERE": print("Warning: TELNYX_API_KEY environment variable not set or is placeholder.") print("Please set TELNYX_API_KEY or replace 'YOUR_TELNYX_API_KEY_HERE' with your actual API key.") # In a production environment, you would likely exit or raise an error. client = telnyx.Telnyx(api_key=api_key) try: # Example: List messaging profiles to verify connectivity and API key print("Attempting to list messaging profiles...") messaging_profiles = client.messaging_profiles.list() print(f"Successfully retrieved {len(messaging_profiles.data)} messaging profiles.") if messaging_profiles.data: print(f"First profile ID: {messaging_profiles.data[0].id}") except telnyx.APIStatusError as e: print(f"Telnyx API Error: {e.status_code} - {e.response.json()}") print("Please ensure your API key is valid and has the necessary permissions.") except telnyx.APIConnectionError as e: print(f"Telnyx Connection Error: {e}") print("Please check your network connection.") except Exception as e: print(f"An unexpected error occurred: {e}")
Debug
Known issues
breakingMalicious versions 4.87.1 and 4.87.2 were briefly published to PyPI, containing malicious code. If installed between 03:51 UTC and 10:13 UTC on March 27, 2026, your system may have been compromised.
fix
Immediately uninstall the affected versions (`pip uninstall telnyx`), then install a known clean version (e.g., `pip install telnyx==4.87.0` or the latest stable version not affected). Rotate all exposed credentials and audit systems for compromise.
affects: 4.87.1, 4.87.2
gotchaTelnyx recommends storing API keys as environment variables (`TELNYX_API_KEY`) and explicitly passing them to the client constructor, rather than setting `telnyx.api_key` globally, especially for applications requiring multiple keys or robust security practices.
fix
Use `api_key=os.environ.get("TELNYX_API_KEY")` when instantiating `telnyx.Telnyx()` or `telnyx.AsyncTelnyx()`. Never hardcode API keys or commit them to version control.
affects: All versions
gotchaWebhook signature verification now defaults to Ed25519. If you are handling webhooks, it's strongly recommended to verify signatures to ensure authenticity.
fix
Implement Ed25519 webhook signature verification in your webhook handler. Refer to the Telnyx documentation for specific implementation details for Python.
affects: 4.105.0 and newer
gotchaThe library is updated very frequently (sometimes daily), and while it generally follows SemVer, some backwards-incompatible changes may be released as minor versions if they affect static types, internal components, or are not expected to impact the majority of users.
fix
Regularly review release notes before upgrading and thoroughly test your application after updates to catch subtle breaking changes.
affects: All versions (v4 and above)
gotchaThe keyword `from` is a reserved word in Python but often an API parameter (e.g., in messaging). The library handles this by allowing `from_` as a keyword argument for such parameters.
fix
When an API parameter clashes with a Python reserved word, append an underscore (`_`) to the parameter name (e.g., `from_="..."`).
affects: All versions (where 'from' is an API parameter)
gotchaWhen sending file data, ensure it is passed as a single parameter. An earlier bug caused issues if file data was incorrectly structured.
fix
Ensure your file upload logic conforms to the latest SDK examples for `telnyx.files.create()` or similar methods to avoid issues fixed in v4.104.1.
affects: Prior to 4.104.1
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'telnyx'
The 'telnyx' package is not installed in the Python environment being used.
fix
pip install telnyx
telnyx.exceptions.TelnyxAPIError: 401 Client Error: Unauthorized
The provided Telnyx API key is missing, incorrect, expired, or does not have the necessary permissions for the requested operation, leading to an unauthorized API request.
fix
import telnyx
client = telnyx.TelnyxClient(api_key="YOUR_VALID_TELNYX_API_KEY")
# Ensure 'YOUR_VALID_TELNYX_API_KEY' is replaced with a real, active API key from the Telnyx Mission Control Portal.
AttributeError: module 'telnyx' has no attribute 'Message'
This error occurs when attempting to use an older API interaction pattern (e.g., `telnyx.Message.create()`) from Telnyx Python library versions 2.x/3.x, which is deprecated in version 4.x in favor of a client-based approach.
fix
import telnyx
client = telnyx.TelnyxClient(api_key="YOUR_TELNYX_API_KEY")
message = client.messages.create(
    to=["+15551234567"],
    from_="+15550001111",
    text="Hello from Telnyx!"
)
TypeError: create() missing 1 required positional argument: 'to'
A required parameter for the API call, such as 'to' for message creation, was not provided or was misspelled in the method call.
fix
import telnyx
client = telnyx.TelnyxClient(api_key="YOUR_TELNYX_API_KEY")
message = client.messages.create(
    to=["+15551234567"],  # Add the missing 'to' argument with a valid recipient number
    from_="+15550001111",
    text="Hello from Telnyx!"
)
Upgrade
Version history
4.176.0latest on PyPI · released Aug 21, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.9 or newer.
aiohttpoptionalOptional backend for improved concurrency performance with the async client.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources