Skip to main content

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"],
    os.environ["TERNWIRE_API_ORIGIN"],
    timeout=30,
)
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 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_API_ORIGIN, TERNWIRE_FROM, and TERNWIRE_TO before deliberately running python3 examples/send.py. It submits an email.

Use https://ternwire.com as the API origin. Read the full documentation at ternwire.com/docs, or contact support@ternwire.com. Released under the MIT License.

Metadata

Release files for ternwire 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ternwire 0.1.0
File Size Uploaded
ternwire-0.1.0.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ternwire 0.1.0
File Interpreter ABI Platform
ternwire-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / ternwire-0.1.0.tar.gz

Download URL ternwire-0.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b16bf7b8f70e51b9b0a23a83637ba412736348adfe50f093c8d5c595c8ab2f55
BLAKE2b-256 checksum
How to use checksums
ec9d5e297f50e0ec897382c4a6e22d4cf199f1a81bcf1840d53120006471fef1
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

Release files / ternwire-0.1.0-py3-none-any.whl

Download URL ternwire-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e1b6ff5466c937afc29c968d00f161d2667c929721c63808efafb43d000ba50
BLAKE2b-256 checksum
How to use checksums
c213535b7347593dbbb874dad80b99407e370d6df893e2cac3723f699355ff31
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

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page