Skip to main content

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

Project description

vellumcharter

Thin, dependency-free (stdlib-only) server-side client for the VellumCharter entitlements + billing API. Server-side only — it holds a secret API key.

Install

pip install vellumcharter

Requires Python 3.11+.

Usage

from vellumcharter import VellumCharterClient

vellum = VellumCharterClient(
    api_key="vlm_sam.xxxxx",   # keep server-side, never ship to a browser
    tenant_id="sam",
    # base_url defaults to https://api.vellumcharter.com
)

# Gate a feature (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)

A 404 returns an empty EntitlementSet (no exception), so gating never needs a null check.

Async

AsyncVellumCharterClient is the awaitable counterpart — same constructor and methods, each await-ed. Use it from async frameworks (e.g. FastAPI):

from vellumcharter import AsyncVellumCharterClient

vellum = AsyncVellumCharterClient(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)

What it covers

  • Entitlements: get_entitlements, can, opt-in TTL cache + invalidate.
  • Checkout / subscriptions: create_checkout, create_setup_checkout, create_subscription, cancel_subscription, get_subscription.
  • Provisioning: create_account, create_customer, set_account_status, set_customer_status.
  • Billing: list_payment_methods, set_default_payment_method, remove_payment_method, set_subscription_payment_method, list_invoices, invoice_pdf_url.
  • Webhook verification: verify_push_signature(raw_body, header, secret) — validates a push and returns the parsed event (raises on a bad signature).

Billing reads return dicts in the server's camelCase shape:

  • get_subscriptionid, status, cancelAtPeriodEnd, seats, amount (per-seat price, cents), currency, interval (month/year), currentPeriodStart, currentPeriodEnd, trialEnd, canceledAt, defaultPaymentMethod (all timestamps ISO 8601).
  • list_payment_methods → items of id, brand, last4, expMonth, expYear, name (cardholder), isDefault.
  • list_invoices → items of id, number, status, amountDue, amountPaid, subtotal, total, tax, paid, currency, created (ISO), hostedInvoiceUrl, invoicePdf.

payment.* push events additionally carry seats and an invoice block (id, number, status, amountDue, amountPaid, currency, hostedInvoiceUrl, invoicePdf) so a dunning notice needs no follow-up read.

Errors

VellumCharterAuthError on 401/403; VellumCharterApiError (with .status / .body) on other non-2xx; VellumCharterSignatureError on a bad push signature. The API key is sent as x-api-key on every request.

API reference

Full endpoint + webhook contract: https://api.vellumcharter.com/openapi.json

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.7.1.tar.gz (10.7 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.7.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for vellumcharter-0.7.1.tar.gz
Algorithm Hash digest
SHA256 169014fe058dbb535266d20976616f84f0fbbe263d4f77d0640f1b12dbc12acd
MD5 3f0d0aa7ec3a387627444cf61b6a32fd
BLAKE2b-256 edf2c272dfd0278b4e1c00202b4ba03d69d04c7af4e2d6e043b589b4faeb2867

See more details on using hashes here.

Provenance

The following attestation bundles were made for vellumcharter-0.7.1.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.7.1-py3-none-any.whl.

File metadata

  • Download URL: vellumcharter-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ebaa114e977d5dd35a0c99aa41a70d8a31683f726614ce43a9e96449996fc64
MD5 fbb3f22a00c54e0fd7da9af0fe1926bf
BLAKE2b-256 10137708bf2602ff1ae53806cecd60fae085a87549959e3855db1184d7a3aa84

See more details on using hashes here.

Provenance

The following attestation bundles were made for vellumcharter-0.7.1-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