Skip to content
Join our SlackContact usGet started

Get Billing State

client.CustomerAccess.GetBillingState(ctx, subjectID) (*CustomerAccessGetBillingStateResponse, error)
get/customer-access/{subject_id}/billing-state

Get Billing State

ParametersExpand Collapse
subjectID string

The ID or external ID of the subject to get billing state for.

ReturnsExpand Collapse
type CustomerAccessGetBillingStateResponse struct{…}
ActiveSubscriptions []CustomerAccessGetBillingStateResponseActiveSubscription

List of active subscriptions the subject is subscribed to.

RateCardID string
SubscriptionID string
HasActiveSubscription bool

Whether the subject has an active subscription.

HasOverageForUsage bool

Whether the subject has exceeded the included usage (if any) on a usage-based rate they are subscribed to.

UsageData []CustomerAccessGetBillingStateResponseUsageData

The usage data for the usage-based rates the subject is subscribed to.

IncludedUnits int64
PricingMetricID string
RateName string
UsedUnits string
Get Billing State
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.CustomerAccess.GetBillingState(context.TODO(), "user_1234567890")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ActiveSubscriptions)
}
{
  "active_subscriptions": [
    {
      "rate_card_id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
      "subscription_id": "sub_PuLvkNSP3IBCvjayBD3TXNQ6"
    }
  ],
  "has_active_subscription": true,
  "has_overage_for_usage": false,
  "usage_data": [
    {
      "included_units": 300,
      "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
      "rate_name": "Compute Hours",
      "used_units": "100"
    }
  ]
}
Returns Examples
{
  "active_subscriptions": [
    {
      "rate_card_id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
      "subscription_id": "sub_PuLvkNSP3IBCvjayBD3TXNQ6"
    }
  ],
  "has_active_subscription": true,
  "has_overage_for_usage": false,
  "usage_data": [
    {
      "included_units": 300,
      "pricing_metric_id": "pmtr_GlX5Tcm2HOn00CoRTFxw2Amw",
      "rate_name": "Compute Hours",
      "used_units": "100"
    }
  ]
}