Skip to main content

Billing & Entitlements

Flux Billing connects your product’s plans and features to Stripe subscriptions — and exposes a simple entitlements API so your code never has to query Stripe directly.

Creating Plans

Plans are defined in the Billing dashboard. Each plan has a name, a Stripe price ID, and a set of entitlements. Entitlements are named capabilities (e.g. api-access, sso, audit-logs) or numeric limits (e.g. seats, api-calls-per-month).

Connecting to Stripe

Link your Stripe account from the Billing settings page. Flux syncs subscription state in real time via Stripe webhooks — no polling required.

Once connected, Flux automatically provisions entitlements when a subscription is created, updated, or cancelled.

Checking Entitlements

Check whether an organization has a named entitlement:

use flux_sdk::Flux;

let flux = Flux::init("your-api-key");

if flux.billing().is_entitled(&org.id, "sso")? {
    // Enable SSO configuration UI
}

Check a numeric limit:

let limit = flux.billing().get_limit(&org.id, "seats")?;

if current_member_count < limit.value {
    // Allow adding another member
} else {
    // Show upgrade prompt
}

Python

import flux

flux.init("your-api-key")

if flux.billing.is_entitled(org.id, "sso"):
    # Enable SSO configuration UI
    pass

limit = flux.billing.get_limit(org.id, "seats")
if current_member_count < limit.value:
    # Allow adding another member
    pass

Usage Metering

For consumption-based features, record usage events and let Flux aggregate them for Stripe billing.

flux.billing().record_usage(flux_sdk::UsageEvent {
    org_id: org.id.clone(),
    metric: "api-calls".into(),
    quantity: 1,
})?;

Flux batches and forwards usage to Stripe Billing’s usage records API. You can also query current-period usage from the SDK:

let usage = flux.billing().get_usage(&org.id, "api-calls")?;
println!("Used {} API calls this period", usage.quantity);

Entitlement Caching

Entitlement checks are evaluated locally against a cached snapshot that Flux keeps fresh via a background sync. Cold-path latency is under 1 ms for boolean entitlements — no network hop required.

Next Steps