Skip to main content

Python SDK

Python 3.9+. Zero runtime dependencies.

Initialize + verify

HTTP under the hood:

Verify response (JSON)

keverd.verify() returns a dict matching POST /v2/verify:

FastAPI

Client → your API (JSON body):

Webhooks

Inbound body is the webhook envelope (JSON). Verify signature on raw bytes first.

Errors

All SDK failures subclass KeverdError. Catch the specific type when you need different handling.

KeverdError

Base exception for client-side failures before a successful API response, or when the request never completes. Raised when
  • Missing config (e.g. no secret_key)
  • Invalid arguments (e.g. empty event_id)
  • Network failures
  • Request timeouts
Attributes: args / message, code (str | None), status_code (int | None)

KeverdAPIError

Raised when the API returns a non-2xx HTTP status. Subclasses KeverdError. Raised when
  • Auth fails (401 / 403)
  • Bad request (400)
  • Quota exceeded (402)
  • Server errors (5xx)
Attributes: status_code, code, body (parsed JSON when available)

KeverdSignatureError

Raised by keverd.webhooks.construct_event(...) when webhook signature verification fails. Subclasses KeverdError with code="invalid_signature". Raised when
  • Missing X-Keverd-Signature or webhook secret
  • Malformed signature header
  • Timestamp outside the 300s tolerance
  • HMAC mismatch (wrong secret, or body was parsed/modified before verify)
  • Payload is not valid JSON
Treat these as untrusted requests — return 400 and do not process the event. See Webhooks.