Skip to main content

carrier-python

Python client for the Carrier API, the hosted MCP server, and the carrier CLI. intents.create posts to /v1/connectivity/intents. call uses an OpenAPI operation id. Mcp speaks Streamable HTTP. Cli runs the binary with an argument list. rest_tools, mcp_tools, and cli_tools return plain dicts for LangGraph or an OpenAI-style tool loop. The price on a product is catalogue data. Neither an intent nor a product debits a wallet.

pip install carrier-python
import os
from carrier import Carrier

carrier = Carrier(os.environ["CARRIER_API_KEY"])
intent = carrier.intents.create(
    plan="test_global_1gb",
    metadata={"order": "123"},
    idempotency_key="order_123",
)

test_global_1gb is a practice plan. The call succeeds, livemode is false, and the network is not used. The same idempotency key and body return the original intent.

A waiting intent takes a plan later:

carrier.intents.confirm(intent.id, plan="test_global_1gb")

Webhook deliveries use Carrier-Signature: t=<unix>,v1=<hex> over {timestamp}.{body}. The endpoint secret (whsec_…) is returned once, on create.

from carrier import verify_webhook_signature

ok = verify_webhook_signature(raw_body, header, secret)

CarrierError.status, .code, and .type match the API error envelope. A blank API key raises before a request is sent.

Issuance safety (0.1.11)

For intents.create and call("issue_esim_from_inventory", ...), supply a stable business key. Issuance keys must match [A-Za-z0-9][A-Za-z0-9_.:-]{0,199}. They are never trimmed, coerced, or replaced. Invalid keys fail before transport; nonissuance operations retain their existing key rules.

Transport loss, response-read failure, or response-decode failure after an issuance call raises CarrierError with code == "outcome_unknown", the unchanged .idempotency_key, and .retryable is False. The SDK does not retry dispatch or mint a new key. Reconcile the original operation using that key; do not automatically reissue. A complete valid API error keeps its server status, code, message, and type. This is not a provider exactly-once guarantee. Custom transports must not retry issuance internally.

Every public operation:

accounts = carrier.call("list_reseller_accounts")
issued = carrier.call(
    "create_connectivity_intent",
    body={"plan": "test_global_1gb"},
    idempotency_key="order_123",
)

security on each catalog entry is bearer, public, internal, or storefront. A customer API key is bearer. The two internal routes do not accept that key.

from carrier import Mcp, Cli, rest_tools

session = Mcp(os.environ["ESIMVAULT_API_TOKEN"])  # ?TOKEN= on https://mcp.carrier.llc/mcp
tools = session.list_tools()
session.call_tool("list_subscribers", {"limit": 5})

cli = Cli()
cli.run(["subscribers", "list", "--limit", "5"])
agent_tools = rest_tools(carrier)

Mcp(..., auth="bearer") sends an OAuth access token or a Clerk organization API key. Cli never invokes a shell. Pass strict=False only when you intentionally run a command that is not in the catalog.

Python 3.11 or newer. The package uses the standard library only. pip install carrier-python installs it from PyPI.

Metadata

Release files for carrier-python 0.1.19

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

Source distribution (sdist)

Source distribution for carrier-python 0.1.19
File Size Uploaded Provenance Actions
carrier_python-0.1.19.tar.gz 49.4 kB Without provenance Details for carrier_python-0.1.19.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for carrier-python 0.1.19
File Interpreter ABI Platform Actions
carrier_python-0.1.19-py3-none-any.whl Python 3 none any Details for carrier_python-0.1.19-py3-none-any.whl

Total release size: 96.9 kB

Release files / carrier_python-0.1.19.tar.gz

Download URL carrier_python-0.1.19.tar.gz
Size 49.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9c307ed10f285c4adc14133af35eae5a7d6d7c2e1539d756d07faee6e2e4223a
BLAKE2b-256 checksum
How to use checksums
7a21c86430a80c9be716d33f7dd51d76dcd5867d49269f761d2412f665e2d294
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / carrier_python-0.1.19-py3-none-any.whl

Download URL carrier_python-0.1.19-py3-none-any.whl
Size 47.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bf6f072ebc7f2f468b5fe0ba907e8c17eee9688c5618e5e4350e281a2532bcc
BLAKE2b-256 checksum
How to use checksums
164dde9af5dc7d4ce80f4f6503bfe7fbdc2f0b42e7052936b998faa51d719d32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.16

Security for carrier-python 0.1.19

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