Python SDK
Full Python SDK reference with service namespaces
Python SDK
The Python SDK mirrors every method in the TypeScript SDK with Pythonic naming conventions. It uses httpx for HTTP with retry, timeout, and circuit breaker support.
pip install platformxe
from platformxe import PlatformXeClient
client = PlatformXeClient(api_key="pxk_live_your_key_here")
Service namespaces
The client exposes 10 service namespaces with 104 methods total.
client.permissions
Authorization (permission checks, roles, policies, relationships, overrides, federation and audit) is documented in the Permissions SDK reference (access on request), available on request.
client.identity
Country-pluggable identity resolution + per-kind verifications across NG / KE / GH / ZA. The engine dispatches through the right per-country provider chain based on the identifier kind.
# Resolve identity (BVN, NIN, phone, etc.)
# purpose is required (keyword-only, 1.12.0); the key must name identity:resolve.
profile = client.identity.resolve(
"BVN",
"22012345678",
purpose="tenant onboarding",
consent_reference="ref_123",
resolve_linked=True, # default False; each linked lookup a provider answers is billed
)
print(profile["outcome"]) # "found" | "not_found" | "provider_down"
# Generic verify (cross-country)
result = client.identity.verify(
type="NIN",
value="12345678901",
first_name="Adaeze",
last_name="Okafor",
)
# Per-kind verifications (Phase 6F)
bvn = client.identity.verify_bvn(
subject_id="usr_001", bvn="22012345678",
first_name="Adaeze", last_name="Okafor",
)
nin = client.identity.verify_nin(
subject_id="usr_001", nin="12345678901",
first_name="Adaeze", last_name="Okafor",
)
acct = client.identity.verify_account(
subject_id="usr_001",
account_number="0123456789", bank_code="058",
first_name="Adaeze", last_name="Okafor",
)
live = client.identity.liveness(
subject_id="usr_001",
image_url="https://example.com/selfie.jpg",
)
face = client.identity.face_match(
subject_id="usr_001",
selfie_url="https://example.com/selfie.jpg",
reference_url="https://example.com/id-photo.jpg",
)
# Provider health rollup (Phase 6F.5) — per-(country, provider)
# circuit-breaker state + latency p50/p95/p99
health = client.identity.providers_health()
# Dead-letter queue (Phase 6F.5b)
dlq = client.identity.dlq.list(unreplayed_only=True)
stats = client.identity.dlq.stats()
row = client.identity.dlq.get("idlq_123")
replay = client.identity.dlq.replay("idlq_123")
client.messaging (7 methods)
Transactional email and (coming soon) SMS/WhatsApp.
# Send email
# (from_ is required and keyword-only; reply_to is a string or a list of 1 to 5)
result = client.messaging.send_email(
to="user@example.com",
subject="Order Confirmation",
html="<h1>Order #1234 confirmed</h1>",
reply_to="support@example.com",
from_="Your App <hello@yourapp.com>",
)
# Send email to multiple recipients
result = client.messaging.send_email(
to=["alice@example.com", "bob@example.com"],
subject="Team Update",
html="<p>New release deployed.</p>",
from_="Your App <hello@yourapp.com>",
)
# Email provider health and the retry queue
health = client.messaging.email_health()
stats = client.messaging.queue_stats()
# Send SMS (coming soon)
# result = client.messaging.send_sms(to="+2348012345678", body="Your OTP is 123456")
# Send WhatsApp (coming soon)
# result = client.messaging.send_whatsapp(to="+2348012345678", template="order_update", params={"order_id": "1234"})
client.webhooks (10 methods)
Manage outbound webhook endpoints, dispatch to one recipient (v2) and read the delivery log. See Webhooks for the rules.
# Create a v2 recipient endpoint. The secret is returned ONCE.
created = client.webhooks.create(
name="Host 1",
url="https://host-1.example.com/hooks",
events=["booking.created"],
engine_version=2,
recipient_ref="host:1",
)
print(created["webhook"]["id"], created["secret"])
# List: untargeted endpoints, or one recipient's (limit / page of 0 = server default)
page = client.webhooks.list()
hosts = client.webhooks.list(recipient_ref="host:1", limit=50)
webhook = client.webhooks.get("wh_abc123")
client.webhooks.update("wh_abc123", status="PAUSED")
client.webhooks.delete("wh_abc123")
rotated = client.webhooks.rotate_secret("wh_abc123") # rotated["secret"], once
result = client.webhooks.test("wh_abc123")
# Dispatch one event to one recipient (scope webhooks:dispatch); data=None is sent as {}
sent = client.webhooks.dispatch(
"host:1", "booking.created", "evt_2026_10_20_0001", {"bookingId": "b_123"},
idempotency_key="booking-b_123-created",
)
# Delivery log and redelivery
log = client.webhooks.deliveries("wh_abc123", limit=20)
attempt = client.webhooks.redeliver(log["items"][0]["id"])
client.templates (7 methods)
Manage reusable content templates.
# Create template
template = client.templates.create(
name="welcome-email",
subject="Welcome to {{company}}",
html="<h1>Welcome, {{name}}!</h1>",
variables=["company", "name"],
)
# List templates
templates = client.templates.list()
# Get template
template = client.templates.get(template_id="tmpl_abc123")
# Update template
client.templates.update(template_id="tmpl_abc123", subject="Updated Subject")
# Delete template
client.templates.delete(template_id="tmpl_abc123")
# Render template (preview)
rendered = client.templates.render(
template_id="tmpl_abc123",
variables={"company": "Acme", "name": "Jane"},
)
# List template versions
versions = client.templates.list_versions(template_id="tmpl_abc123")
client.storage (10 methods)
File upload, retrieval, and management via multi-provider storage.
# Upload file
file = client.storage.upload(
file=open("invoice.pdf", "rb"),
filename="invoice.pdf",
folder="invoices",
access="private",
)
# Upload from URL
file = client.storage.upload_from_url(
url="https://example.com/image.png",
filename="image.png",
folder="images",
)
# Get file metadata
meta = client.storage.get(file_id="file_abc123")
# List files
files = client.storage.list(folder="invoices", limit=20)
# Delete file
client.storage.delete(file_id="file_abc123")
# Get signed URL (temporary access)
url = client.storage.get_signed_url(file_id="file_abc123", expires_in=3600)
# Update file metadata
client.storage.update(file_id="file_abc123", folder="archive")
# Copy file
copy = client.storage.copy(file_id="file_abc123", folder="backup")
# Move file
client.storage.move(file_id="file_abc123", folder="processed")
# Get storage usage
usage = client.storage.get_usage()
client.workflows (6 methods)
Event-driven workflow automation.
# Create workflow
workflow = client.workflows.create(
name="New User Onboarding",
trigger={"event": "user.created"},
actions=[
{"type": "send_email", "template_id": "tmpl_welcome"},
{"type": "webhook", "url": "https://example.com/onboard"},
],
)
# List workflows
workflows = client.workflows.list()
# Get workflow
workflow = client.workflows.get(workflow_id="wf_abc123")
# Update workflow
client.workflows.update(workflow_id="wf_abc123", name="Updated Onboarding")
# Delete workflow
client.workflows.delete(workflow_id="wf_abc123")
# Trigger workflow manually
client.workflows.trigger(workflow_id="wf_abc123", payload={"user_id": "usr_123"})
client.domains (5 methods)
Manage sending domains for email delivery.
# Add sending domain
domain = client.domains.create(domain="mail.example.com")
# List domains
domains = client.domains.list()
# Get domain (includes DNS records)
domain = client.domains.get(domain_id="dom_abc123")
# Verify domain
result = client.domains.verify(domain_id="dom_abc123")
# Delete domain
client.domains.delete(domain_id="dom_abc123")
client.subscriptions (8 methods)
Manage event subscriptions for real-time notifications.
# Create subscription
sub = client.subscriptions.create(
event="email.sent",
url="https://example.com/events",
)
# List subscriptions
subs = client.subscriptions.list()
# Get subscription
sub = client.subscriptions.get(subscription_id="sub_abc123")
# Update subscription
client.subscriptions.update(subscription_id="sub_abc123", url="https://example.com/events/v2")
# Delete subscription
client.subscriptions.delete(subscription_id="sub_abc123")
# Pause subscription
client.subscriptions.pause(subscription_id="sub_abc123")
# Resume subscription
client.subscriptions.resume(subscription_id="sub_abc123")
# List subscription deliveries
deliveries = client.subscriptions.list_deliveries(subscription_id="sub_abc123")
client.misc (7 methods)
Utility and account-level operations.
# Health check
health = client.misc.health()
# Get API key info
info = client.misc.get_api_key_info()
# Get organization details
org = client.misc.get_organization()
# Get usage summary
usage = client.misc.get_usage(period="2026-03")
# Generate PDF from HTML
pdf = client.misc.generate_pdf(
html="<h1>Invoice #1234</h1><p>Total: ₦50,000</p>",
options={"format": "A4", "margin": "20mm"},
)
# OCR - extract text from image
text = client.misc.ocr(file_id="file_abc123")
# Verify identity document
result = client.misc.verify_document(
file_id="file_abc123",
document_type="national_id",
)
client.fraud
Fraud Detection (decisions, rules, screening, devices, cases and terms) is documented in the Fraud Detection SDK reference (access on request), available on request.
client.audit (1 method)
Federated audit log dispatch. See the Audit reference.
client.audit.log(
app="lettings",
actor_id="user_123",
entity_type="BOOKING",
entity_id="bk_abc",
action="CONFIRMED",
metadata={"propertyId": "prop_xyz"},
)
client.issues (2 methods)
Federated bug / support-ticket workflow. See the Issues reference.
issues = client.issues.list(app="lettings", status="OPEN")
created = client.issues.create(
app="lettings",
reporter_id="user_123",
title="Booking confirmation email shows wrong nights",
description="Booked 3 nights, email says 2.",
priority="HIGH",
)
A plan-change request (app="PX", tag plan-change) needs metadata={"requestedPlan": "BASIC" | "PRO" | "ENTERPRISE"} (otherwise HTTP 400 VALIDATION_ERROR) and is refused with HTTP 409 CONFLICT while one of your organisation's is still open. "PRO" and "ENTERPRISE" come with an Enterprise License: the request goes to the licensing team and raises PlatformXeAPIError with code == "CONTACT_LICENSING" (status 409; details {email, id, existing}, existing True when an open licensing request was answered and nothing was filed). See Request a plan change.
client.search (2 methods)
Federated search index + query. See the Search reference.
client.search.index(
app="lettings",
entity_type="PROPERTY",
entity_id="prop_abc",
title="Lekki Penthouse",
keywords="lekki lagos penthouse 3 bedroom",
)
results = client.search.query(q="lekki", app="lettings")
client.whoami (1 method)
API key verification + boot-time self-check. See the Whoami reference.
me = client.whoami.get()
print(f"Authenticated as {me['callerService']} ({me['organizationId']})")
if me.get("gracePeriodWarning"):
print(me["gracePeriodWarning"])
platformxe.register (module-level)
Unauthenticated bootstrap for new developers. Sits at the package root because it runs before you have an API key.
from platformxe import register, PlatformXeClient
r = register(name="Acme", email="dev@acme.test")
client = PlatformXeClient(api_key=r["apiKey"])
# Save r["apiKey"] — it cannot be retrieved again.
Error handling
from platformxe import PlatformXeAPIError, PlatformXeClient, PlatformXeError
# fail_open=False: a request that gets no answer raises PlatformXeError.
# The default (fail_open=True) raises nothing for it: the call returns
# {"error": ..., "_failed": True}, which you must check yourself.
client = PlatformXeClient(api_key="pxk_live_...", fail_open=False)
try:
client.messaging.send_email(to="user@example.com", subject="Test", html="<p>Hi</p>", from_="Your App <hello@yourapp.com>")
except PlatformXeAPIError as e:
# Every error answer: e.code, e.message, e.status_code, e.retry_after (the Retry-After header, or None)
if e.retry_after is not None:
# 429 (RATE_LIMITED, EMAIL_RATE_LIMITED) and some 503s: the client does not
# send the request again; wait this long before you do.
print(f"{e.code}. Send again after {e.retry_after}s")
else:
print(f"Error {e.code}: {e.message}")
except PlatformXeError as e:
# No answer (network failure, timeout) after the client's retries
print(f"Request failed: {e}")
With the default client, check the result instead of catching PlatformXeError:
result = client.messaging.send_email(to="user@example.com", subject="Test", html="<p>Hi</p>", from_="Your App <hello@yourapp.com>")
if result.get("_failed"):
print(f"Request failed: {result['error']}")
See Error Handling for the full list of error codes.