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 emptyEntitlementSet(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/vellumendpoint (mirrorsapi/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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e26738bcb803a8a9b402d78ca72d23ee9799d14f956845a238eb9a427ddbd4
|
|
| MD5 |
86eb4112f4e5c758fddcc46b5f2ad00a
|
|
| BLAKE2b-256 |
b5cf44a91a3b006e43a0bef7a31ff7a364d6e7c79759972f8ab56ef2a4425db0
|
Provenance
The following attestation bundles were made for vellumcharter-0.1.0.tar.gz:
Publisher:
publish.yml on tdesposito/VellumCharter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vellumcharter-0.1.0.tar.gz -
Subject digest:
92e26738bcb803a8a9b402d78ca72d23ee9799d14f956845a238eb9a427ddbd4 - Sigstore transparency entry: 1829991250
- Sigstore integration time:
-
Permalink:
tdesposito/VellumCharter@2ada8ce1ef75cec2d9cd78e7f102a6675a9d33c4 -
Branch / Tag:
refs/tags/sdks-python-v0.1.0 - Owner: https://github.com/tdesposito
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ada8ce1ef75cec2d9cd78e7f102a6675a9d33c4 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38093dc145baf4a0d66840ff902eb8b81750745eba3c928ac057ac7dcacd8ef5
|
|
| MD5 |
94816edd90c5ed453ecf65971ef07507
|
|
| BLAKE2b-256 |
f0554ae32036367ab7ad5639980e75fea310950f53fbc9365341936f07627435
|
Provenance
The following attestation bundles were made for vellumcharter-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on tdesposito/VellumCharter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vellumcharter-0.1.0-py3-none-any.whl -
Subject digest:
38093dc145baf4a0d66840ff902eb8b81750745eba3c928ac057ac7dcacd8ef5 - Sigstore transparency entry: 1829991708
- Sigstore integration time:
-
Permalink:
tdesposito/VellumCharter@2ada8ce1ef75cec2d9cd78e7f102a6675a9d33c4 -
Branch / Tag:
refs/tags/sdks-python-v0.1.0 - Owner: https://github.com/tdesposito
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ada8ce1ef75cec2d9cd78e7f102a6675a9d33c4 -
Trigger Event:
push
-
Statement type: