SDK — Billing

The rivano.billing resource gives you programmatic access to plan information, usage limits, and Stripe checkout flows — useful for building upgrade prompts or usage dashboards in your own tooling.

Billing status

Returns the current plan, usage, and limits for the tenant:

import Rivano from '@rivano/sdk';

const rivano = new Rivano({ apiKey: 'rv_...' });

const status = await rivano.billing.status();

console.log('Plan:', status.plan);
console.log('Subscription:', status.stripeSubscriptionId ?? 'none');
console.log('Trial ends:', status.trialEndsAt ?? 'not on trial');

console.log('Usage:');
console.log('  Traces this month:', status.usage.tracesThisMonth);
console.log('  Agents:', status.usage.agents);

console.log('Limits:');
console.log('  Max traces/month:', status.limits.tracesPerMonth);
console.log('  Max agents:', status.limits.agents);

Status response fields

FieldTypeDescription
planstringCurrent plan: free, pro, team, enterprise
stripeSubscriptionIdstring | nullStripe subscription ID (null if no subscription)
trialEndsAtstring | nullISO 8601 trial expiry date, or null
usage.tracesThisMonthnumberTraces consumed in the current billing period
usage.agentsnumberActive agent count
limits.tracesPerMonthnumberMonthly trace cap for current plan
limits.agentsnumberMaximum active agents for current plan

Create a checkout session

Generates a Stripe-hosted checkout URL to upgrade the tenant to a paid plan:

import Rivano from '@rivano/sdk';

const rivano = new Rivano({ apiKey: 'rv_...' });

const { url } = await rivano.billing.createCheckout('pro');

// Redirect the user to complete payment
console.log('Checkout URL:', url);
// e.g. window.location.href = url;

Available plans for createCheckout: pro, team, enterprise.

Create a billing portal session

Generates a Stripe-hosted customer portal URL where the tenant can manage their subscription, invoices, and payment method:

import Rivano from '@rivano/sdk';

const rivano = new Rivano({ apiKey: 'rv_...' });

const { url } = await rivano.billing.createPortal();
console.log('Portal URL:', url);

Checkout and portal URLs expire after 24 hours. Generate them immediately before redirecting the user — do not cache them.

Error handling

ErrorWhen it occurs
SdkAuthErrorInvalid API key
SdkForbiddenErrorOnly tenant admins can access billing
SdkErrorInvalid plan name or Stripe configuration error
  • SDK Costs — Cost breakdowns and budget alerts within the current plan
  • SDK Keys — API key management