Ternwire Python SDK
Python client for the Ternwire transactional email API. Requires Python 3.10+ and has no runtime dependencies.
Install
pip install ternwire
Usage
import os
from ternwire import TernwireApiError, TernwireClient, verify_webhook
client = TernwireClient(os.environ["TERNWIRE_API_KEY"])
try:
message = client.submit_email({
"from": "notifications@your-verified-domain.com",
"to": ["recipient@example.com"],
"subject": "Your receipt",
"text": "Thanks for your order.",
}, "order-123-receipt")
print(message)
except TernwireApiError as error:
print(error.status, error.body, error.headers)
The client sends requests to https://ternwire.com, exported as DEFAULT_BASE_URL.
To use a local or staging server, pass its origin as the second argument, as in
TernwireClient(api_key, "http://localhost:3001"). The origin must use https unless it
points at localhost or a loopback address, and must not include /v1 or any other path.
The optional timeout keyword sets the request timeout in seconds, default 30.
The synchronous client exposes all 17 operations using snake_case names, such as
get_message(id), create_sending_domain({"domain": "example.com"}), and
list_email_templates(). Bodies and responses are dictionaries with camelCase
JSON keys. Template deletion returns None. Network failures use urllib exceptions.
list_email_templates(cursor=None, limit=None) returns one page of summaries;
pass the previous page.nextCursor as cursor to fetch the next page.
For webhooks, call verify_webhook(signature_header, raw_body_bytes, signing_secret).
The optional fourth argument is the timestamp tolerance in seconds, default 300.
Set TERNWIRE_API_KEY, TERNWIRE_FROM, and TERNWIRE_TO before deliberately running
python3 examples/send.py. It submits an email. Set TERNWIRE_API_ORIGIN only to send
to a local or staging server instead of https://ternwire.com.
Read the full documentation at ternwire.com/docs, or contact support@ternwire.com. Released under the MIT License.
Metadata
Release files for ternwire 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ternwire-0.2.0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ternwire-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / ternwire-0.2.0.tar.gz
| Download URL | ternwire-0.2.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
40198ff06b8974aa2152b19d6cfe8d6c64eb325c31f7ea4bf76b533ab23e394a
|
|
BLAKE2b-256 checksum How to use checksums |
b7b292c5c6334fe233d40bddd6d1f6204e20de14176a7c89d0d7a4bb46c74218
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / ternwire-0.2.0-py3-none-any.whl
| Download URL | ternwire-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31a1e95e0ace12ebbb00ac1e5eaa63d0aac9e7511ff9340a1dda1e2ae37da60a
|
|
BLAKE2b-256 checksum How to use checksums |
b3a4886aa19fcff38db06e5a3d5a44e2c376d1a02814e2a444b9a2a1390a03a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log