Skip to main content

Sonic SDK

Multi-currency settlement engine with cryptographic receipt attestation.

Sonic processes payments across rails (Stripe, Moov, Circle/USDC), normalizes through a treasury layer, executes payouts, and produces hash-chained receipts optionally attested by the SmartBlocks Network.

You need a Sonic API key to use this SDK. Request access

Install

pip install sonic-sdk

Quick Start

from sonic.client import SonicClient

sonic = SonicClient(
    base_url="https://api.sonic.tower.dev",
    api_key="sonic_live_...",
)

# Create a payment
payment = sonic.create_payment(
    amount="250.00",
    currency="USD",
    rail="stripe_card",
    idempotency_key="inv-20260219-001",
)
print(payment.tx_id)        # "txn_a1b2c3..."
print(payment.receipt_hash)  # "sha256:..."

# Check transaction state
tx = sonic.get_transaction(payment.tx_id)
print(tx.state)              # "receivable_detected"
print(tx.inbound_amount)     # Decimal("250.00")

# Get finality info
finality = sonic.get_transaction_finality(payment.tx_id)
print(finality.finality_status)       # "final" | "confirmed" | "pending"
print(finality.hold_period_seconds)   # 0 for cards, 259200 for ACH

# Execute payout once cleared
payout = sonic.execute_payout(
    tx_id=payment.tx_id,
    recipient_id="rcpt_merchant_wallet",
    idempotency_key="payout-20260219-001",
)
print(payout.payout_status)  # "payout_executed"
print(payout.provider_ref)   # "po_stripe_xyz..."

# Verify receipt chain integrity
verification = sonic.verify_receipt(payment.tx_id, sequence=0)
print(verification.chain_valid)   # True
print(verification.sbn_attested)  # True (if SBN attestation completed)

# Public verification (no auth required — shareable with auditors)
public = sonic.public_verify(payment.receipt_hash)
print(public.chain_valid)

Async

from sonic.client import AsyncSonicClient

async with AsyncSonicClient(base_url="...", api_key="...") as sonic:
    payment = await sonic.create_payment(
        amount="100.00", currency="USD", idempotency_key="inv-001"
    )
    tx = await sonic.get_transaction(payment.tx_id)

API Coverage

Method Endpoint Returns
create_payment() POST /v1/payments PaymentResponse
execute_payout() POST /v1/payouts PayoutResponse
get_transaction() GET /v1/transactions/{tx_id} TransactionResponse
list_transactions() GET /v1/transactions TransactionListResponse
get_transaction_events() GET /v1/transactions/{tx_id}/events list[EventResponse]
get_transaction_finality() GET /v1/transactions/{tx_id}/finality FinalityResponse
get_receipts() GET /v1/receipts/{tx_id} list[ReceiptResponse]
verify_receipt() GET /v1/receipts/{tx_id}/verify VerifyResponse
public_verify() GET /v1/verify/{hash} VerifyResponse
get_merchant() GET /v1/merchants/{id} MerchantResponse
register_webhook() POST /v1/merchants/{id}/webhooks WebhookResponse

All response types are Pydantic v2 models with full type hints.

Error Handling

from sonic.client import SonicClient, SonicNotFound, SonicAuthError, SonicConflict

sonic = SonicClient(base_url="...", api_key="...")

try:
    tx = sonic.get_transaction("txn_nonexistent")
except SonicNotFound:
    print("Transaction not found")
except SonicAuthError:
    print("Bad API key")
except SonicConflict:
    print("State conflict (e.g., payout on uncleared tx)")

Install Extras

pip install sonic-sdk              # Client only — all you need to call the API
pip install sonic-sdk[engine]      # + settlement engine, receipt builder, finality gate
pip install sonic-sdk[server]      # + FastAPI server, DB, Redis (run your own Sonic)
pip install sonic-sdk[dev]         # + pytest, ruff, mypy

Supported Rails

Rail Provider Finality Reversible Window
stripe_card Stripe Instant on capture 120 days (chargeback)
stripe_ach Stripe 4 days 60 days (ACH return)
moov_ach Moov 3 days 60 days
circle_usdc Circle ~2 min (6 confirmations) Irreversible
circle_usdc_solana Circle ~30s (32 confirmations) Irreversible

License

Apache 2.0 — Tower Technologies, Brooks Holdings Inc.

Metadata

Release files for sonic-sdk 0.3.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 sonic-sdk 0.3.0
File Size Uploaded Provenance Actions
sonic_sdk-0.3.0.tar.gz 234.1 kB Without provenance Details for sonic_sdk-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sonic-sdk 0.3.0
File Interpreter ABI Platform Actions
sonic_sdk-0.3.0-py3-none-any.whl Python 3 none any Details for sonic_sdk-0.3.0-py3-none-any.whl

Total release size: 541.6 kB

Release files / sonic_sdk-0.3.0.tar.gz

Download URL sonic_sdk-0.3.0.tar.gz
Size 234.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0b33092b1240bd0396d3aac467df522d0894b724bcdfab7f3e87239a8827703d
BLAKE2b-256 checksum
How to use checksums
f13157107855f228e7f556b42c9b5f7daf7dd9068138755e68740d72d391bc64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / sonic_sdk-0.3.0-py3-none-any.whl

Download URL sonic_sdk-0.3.0-py3-none-any.whl
Size 307.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1be17efc656287a50395c4a37c0069ea7ce16fb808b207cb02c1f19e8e13ab67
BLAKE2b-256 checksum
How to use checksums
92843715fb1df6008dce1b1efb2da80a5c8b7fa54556d8393c8a4acdbf8623a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for sonic-sdk 0.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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