ody-sdk
Official Python SDK for the Ody REST API — contacts, conversations, SMS/MMS sending, calls and the AI agent, phone numbers, and outbound webhooks. Docs: dev.ody.co/sdks/python.
- Standard library only — no dependencies (
urllib.request,hmac,hashlib). - Python ≥ 3.9, type hints throughout.
- Auto-pagination generators, typed errors, idempotent sends, Standard-Webhooks verification and webhook event parsing built in.
Install
pip install ody-sdk
Published on PyPI since 0.6.0 (2026-11-04). To work from a checkout instead (for example to test an unreleased change):
pip install /path/to/ody-platform/sdks/python
# or for development:
pip install -e sdks/python
Quickstart
from ody import Ody, OdyError
# Keys come from Settings → Developer API. ody_test_... keys behave identically
# but message sends are simulated (no real SMS).
client = Ody("ody_live_...")
# Override the origin if you call the Cloud Run URL directly:
# client = Ody(key, base_url="https://ody-api-rtvqk5tg2a-uc.a.run.app")
# Contacts
page = client.contacts.list(q="acme", limit=50) # {"contacts": [...], "nextCursor": ...}
contact = client.contacts.create(
first_name="Ada",
last_name="Lovelace",
phone="+15125550123",
tags=["vip"],
)
# Auto-pagination: iterate every contact, following nextCursor for you.
for c in client.contacts.list_all():
print(c["id"], c["firstName"])
# Conversations
open_page = client.conversations.list(status="open")
thread = client.conversations.get(open_page["conversations"][0]["id"])
client.conversations.set_status(thread["conversation"]["id"], "done")
# Send an SMS (idempotent — safe to retry with the same key for 24h)
sent = client.messages.send(
to="+15125550123",
body="Your order shipped!",
idempotency_key="order-1042-shipped",
)
print(sent["conversationId"], sent.get("simulated", False))
# Search, calls, numbers
hits = client.messages.search("refund", limit=10)
calls = client.calls.list(limit=100)
numbers = client.numbers.list()
Error handling
Every non-2xx response raises OdyError carrying the structured body plus HTTP status:
try:
client.contacts.get("00000000-0000-0000-0000-000000000000")
except OdyError as err:
print(err.code) # "not_found", "resource_exhausted", ...
print(err.status) # 404, 429, ...
print(err.request_id) # quote this to support
if err.status == 429:
print(f"retry in {err.retry_after}s") # from Retry-After
Rate limit: 600 requests/minute per key; every response carries RateLimit-* headers and a 429 adds Retry-After (surfaced as err.retry_after).
Webhooks
Register endpoints and verify deliveries per Standard Webhooks. The signing secret (whsec_...) is returned only by create and rotate — store it immediately.
catalog = client.webhooks.event_types()
hook = client.webhooks.create(
url="https://example.com/ody-webhook",
events=["*"],
label="prod",
)
print(hook["secret"]) # whsec_... — shown once!
client.webhooks.test(hook["id"]) # signed {"type": "ping"} delivery
deliveries = client.webhooks.deliveries(hook["id"]) # debugging view
Verifying deliveries
verify_webhook_signature checks the v1,<base64 HMAC-SHA256> signature over <webhook-id>.<webhook-timestamp>.<raw body> in constant time and rejects timestamps older than 5 minutes (replay guard). Pass the raw body bytes — re-serializing parsed JSON breaks the signature.
import json
import os
from flask import Flask, request
from ody import verify_webhook_signature
app = Flask(__name__)
@app.post("/ody-webhook")
def ody_webhook():
ok = verify_webhook_signature(
os.environ["ODY_WEBHOOK_SECRET"],
request.headers, # any case-insensitive mapping works
request.get_data(), # RAW bytes, not request.json
)
if not ok:
return "", 401
event = json.loads(request.get_data())
print("verified event:", event["type"])
return "", 200
One step: parse_webhook_event
Verify and parse together. Returns the envelope dict (id, apiVersion, createdAt, type, data); raises WebhookVerificationError on a bad or stale signature or a malformed body.
from ody import parse_webhook_event, WebhookVerificationError, WEBHOOK_EVENT_TYPES, is_known_webhook_event_type
@app.post("/ody-webhook")
def ody_webhook():
try:
event = parse_webhook_event(os.environ["ODY_WEBHOOK_SECRET"], request.headers, request.get_data())
except WebhookVerificationError:
return "", 401
if event["type"] == "call.ringing":
screen_pop(event["data"]["from"], event["data"]["callerName"])
elif event["type"] in ("contact.updated", "contact.deleted"):
sync_contact(event["data"]["contactId"])
elif not is_known_webhook_event_type(event["type"]):
app.logger.info("new Ody event type %s", event["type"])
return "", 200
WEBHOOK_EVENT_TYPES is the server catalog as a tuple (kept in step by tests/events/sdkCatalogParity.test.ts in the platform repo). Every event and its data fields: dev.ody.co/webhooks/events.
API surface
| Group | Methods |
|---|---|
client.contacts |
list, list_all (generator), create, get, update, delete |
client.conversations |
list, list_all, get, set_status |
client.messages |
send (supports idempotency_key), search |
client.calls |
list, place (outbound AI call, scope calls:place) |
client.numbers |
list, search_available, buy (supports idempotency_key), connect_agent, disconnect_agent |
client.messaging |
status, register (10DLC brand + campaign), refresh |
client.agent |
get, update, publish |
client.knowledge |
get, search, list_articles, get_article, create_article, update_article, delete_article, import_website, refresh_article, create_folder, update_folder, delete_folder |
client.webhooks |
list, create, get, update, delete, rotate, test, deliveries, event_types |
Agent Phone
Provision a working AI phone line end to end — everything an agent buys or configures through the API appears in the customer's account exactly as if they did it in the app (same billing, same gates, same timeline), and a human can take over at any moment:
candidate = client.numbers.search_available(starts_with="512")[0]
client.numbers.buy(candidate["phone_number"], idempotency_key="onboard-1")
client.messaging.register(business={
"displayName": "Acme Plumbing", "email": "ops@acme.com", "vertical": "PROFESSIONAL",
"companyName": "Acme Plumbing LLC", "ein": "12-3456789",
"street": "600 Congress Ave", "city": "Austin", "state": "TX", "postalCode": "78701",
})
client.agent.update(name="Front Desk", greeting="Thanks for calling Acme!")
client.agent.publish()
client.numbers.connect_agent(candidate["phone_number"])
placed = client.calls.place(to="+15125550123")
Use an ody_test_... key to dry-run the whole flow: purchases, filings, and
calls are simulated — nothing is bought, filed, or dialed.
Knowledge hub
Everything the AI agents (and the inbox's AI suggested replies) answer from
lives in the workspace's Knowledge hub — Markdown articles in nested folders.
Articles are live the moment they are saved; published agents are updated
automatically. Scopes knowledge:read / knowledge:write.
tree = client.knowledge.get() # folders, articles, consumers
sales = client.knowledge.create_folder("Sales line")
client.knowledge.import_website("https://acme.com", folder_id=sales["id"])
client.knowledge.create_article(
title="Pricing",
content="## Hourly rate\n$120/h, first hour minimum…",
folder_id=sales["id"],
audience="selected",
consumers=["texting"] + [c["key"] for c in tree["consumers"] if c["name"] == "Sales desk"],
)
hits = client.knowledge.search("how much per hour", consumer="texting")
Development
python3 -m py_compile ody/__init__.py ody/client.py ody/webhooks.py # syntax check
python3 -m build # build sdist + wheel
Metadata
Release files for ody-sdk 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ody_sdk-0.7.0.tar.gz | 23.1 kB | With provenance | Details for ody_sdk-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ody_sdk-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for ody_sdk-0.7.0-py3-none-any.whl |
Total release size: 43.9 kB
Release files / ody_sdk-0.7.0.tar.gz
| Download URL | ody_sdk-0.7.0.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
284ca6972d674de111ee884dd75e7934948ec7e62739e6bca737671340d8323e
|
|
BLAKE2b-256 checksum How to use checksums |
3c71ee27e4065137aa92db16df0c945629d741bb98619f64f8bb3a7c923b5b6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 6, 2026.
Transparency logRelease files / ody_sdk-0.7.0-py3-none-any.whl
| Download URL | ody_sdk-0.7.0-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
794d01c4a4203674a4aabbf0d34d6ebf7521e47e0117345c58749407a088a31b
|
|
BLAKE2b-256 checksum How to use checksums |
d3594f3a7d3acb304d145b0807accfd79c126c3200e81b1e2d63a2c020a1b8e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 6, 2026.
Transparency logSecurity for ody-sdk 0.7.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ody_sdk-0.7.0.tar.gz
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 Nov 6, 2026.
Transparency logA 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.