Python SDK | MOSS Partner API
moss-partner-sdk · PyPI v0.3.0 · Python 3.9+

Python SDK

The official MOSS Partner SDK for Python. Full programmatic access to the Partner API: create customers, promote them to production, manage webhooks, and download compliance reports. Methods are async and field names are snake_case, matching the REST API exactly.

Install

bash
pip install moss-partner-sdk

Quickstart

Initialize the client with your prt_ partner key, then create a customer. The customer token is returned once. Store it securely.

python
from moss_partner_sdk import MossPartner

moss = MossPartner(api_key="prt_your_key")

# Create a sandbox customer
customer = await moss.customers.create(
    external_id="acme_123",
    name="Acme Corp",
    tier="platform",
)
print(customer.customer_id)
print(customer.credentials.customer_token.token)

Working with customers

List, fetch, and update customers with async methods that mirror the REST resource.

python
# List customers, optionally filtered by status
result = await moss.customers.list(status="sandbox_active")
for c in result.customers:
    print(c.name, c.status)

# Fetch one customer
customer = await moss.customers.get("cust-uuid")

# Update limits
await moss.customers.update("cust-uuid", limits={"agents": 50})

Promote to production

Check readiness, then promote with a signed attestation and billing details. The attestation record is signed with ML-DSA-44 and is immutable.

python
# Is the customer ready?
readiness = await moss.customers.promotion_readiness("cust-uuid")
if not readiness.ready:
    print("Blockers:", readiness.blockers)

# Promote
result = await moss.customers.promote(
    "cust-uuid",
    attestation={
        "kyc_completed": True,
        "kyc_provider": "Onfido",
        "terms_accepted": True,
        "compliance_reviewed": True,
    },
    billing={"tier": "platform", "billing_email": "billing@acme.com"},
)
print(result.credentials.production_token.token)  # returned once

Invite users & sessions

Invite a customer admin to the Customer Portal, or mint a short-lived session token to embed the MOSS dashboard in your own product.

python
# Invite a customer user
await moss.customers.invite("cust-uuid", email="admin@acme.com", role="admin")

# Mint a 15-minute session token for embedding
session = await moss.customers.create_session("cust-uuid")
print(session.token, session.expires_at)

Verify webhook signatures

MOSS signs "{timestamp}.{body}" with HMAC-SHA256 using your shared secret. The SDK ships a constant-time verifier.

python
from moss_partner_sdk import verify_webhook_signature

# In your webhook handler (e.g. Flask/FastAPI):
is_valid = verify_webhook_signature(
    payload=request.body,                          # raw bytes
    signature=request.headers["X-MOSS-Signature"], # "sha256="
    secret="your-shared-secret",
    timestamp=request.headers["X-MOSS-Timestamp"],
)
if not is_valid:
    return ("invalid signature", 401)

Idempotency

Pass an idempotency_key on create, promote, suspend, reactivate, and session calls for replay-safe writes.

python
customer = await moss.customers.create(
    external_id="acme_123",
    name="Acme Corp",
    idempotency_key="acme_creation_2026_08_20",
)

Errors

API errors raise typed exceptions carrying the machine-readable error code, a human message, and a request_id for support. See the error reference for the full list of codes.