JavaScript: Billing and usage
Read plans, subscriptions, usage, compute and invoices, and check platform health with @sovaria/sdk.
Read your organization's plan, usage and invoices from code — for dashboards, alerts or internal tools. Payment methods (checkout, payInvoice, razorpay*) are used by the console's checkout.
const usage = await sovaria.billing.getUsage(orgId)
const plan = await sovaria.billing.getSubscription(orgId)sovaria.billing
sovaria.billing.listPlans
List plans.
sovaria.billing.listPlans(): Promise<JsonValue>- Returns
Promise<JsonValue>- HTTP
GET /api/v1/plans
sovaria.billing.getPlan
Get plan.
sovaria.billing.getPlan(name: string): Promise<JsonObject>Parameters
namestringrequired
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/plans/{…}
sovaria.billing.getSubscription
Get subscription.
sovaria.billing.getSubscription(orgId: string): Promise<JsonObject>Parameters
orgIdstringrequired
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/subscriptions/{…}
sovaria.billing.setSubscription
Set subscription.
sovaria.billing.setSubscription(
orgId: string,
payload: { plan: string billingCycle?: 'monthly' | 'annual' stripeCustomerId?: string metadata?: JsonObject },
): Promise<JsonObject>Parameters
orgIdstringrequiredpayload{ plan: string billingCycle?: 'monthly' | 'annual' stripeCustomerId?: string metadata?: JsonObject }required
- Returns
Promise<JsonObject>- HTTP
PUT /api/v1/subscriptions/{…}
sovaria.billing.cancelSubscription
Cancel subscription.
sovaria.billing.cancelSubscription(
orgId: string,
options?: { immediate?: boolean } = {},
): Promise<JsonObject>Parameters
orgIdstringrequiredoptions{ immediate?: boolean }optionaldefault{}
- Returns
Promise<JsonObject>- HTTP
DELETE /api/v1/subscriptions/{…}
sovaria.billing.listSubscriptions
List subscriptions.
sovaria.billing.listSubscriptions(): Promise<JsonValue>- Returns
Promise<JsonValue>- HTTP
GET /api/v1/subscriptions
sovaria.billing.getUsage
Get usage.
sovaria.billing.getUsage(orgId: string, period?: string): Promise<JsonObject>Parameters
orgIdstringrequired- Organization id.
periodstringoptionalYYYY-MM; default the current month.
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/usage/{…}
sovaria.billing.getUsageHistory
Get usage history.
sovaria.billing.getUsageHistory(orgId: string, months?: number = 6): Promise<JsonValue>Parameters
orgIdstringrequiredmonthsnumberoptionaldefault6- How many months back.
- Returns
Promise<JsonValue>- HTTP
GET /api/v1/usage/{…}/history
sovaria.billing.listInvoices
List invoices.
sovaria.billing.listInvoices(orgId: string): Promise<JsonValue>Parameters
orgIdstringrequired
- Returns
Promise<JsonValue>- HTTP
GET /api/v1/invoices/{…}
sovaria.billing.buildInvoice
Build invoice.
sovaria.billing.buildInvoice(orgId: string, period?: string): Promise<JsonObject>Parameters
orgIdstringrequiredperiodstringoptional
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/invoices/{…}/build
sovaria.billing.getCompute
Get compute.
sovaria.billing.getCompute(orgId: string, period?: string): Promise<JsonObject>Parameters
orgIdstringrequiredperiodstringoptional
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/compute/{…}
sovaria.billing.checkout
Checkout.
sovaria.billing.checkout(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/billing/checkout
sovaria.billing.getProvider
Get provider.
sovaria.billing.getProvider(): Promise<JsonObject>- Returns
Promise<JsonObject>- HTTP
GET /api/v1/billing/provider
sovaria.billing.getFx
Get fx.
sovaria.billing.getFx(): Promise<JsonObject>- Returns
Promise<JsonObject>- HTTP
GET /api/v1/billing/fx
sovaria.billing.getOverage
Get overage.
sovaria.billing.getOverage(orgId: string): Promise<JsonObject>Parameters
orgIdstringrequired
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/billing/overage/{…}
sovaria.billing.getOpenInvoice
Get open invoice.
sovaria.billing.getOpenInvoice(): Promise<JsonObject>- Returns
Promise<JsonObject>- HTTP
GET /api/v1/billing/invoices/open
sovaria.billing.payInvoice
Pay invoice.
sovaria.billing.payInvoice(
orgId: string,
period: string,
body?: JsonObject = {},
): Promise<JsonObject>Parameters
orgIdstringrequiredperiodstringrequiredbodyJsonObjectoptionaldefault{}
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/billing/invoices/{…}/{…}/pay
sovaria.billing.razorpayCreateOrder
Razorpay create order.
sovaria.billing.razorpayCreateOrder(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/billing/razorpay/create-order
sovaria.billing.razorpayVerifyPayment
Razorpay verify payment.
sovaria.billing.razorpayVerifyPayment(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/billing/razorpay/verify-payment
sovaria.billing.getAccount
Get account.
sovaria.billing.getAccount(accountId: string): Promise<JsonObject>Parameters
accountIdstringrequired
- Returns
Promise<JsonObject>- HTTP
GET /api/v1/accounts/{…}
sovaria.billing.cancelAccount
Cancel account.
sovaria.billing.cancelAccount(accountId: string): Promise<JsonObject>Parameters
accountIdstringrequired
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/accounts/{…}/cancel
sovaria.billing.resumeAccount
Resume account.
sovaria.billing.resumeAccount(accountId: string): Promise<JsonObject>Parameters
accountIdstringrequired
- Returns
Promise<JsonObject>- HTTP
POST /api/v1/accounts/{…}/resume
Platform health
sovaria.system.enginesHealth
Engines health.
sovaria.system.enginesHealth(): Promise<JsonValue>- Returns
Promise<JsonValue>- HTTP
GET /api/v1/system/engines/health
Something unclear or missing on this page?Tell us