Billing
Manage billing customers, plans, subscriptions, invoices, payment methods, and Stripe Connect.
Customers
| Operation | GraphQL |
|---|---|
| Get customer | billing_customers(where: {organization_id: {_eq: $orgId}}) |
| Create customer | insert_billing_customers_one(object: {organization_id, stripe_customer_id, email, name}) |
Plans
| Operation | GraphQL |
|---|---|
| List plans | billing_plans(where: {organization_id: {_eq: $orgId}, application_id: {_eq: $appId}, deleted: {_neq: true}}, order_by: {created_at: desc}) |
| Create plan | insert_billing_plans_one(object: {name, description, price_pusd, currency, interval, billing_model, billed_entity, credit_pack_picodollars, features, ...}) |
| Update plan | update_billing_plans_by_pk(pk_columns: {id: $planId}, _set: {name, price_pusd, is_active, ...}) |
| Update plan (Action) | BillingUpdatePlan(input: {planId, name, priceCents, ...}) (Hasura Action) |
| Delete plan | update_billing_plans_by_pk(pk_columns: {id: $planId}, _set: {deleted: true}) (soft-delete) |
| Plan analytics | billing_plan_analytics(where: {organization_id: {_eq: $orgId}}) (view) |
Subscriptions
| Operation | GraphQL |
|---|---|
| Create subscription | insert_subscriptions_one(object: {organization_id, billing_customer_id, stripe_subscription_id, status, plan_name, ...}) |
| Update subscription | update_subscriptions(where: {stripe_subscription_id: {_eq: $stripeSubId}}, _set: {status, ...}) |
| List user subscriptions | user_subscriptions(where: {organization_id: {_eq: $orgId}}, order_by: {created_at: desc}) |
Invoices
| Operation | GraphQL |
|---|---|
| List invoices | invoices(where: {organization_id: {_eq: $orgId}}, order_by: {created_at: desc}, limit: 50) |
| Create invoice | insert_invoices_one(object: {organization_id, stripe_invoice_id, status, amount_due, ...}) |
| Update invoice | update_invoices(where: {stripe_invoice_id: {_eq: $stripeInvoiceId}}, _set: {status, amount_paid, ...}) |
Payment Methods
| Operation | GraphQL |
|---|---|
| List payment methods | payment_methods(where: {organization_id: {_eq: $orgId}, deleted: {_eq: false}}, order_by: [{is_default: desc}, {created_at: desc}]) |
| Create payment method | insert_payment_methods_one(object: {organization_id, stripe_payment_method_id, type, card_brand, card_last4, is_default, ...}) |
| Set default | update_payment_methods(where: {stripe_payment_method_id: {_eq: $id}}, _set: {is_default: true}) |
| Remove payment method | update_payment_methods(where: {stripe_payment_method_id: {_eq: $id}}, _set: {deleted: true, is_default: false}) (soft-delete) |
| Create setup intent | BillingCreateSetupIntent(input: {orgId, email, name}) (Hasura Action) |
| Attach payment method | BillingAttachPaymentMethod(input: {orgId, paymentMethodId}) (Hasura Action) |
Ledger & Balance
| Operation | GraphQL |
|---|---|
| List ledger entries | billing_ledger(where: $where, order_by: {created_at: desc}, limit: $limit) |
| Get plan balance | billing_balances(where: {plan_id: {_eq: $planId}}, limit: 1) |
| Pool balance (org) | billing_wallet_ledger_aggregate(where: {organization_id: {_eq: $orgId}, direction: {_eq: "credit"}}) combined with usage_events_aggregate |
| Refund charge | BillingRefundCharge(input: {orgId, chargeId, amountCents, ...}) (Hasura Action) |
| Credit checkout | BillingCreditCheckout(input: {orgId, amountUsd, currency}) (Hasura Action) |
Plan Funding
| Operation | GraphQL |
|---|---|
| Create funding intent | BillingCreatePlanFundingIntent(input: {orgId, planId, fundingModeId, assignmentId, provider, ...}) (Hasura Action) |
| User plan checkout | BillingUserPlanCheckout(input: {orgId, applicationId, userId, billingPlanId, fundingModeId}) (Hasura Action) |
Stripe Connect
| Operation | GraphQL |
|---|---|
| Create Connect account | BillingCreateConnectAccount(input: {orgId, displayName, contactEmail, country}) (Hasura Action) |
| Get onboard link | BillingCreateConnectOnboardLink(input: {orgId, refreshUrl, returnUrl}) (Hasura Action) |
| Get account status | BillingGetConnectAccountStatus(input: {orgId, accountId}) (Hasura Action) |
| Delete Connect account | BillingDeleteConnectAccount(input: {orgId}) (Hasura Action) |
| Create Connect product | BillingCreateConnectProduct(input: {orgId, name, unitAmount, currency, recurringInterval, planId}) (Hasura Action) |
| List Connect products | BillingListConnectProducts(input: {orgId, limit}) (Hasura Action) |
| Create Connect checkout | BillingCreateConnectCheckout(input: {orgId, planId, priceId, quantity, successUrl, cancelUrl}) (Hasura Action) |
| Get connected account | billing_connected_accounts(where: {org_id: {_eq: $orgId}}, limit: 1) |
External Checkout Integrations
| Operation | GraphQL |
|---|---|
| List integrations | external_checkout_integrations(where: {organization_id: {_eq: $orgId}}, order_by: {created_at: desc}) |
| Create integration | insert_external_checkout_integrations_one(object: {organization_id, provider, display_name, status, ...}) |
| Update integration | update_external_checkout_integrations_by_pk(pk_columns: {id: $id}, _set: {display_name, status, ...}) |
Payouts
| Operation | GraphQL |
|---|---|
| List payouts | payouts(where: {organization_id: {_eq: $orgId}}, order_by: {created_at: desc}) |
Billing Analytics (REST)
The GET /billing/analytics REST endpoint returns plan-level subscriber counts and revenue aggregates for the organization. Authentication: builder JWT. The org is resolved from the token; no query parameters are needed.
curl https://api.picklayer.ai/billing/analytics \
-H "Authorization: Bearer $ORG_TOKEN"Response: array of per-plan rows with planId, planName, subscriberCount, activeSubscriberCount, totalRevenuePusd, and mrr. Monetary values are in pUSD (divide by 10^12 for dollars).
For finer-grained control, query the billing_plan_analytics Hasura view directly:
| Operation | GraphQL |
|---|---|
| Plan analytics (all plans) | billing_plan_analytics(where: {organization_id: {_eq: $orgId}}) |
| Plan analytics (single plan) | billing_plan_analytics(where: {id: {_eq: $planId}}) |
Billing Settings (REST)
PATCH /billing/settings — updates budget_limit and hard_cap_enabled on the organization. Body: { orgId, budgetLimit?, hardCapEnabled? }. See management-api/settings for the full field descriptions and guard behavior.