SupportHub Python SDK
Official Python SDK for the SupportHub REST API.
It provides ergonomic synchronous and asynchronous clients, fully typed pydantic v2 response models, and a high-level long-polling helper for real-time updates.
- API base URL (default):
https://supporthub.cc/api/v1— passbase_urlfor another instance (the formerhttps://api.support.forestsnet.com/api/v1keeps working) - Auth:
Authorization: Bearer sk_...— create a key in SupportHub under Settings → API keys (shown once) - Full API docs: https://supporthub.cc/docs/api-guide (English: https://supporthub.cc/en/docs/api-guide)
Installation
With Poetry:
poetry add supporthub-sdk
With pip:
pip install supporthub-sdk
Requires Python 3.10+.
Quick start
Synchronous
from supporthub import Client
with Client(api_key="sk_...") as client:
page = client.tickets.list(status="open", page=1)
for ticket in page.items:
print(ticket.id, ticket.subject, ticket.status)
ticket = client.tickets.create(
contact={"email": "alice@example.com", "name": "Alice"},
subject="Cannot log in",
message="I get a 500 error when logging in.",
priority="high",
)
client.messages.send(ticket_id=ticket.id, content="Thanks, looking into it!")
client.tickets.close(ticket.id)
Asynchronous
import asyncio
from supporthub import AsyncClient
async def main():
async with AsyncClient(api_key="sk_...") as client:
page = await client.tickets.list(status="open")
for t in page.items:
print(t.id, t.subject)
asyncio.run(main())
Configuration
Client(
api_key="sk_...",
base_url="https://supporthub.cc/api/v1", # optional
timeout=30.0, # optional
)
You can also inject your own httpx.Client / httpx.AsyncClient via http_client= if you need custom transports, proxies, retries, etc.
Resources
Both clients expose the same resource attributes: client.tickets, client.messages, client.contacts, client.updates, client.webhooks, client.media, client.kb and client.workspace.
Tickets
page = client.tickets.list(status="open", priority="high", page=1, page_size=20)
detail = client.tickets.get("ticket-uuid", last_messages=50)
ticket = client.tickets.create(
contact={"email": "user@example.com"},
subject="Help",
message="Initial message",
priority="normal",
tags=["billing"],
)
ticket = client.tickets.update("ticket-uuid", status="resolved")
ticket = client.tickets.close("ticket-uuid")
ticket = client.tickets.reopen("ticket-uuid")
# A contact's past tickets (closed by default), with message previews
history = client.tickets.history("contact-uuid", status="closed", page=1)
Messages
page = client.messages.list(ticket_id="ticket-uuid", page=1, page_size=50)
msg = client.messages.send(ticket_id="ticket-uuid", content="Hello!", is_internal=False)
msg = client.messages.edit(msg.id, "Hello again!")
# Inbound from an external source (creates/finds contact and ticket automatically):
result = client.messages.create_inbound(
contact={"email": "user@example.com", "name": "Alice"},
message="Hi, I have a question",
session_id="sess-abc",
)
create_inbound() is text only: the inbound endpoint takes no attachments, so passing media_ids raises TypeError. Files go into a ticket with messages.send(ticket_id=..., media_ids=[...]), sent as the bot.
Contacts
contacts = client.contacts.list(search="alice", page=1)
contact = client.contacts.get("contact-uuid")
contact = client.contacts.upsert(
email="alice@example.com",
full_name="Alice Smith",
)
Updates (long polling)
Telegram-style long polling. The server holds the connection open until new events arrive or timeout seconds pass.
Update ids are UTC timestamps in microseconds. Start from the current time; offset=0 replays the project's whole history.
import time
offset = int(time.time() * 1_000_000)
while True:
updates = client.updates.poll(
offset=offset,
timeout=25,
types=["ticket.created", "message.created"],
)
for u in updates:
print(u.type, u.data)
offset = max(offset, u.id)
The async client provides a higher-level streaming helper that tracks the offset internally and yields events as they arrive. Network errors, 5xx and 429 responses are retried (after backoff seconds, or the server's Retry-After); an invalid or revoked key raises AuthError:
async with AsyncClient(api_key="sk_...") as client:
now = int(time.time() * 1_000_000)
async for update in client.updates.stream(offset=now, types=["message.created"]):
print(update.type, update.data)
Webhooks
webhooks = client.webhooks.list()
wh = client.webhooks.create(
url="https://example.com/hooks/supporthub",
events=["ticket.created", "message.created"],
description="Production ingestion",
)
print(wh.secret) # only returned once, on creation
client.webhooks.delete(wh.id)
The API can also update and test webhooks (PATCH /webhooks/{id}, POST /webhooks/{id}/test); the SDK covers list, create and delete.
Every delivery is signed: X-Webhook-Signature: sha256=<hex> is an HMAC-SHA256 of the raw request body with the webhook secret; X-Webhook-Event, X-Webhook-Id and X-Webhook-Attempt come along. Failed deliveries are retried six times (immediately, 30 s, 2 min, 10 min, 1 h, 6 h).
import hashlib, hmac
def is_valid(secret: str, body: bytes, header: str) -> bool:
expected = "sha256=" + hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header)
Knowledge base
categories = client.kb.list_categories()
page = client.kb.list_articles(category_id=categories[0].id, page=1)
found = client.kb.search("dns")
article = client.kb.get_article(found.items[0].id)
The knowledge base endpoints follow the project's plan; without the knowledge base feature they return an error.
Workspace
settings = client.workspace.get_settings()
secret = client.workspace.get_widget_signing_secret() # signs widget visitor tokens
Media
Upload, attach to a message, and download files:
# Upload (path, bytes, or file-like)
media = client.media.upload("./photo.jpg")
# Attach to an outbound message
client.messages.send(
ticket_id=ticket.id,
content="See attached",
media_ids=[media.id],
)
# Download the raw bytes
blob = client.media.download(media.id)
with open("out.jpg", "wb") as f:
f.write(blob)
Messages come back with a media array of MediaFile items:
detail = client.tickets.get(ticket.id)
for m in detail.messages:
for mf in m.media:
print(mf.id, mf.url, mf.mime_type, mf.file_type)
Ticket ratings
client.tickets.rate(ticket_id, 5, comment="Отлично!")
Long polling vs webhooks
- Webhooks are best for production servers with a public HTTPS endpoint. SupportHub will POST events to your URL and sign them with your webhook secret.
- Long polling (
/updates) is great for development, prototyping, workers behind NAT, or any environment without a public callback URL. UseAsyncClient.updates.stream(...)for an async iterator that handles offset tracking and reconnection for you.
Error handling
All HTTP errors raise subclasses of supporthub.APIError:
| Status | Exception |
|---|---|
| 400 | ValidationError |
| 401 | AuthError |
| 403 | PermissionError |
| 404 | NotFoundError |
| 422 | ValidationError |
| 429 | RateLimitError |
| 5xx | ServerError |
Each exception exposes:
.status_code— HTTP status.error_code— backenderror_codeif present.message— human-readable message.detail— rawdetailpayload from the API
from supporthub import Client, RateLimitError, AuthError, APIError
try:
client.tickets.list()
except AuthError:
print("Bad API key")
except RateLimitError as e:
print("Slow down, retry after", e.retry_after)
except APIError as e:
print("API error:", e.status_code, e.message)
Models
All responses are parsed into pydantic v2 models with extra="allow" so unknown future fields will not break your code. Common types:
Ticket,TicketDetail,TicketStatus,TicketPriorityMessage,SenderTypeContactUpdate,UpdatesResponseWebhook,InboundMessageResult,MediaFileKBCategory,KBArticle,PaginatedKBArticlesWorkspaceSettingsPaginatedTickets,PaginatedMessages,PaginatedContacts
Use model.model_dump() to get a plain dict.
Development
cd sdks/python
poetry install
poetry run pytest
poetry run ruff check .
License
MIT — the SDK is one of the open parts of the SupportHub repository.
Metadata
Release files for supporthub-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 |
|---|---|---|---|---|
| supporthub_sdk-0.7.0.tar.gz | 14.7 kB | With provenance | Details for supporthub_sdk-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| supporthub_sdk-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for supporthub_sdk-0.7.0-py3-none-any.whl |
Total release size: 31.2 kB
Release files / supporthub_sdk-0.7.0.tar.gz
| Download URL | supporthub_sdk-0.7.0.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
506dd4158f91de4cdf59a0e7f33c925a1c3b3d8b66fb0a49c52bf3f42cd97319
|
|
BLAKE2b-256 checksum How to use checksums |
229be14f5cb44af39b0520e559ced8a6e9ddfe6dc097d99ced72bd5846b9be65
|
| 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 4, 2026.
Transparency logRelease files / supporthub_sdk-0.7.0-py3-none-any.whl
| Download URL | supporthub_sdk-0.7.0-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccb6c1154ec9d6d638cffb0942b955de269b1e8844a32b62957cdbeb24f737c5
|
|
BLAKE2b-256 checksum How to use checksums |
fdcf9882a3afc7c129ace42e111002fcc207fc0d1edb0d1ded457b7d999f6a0f
|
| 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 4, 2026.
Transparency logSecurity for supporthub-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 supporthub_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 4, 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.