Skip to content
Docs

Top Up Organization Prepaid Balance

client.Organizations.Billing.TopUp(ctx, organizationID, params) (*OrganizationBillingSummary, error)
POST/v1/organizations/{organization_id}/billing/topup

Charge the card on file and credit the prepaid balance. A unique Idempotency-Key header is required; reuse it across retries so a timed-out top-up is not charged twice.

ParametersExpand Collapse
organizationID string
params BillingTopUpParams
Amount param.Field[string]

Body param: Amount to charge and credit, in USD. Must be greater than 0, at most two decimal places, and at most 10000.

formatdecimal
IdempotencyKey param.Field[string]

Header param: Unique idempotency key scoping the charge; reuse the same value across retries so a timed-out top-up is not charged twice

ReturnsExpand Collapse
type OrganizationBillingSummary struct{…}

Forward-looking billing summary for an organization. All costs are run-rate projections from the organization’s current active usage (”≈ $X/mo at current usage”).

DailyCost string

Arbitrary-precision decimal serialized as a string (e.g. “58.40”).

formatdecimal
EffectiveBalance string

Arbitrary-precision decimal serialized as a string (e.g. “58.40”).

formatdecimal
MonthlyCost string

Arbitrary-precision decimal serialized as a string (e.g. “58.40”).

formatdecimal
RechargeThresholdFraction string

Arbitrary-precision decimal serialized as a string (e.g. “58.40”).

formatdecimal
EstimatedNextChargeAt TimeOptional

Projected date the balance reaches the recharge threshold at the current run-rate. Null when there is no active usage (never charges).

formatdate-time
RunwayMonths stringOptional

Arbitrary-precision decimal serialized as a string (e.g. “58.40”).

formatdecimal

Top Up Organization Prepaid Balance

package main

import (
  "context"
  "fmt"

  "github.com/nirvana-labs/nirvana-go"
  "github.com/nirvana-labs/nirvana-go/option"
  "github.com/nirvana-labs/nirvana-go/organizations"
)

func main() {
  client := nirvana.NewClient(
    option.WithAPIKey("My API Key"),
  )
  organizationBillingSummary, err := client.Organizations.Billing.TopUp(
    context.TODO(),
    "organization_id",
    organizations.BillingTopUpParams{
      Amount: "50.00",
      IdempotencyKey: "Idempotency-Key",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationBillingSummary.DailyCost)
}
{
  "daily_cost": "-69125",
  "effective_balance": "-69125",
  "monthly_cost": "-69125",
  "recharge_threshold_fraction": "-69125",
  "estimated_next_charge_at": "2025-01-01T00:00:00Z",
  "runway_months": "-69125"
}
Returns Examples
{
  "daily_cost": "-69125",
  "effective_balance": "-69125",
  "monthly_cost": "-69125",
  "recharge_threshold_fraction": "-69125",
  "estimated_next_charge_at": "2025-01-01T00:00:00Z",
  "runway_months": "-69125"
}