Skip to main content

Thin, dependency-free server-side client for the Vellum entitlements + billing API

Project description

vellumcharter (Python SDK)

A thin, dependency-free (stdlib urllib + hmac) server-side client for the Vellum entitlements + billing API. The Python counterpart to sdks/js/ (TypeScript); built for Python consumers such as SAM2-SalesImport. Server-side only — it holds a secret API key.

from vellumcharter import VellumClient, verify_push_signature

vellum = VellumClient(
    api_key="vlm_sam.xxxxx",   # from SSM, never shipped to a browser
    tenant_id="sam",
    # base_url defaults to https://api.vellumcharter.com; override for tests/staging.
)

# Gate a feature (pull-first; cached with a short TTL):
if vellum.can("unit_1", "imports"):
    ...

ent = vellum.get_entitlements("unit_1")
ent.is_active()            # True for active/trialing
ent.has("imports")
ent.config("trial_days")
ent.found                  # False if the customer has no record (no exception)

Async

AsyncVellumClient is the awaitable counterpart — same constructor and methods, each await-ed. It wraps the sync client on a worker thread (asyncio.to_thread), so the SDK stays dependency-free. Use it from async frameworks (e.g. FastAPI):

from vellumcharter import AsyncVellumClient

vellum = AsyncVellumClient(api_key="vlm_sam.xxxxx", tenant_id="sam")

if await vellum.can("unit_1", "imports"):
    ...

ent = await vellum.get_entitlements("unit_1")
vellum.invalidate("unit_1")   # cache op is synchronous (no await)

It is "async-compatible" (each call runs in a worker thread), not single-socket async IO — the right trade-off for server-side entitlement checks while keeping zero dependencies.

What it covers

  • Entitlements: get_entitlements, can, opt-in TTL cache + invalidate. A 404 returns an empty EntitlementSet (no exception), so gating never needs a null check.
  • Checkout / subscriptions: create_checkout, create_setup_checkout (payment method, no charge), create_subscription (server-side trial), cancel_subscription, get_subscription.
  • Provisioning: create_account (adopt or create the Stripe customer), create_customer, set_account_status, set_customer_status.
  • Billing facade: list_payment_methods, set_default_payment_method, remove_payment_method, set_subscription_payment_method, list_invoices, invoice_pdf_url (returns Stripe's hosted PDF URL).
  • Push verification: verify_push_signature(raw_body, header, secret) for the consumer's /webhooks/vellum endpoint (mirrors api/src/lib/notify.ts).

VellumAuthError is raised on 401/403; VellumApiError (with .status/.body) on other non-2xx; VellumSignatureError on a bad push signature.

Auth & errors

The API key is sent as x-api-key on every request. Keep it server-side.

Requirements & tooling

Python 3.11+ (3.9/3.10 are end-of-life). Managed with uv:

uv sync                                   # create the venv (pinned to 3.11 via .python-version)
uv run python -m unittest discover -s tests

The SDK itself has no third-party dependencies — uv is just for the dev/test environment and interpreter pinning.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vellumcharter-0.1.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vellumcharter-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file vellumcharter-0.1.0.tar.gz.

File metadata

  • Download URL: vellumcharter-0.1.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vellumcharter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 92e26738bcb803a8a9b402d78ca72d23ee9799d14f956845a238eb9a427ddbd4
MD5 86eb4112f4e5c758fddcc46b5f2ad00a
BLAKE2b-256 b5cf44a91a3b006e43a0bef7a31ff7a364d6e7c79759972f8ab56ef2a4425db0

See more details on using hashes here.

Provenance

The following attestation bundles were made for vellumcharter-0.1.0.tar.gz:

Publisher: publish.yml on tdesposito/VellumCharter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vellumcharter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vellumcharter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vellumcharter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 38093dc145baf4a0d66840ff902eb8b81750745eba3c928ac057ac7dcacd8ef5
MD5 94816edd90c5ed453ecf65971ef07507
BLAKE2b-256 f0554ae32036367ab7ad5639980e75fea310950f53fbc9365341936f07627435

See more details on using hashes here.

Provenance

The following attestation bundles were made for vellumcharter-0.1.0-py3-none-any.whl:

Publisher: publish.yml on tdesposito/VellumCharter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page