Webhooks SDKs
Status: published. Python, TypeScript, and Go are on their public registries at 0.8.0. Java and PHP are written and tested but not yet published — see where it stands.
Official clients for NimbusNexus Webhooks. Each one covers the same four jobs, so a team using two languages gets the same behaviour in both. Pick a language at the top of the page and every sample follows it; Set up an SDK is the short version of install, authenticate and a first call.
These are the Webhooks clients. SDKs for Infrastructure (VMs, storage, networking) are not available yet; call that API over REST. The Go samples alias the import as
nnwhto keep its provenance visible.
The highest-value piece is verify. Signature checking is security-critical, easy to get subtly wrong, and wrong in a way that passes every functional test — the SDKs implement the full contract including the constant-time comparison and the replay window.
Install
pip install nn-webhooks-sdkNo REST example here; showing Python.
Verify an incoming webhook
For anyone receiving webhooks. Pass the raw body bytes — never a re-serialized object.
from nn_webhooks import verify
ok = verify(
secret=ENDPOINT_SIGNING_SECRET,
raw_body=request.body,
signature=request.headers["X-Webhook-Signature"],
timestamp=request.headers["X-Webhook-Timestamp"],
)
if not ok:
return Response(status_code=400) # forged, tampered, or outside the 300s windowNo REST example here; showing Python.
Always pass the timestamp. Omitting it computes the signature over the body alone, which never matches what we send — so verification fails for everything, not just replays. If verify returns false for deliveries you believe are genuine, a missing timestamp is the first thing to check.
Publish an event
For producers. Transient failures — connection errors, 429, 5xx — are retried with backoff, and a 429 honours Retry-After. Other 4xx raise.
The key is minted in your NimbusNexus account console — see Getting access. A whsk_… key from before the change is refused as an unrecognised credential, and no SDK checks the key's shape, so the failure surfaces as a 403 invalid_credential from the API rather than an error at construction.
from nn_webhooks import Client, WebhooksAPIError
with Client("https://webhooks.nimbusnexus.net", api_key=WEBHOOKS_API_KEY) as wh:
try:
event = wh.publish(
"order.created",
{"order_id": "ord_123", "total": 4200},
idempotency_key="order-123", # makes the publish safe to retry
)
print(event.event_uid, event.deliveries_created)
except WebhooksAPIError as e:
print(e.status_code, e.code, e.message)No REST example here; showing Python.
Durable buffering
publish() is synchronous — if the API is unreachable it raises, and the event is gone. The write-first outbox decouples the two: enqueue() persists to a store and returns immediately with no network call, and drain() ships the backlog later.
from nn_webhooks import Client, SQLiteStore
store = SQLiteStore("outbox.db")
# Construct for the process lifetime — NOT in a `with` block. Closing the client stops the
# drainer, so a `with` that exits immediately would shut down the thread you just started.
wh = Client("https://webhooks.nimbusnexus.net", api_key=WEBHOOKS_API_KEY, store=store)
wh.start_drainer(interval_seconds=5) # ships in the background
wh.enqueue("order.created", {"order_id": "ord_123"}) # returns at once, no network
...
wh.close() # at shutdown; also stops the drainerEvery send carries Idempotency-Key = record.id, so re-draining after a crash never double-publishes. A record that keeps failing is retried with capped exponential backoff up to max_attempts (default 10), then flagged dead and handed to an optional on_dead callback.
| Store | Durable | Extra dependency |
|---|---|---|
MemoryStore | No — in-process | none |
FileStore(dir) | Yes | none |
SQLiteStore(path) | Yes, transactional | none |
RedisStore(url) | Yes | pip install 'nn-webhooks-sdk[redis]' |
PostgresStore(dsn) | Yes | pip install 'nn-webhooks-sdk[postgres]' |
No store needs a dependency beyond the SDK itself — Python's only runtime dependency is httpx — and the Redis and Postgres stores import their driver lazily, only when constructed.
Manage endpoints
The same client wraps the control plane, with an admin-scoped key:
ep = wh.create_endpoint(
"https://your-app.example/webhooks",
subscriptions=[{"match_kind": "prefix", "pattern": "order."}],
)
endpoint_id, signing_secret = ep["id"], ep["secret"] # secret returned once
wh.replace_subscriptions(endpoint_id, [ # replaces the whole set
{"match_kind": "exact", "pattern": "order.paid"},
])
wh.rotate_endpoint_secret(endpoint_id)
wh.enable_endpoint(endpoint_id) # recover an auto-disabled endpoint
for d in wh.list_deliveries(status="dead")["items"]: # drain the dead-letter queue
wh.redeliver(d["id"])List methods return {"items": [...], "next_offset": int | None}; deletes return nothing on a 204.
update_endpoint cannot change subscriptions, because webhookd ignores them on a PATCH: replace_subscriptions (replaceSubscriptions in TypeScript, ReplaceSubscriptions in Go) sets the whole list at once, and an empty list unsubscribes the endpoint from everything.
The key-management methods — create_api_key/revoke_api_key in Python, createApiKey/revokeApiKey in TypeScript, Java and PHP, CreateAPIKey/RevokeAPIKey in Go — are still on the client, but the /v1/api-keys routes they call were removed, so calling one now fails with a 404; mint keys in the account console instead.
Targeting a project
A project is addressed by id (prj_3f9a…) — there is no slug or short name. Leave project_id unset to target the workspace's default project, which is what a single-project workspace always wants:
wh.publish("order.created", {...}) # default project
wh.publish("order.created", {...}, project_id="prj_3f9a…") # a specific oneOnly the server can resolve "the default project", so omitting the field is the way to ask for it. Passing an invented string — "default", or a project's display name — is a 404. The real id is on any response, or from GET /v1/projects.
Keeping the SDKs honest
All clients implement one signing contract: HMAC-SHA256(secret, "<timestamp>." + raw_body), sent as X-Webhook-Signature: sha256=<hex> with a 300-second window. They are pinned to it by a shared vector fixture generated by the server's own signer, so no client can drift from the server or from each other — including in CI, where the server package isn't installed.
Where it stands today
| Language | Package | Status |
|---|---|---|
| Python | nn-webhooks-sdk | Published — PyPI, 0.8.0 |
| TypeScript | @nimbusnexus/webhooks-sdk | Published — npm, 0.8.0 |
| Go | github.com/NimbusNexus/webhooks-go | Published — GitHub, v0.8.0 |
| Java | net.nimbusnexus:webhooks-sdk | Written and tested; not yet on Maven Central |
| PHP | nimbusnexus/webhooks-sdk | Written and tested; not yet on Packagist |
Until Java and PHP publish, call the REST API directly — the signature page has everything needed to verify deliveries in any language, and it is about twenty lines.
What's next
- CLI — the same operations from a shell.
- Signature verification — what
verifyimplements. - Quickstart — the flow these clients wrap.
- Idempotency — the platform-wide pattern behind
idempotency_key.