---
title: "Set up billing"
description: "Wire setupBilling into the backend: the scaffolded billing.ts and its options, who pays and who may buy for a workspace, billing each person instead, what a deletion erases, the BILLING_* variables, and going live."
canonical_url: "https://nuxt-backend.dev/docs/build/billing/setup"
---
# Set up billing

> Wire setupBilling into the backend: the scaffolded billing.ts and its options, who pays and who may buy for a workspace, billing each person instead, what a deletion erases, the BILLING_* variables, and going live.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [Try it live in the playground](https://nuxt-backend.dev/playground/pricing)
- [API reference](https://nuxt-backend.dev/docs/reference/api/billing)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

You get billing from one call in one scaffolded file. `setupBilling` in `backend/billing.ts` mounts billing on the `backend` component and on Polar's Convex component, reads the `BILLING_*` variables, and resolves who pays from the session.

- **Polar does natively:** customers (individual or team, with members), products, hosted checkout, the customer portal, tax as the merchant of record, and signed webhooks (checked on 2026-10-25).
- **The package adds:** one customer per workspace or account, keyed by its id; who may buy for a workspace, checked fresh on every call; the entitlement cache your functions read; and billing's part of an account's export and erasure.

This page walks through the file, the choices it leaves you, and what a deployment needs to go live. Polar's account, tokens and sandbox are on the [Polar](https://nuxt-backend.dev/docs/services/polar) page. To sell through Stripe Managed Payments, Dodo Payments or Creem instead, set `BILLING_PROVIDER` and pass `commerce: { definition, products }` to the same call ([Stripe, Dodo and Creem](https://nuxt-backend.dev/docs/services/merchants)); without `commerce`, such a provider fails the deploy.

## Before you start

- **The scaffold**: `backend/billing.ts`, `billing.catalog.ts` and `billing.generated.ts`, next to `auth.ts`, `email.ts` and `audit.ts`. `npx nuxt-backend upgrade` restores a scaffold file that is gone.
- **A catalog**, declared and synced: [Define and sync your catalog](https://nuxt-backend.dev/docs/build/billing/catalog). Without one, billing reads work and a checkout is refused as `not_ready` (reason `no_catalog`).
- **A sandbox token** for development: a Polar sandbox organization's access token in `.env.local` as `BILLING_ACCESS_TOKEN` ([Develop with real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes#billing-on-polars-sandbox)).

## Wire it

<steps level="3">

### Keep the scaffolded instance

`setupBilling(components, options)` takes the app's components and one required option, `email`: the `setupEmail` instance that sends a gift's notice. The scaffold also passes the catalog's id map; `audit`, so billing's events reach the [activity trail](https://nuxt-backend.dev/docs/build/billing/events#on-the-activity-trail); and `paths`, the settings page its emails link to ([The paths file](https://nuxt-backend.dev/docs/reference/configuration/module-options#the-paths-file)). It returns its helpers and `api`, the functions your composables call:

```ts [backend/billing.ts]
import { setupBilling } from 'nuxt-backend/billing'
import { components } from './_generated/api'
import { audit } from './audit'
import { catalog } from './billing.generated'
import { email } from './email'
import { paths } from './paths.generated'

export const billing = setupBilling(components, { catalog, email, audit, paths })

export const {
  getPricing, getConfiguredProducts, getBillingAccess, getFeatures, getCredits,
  getCurrentSubscription, listAllSubscriptions, syncEntitlements, syncProducts, startFreePlan, resyncEntitlements,
  generateCheckoutLink, generateCustomerPortalUrl,
  updateSubscription, cancelSubscription, uncancelSubscription,
  cancelPendingChange, pauseSubscription, resumeSubscription,
  getOrders, getInvoiceUrl, getUsageHistory, refundOrder,
  giftCheckout, getReceivedGifts, claimGift, getWebhookDeliveries, getRevenue,
} = billing.api
```

Keep every export. The composables call them by name: `usePricing` calls `getPricing`, `useBilling` calls `getCurrentSubscription`, `generateCheckoutLink` and the lifecycle actions, and so on. A trimmed export leaves its composable reading `undefined`, and `npx nuxt-backend doctor` names the missing function. The internal ones are run by name too: the free plan's queue runs `startFreePlan`, the gift sweep `runGiftSweep`, and [`npx nuxt-backend billing resync`](https://nuxt-backend.dev/docs/reference/cli#billing-resync) runs `resyncEntitlements`, which reads the entitlements of every workspace, or every account with `billTo: 'user'`, again after the cache missed webhooks. An app whose own `resolveEntity` bills entities of its own names them with `--entity`.

`setupBilling` checks `email` as it runs. An import cycle through `email.ts` can hand it over as `undefined` despite its type. That fails the deploy rather than the first paid gift.

### Hand billing to your functions

`backend/functions.ts` builds every function tier in one `createFunctions` call, and `billing` is one of its inputs. The `withFeature` tier comes from that call: the `workspace` tier plus a plan's feature ([Gate features by plan](https://nuxt-backend.dev/docs/build/billing/subscriptions/feature-gating)).

```ts [backend/functions.ts]
import { createFunctions } from 'nuxt-backend/functions'
import { billing } from './billing'
import { rateLimiter } from './rateLimiter'
import { components } from './_generated/api'
import { action, mutation, query } from './_generated/server'

export const { authed, workspace, admin, withRole, withFeature, setUserRole } = createFunctions(
  { query, mutation, action },
  { components, billing, rateLimiter },
)
```

`billing.ts` imports nothing from `functions.ts`, so the two files never import each other.

### Choose who pays

The default, `billTo: 'workspace'`, bills the active workspace. `billTo: 'user'` bills each account on its own. `resolveEntity` replaces both with a resolver of your own, for an entity your tables define. See [Who pays](#who-pays) and [Bill each person](#bill-each-person) below.

```ts [backend/billing.ts]
export const billing = setupBilling(components, { catalog, email, audit, billTo: 'user' })
```

### Throttle the provider calls

Pass your `setupRateLimiter` instance as `rateLimiter`. Every client-callable function that reaches the live provider then counts against the `billingSync` limit, ten a minute per workspace or user. That covers `syncEntitlements`, checkout, the plan's lifecycle, orders and invoices, so a caller can't loop one to fan out provider requests. `giftCheckout` counts against it too, keyed by the purchaser.

```ts [backend/billing.ts]
import { rateLimiter } from './rateLimiter'

export const billing = setupBilling(components, { catalog, email, audit, rateLimiter })
```

### Leave the routes to `http.ts`

The scaffolded `backend/http.ts` hands `billing` to `registerBackendRoutes`, which mounts the signed webhook endpoint at `/billing/events`. `backend/account.ts` hands it to `setupAccount`, so an account's export and erasure reach the provider. Neither needs more from you. [Register webhooks](https://nuxt-backend.dev/docs/ship/security/webhooks) lists every route and its secret.

</steps>

## The options

Every option but `email` overrides a default. [Hooks and guarantees](https://nuxt-backend.dev/docs/reference/backend/hooks) says when each callback runs and what a throw does.

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Effect
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        email
      </code>
    </td>
    
    <td>
      Required. The app's <code>
        setupEmail
      </code>
      
       instance: a paid gift's recipient hears of it through its <code>
        gift
      </code>
      
       <a href="https://nuxt-backend.dev/docs/build/email/templates">
        template
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        audit
      </code>
    </td>
    
    <td>
      The app's <code>
        setupAudit
      </code>
      
       instance. Checkouts, plan changes, refunds, gifts, low balances and the provider's subscription, order and benefit deliveries are recorded through it and reach its <code>
        onEvent
      </code>
      
      . Without it they are recorded on the component's own trail.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        catalog
      </code>
    </td>
    
    <td>
      The id map in <code>
        billing.generated.ts
      </code>
      
      . The deployment reads its <code>
        production
      </code>
      
       entry when <code>
        BACKEND_ENVIRONMENT
      </code>
      
       is <code>
        production
      </code>
      
      , and its <code>
        sandbox
      </code>
      
       entry everywhere else.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        products
      </code>
      
       · <code>
        credits
      </code>
    </td>
    
    <td>
      An explicit product map (catalog key to product id) and named credit meters. <code>
        products
      </code>
      
       replaces the catalog's map, and <code>
        credits
      </code>
      
       entries win over its meters.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billTo
      </code>
    </td>
    
    <td>
      <code>
        'workspace'
      </code>
      
       (the default: the active workspace pays and its members share the plan) or <code>
        'user'
      </code>
      
       (each account pays for itself).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        resolveEntity
      </code>
    </td>
    
    <td>
      <code>
        (ctx, rule?) => Promise<{ userId, email } | null>
      </code>
      
      : the billing entity, resolved your way, for every read, checkout, spend and lifecycle call. Return <code>
        null
      </code>
      
       without an identity, and throw to refuse a caller the <code>
        rule
      </code>
      
       does not allow. See <a href="#billing-a-user-instead">
        Billing a user instead
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trustedOrigins
      </code>
    </td>
    
    <td>
      Origins besides <code>
        SITE_URL
      </code>
      
      's that a checkout, a gift checkout or the portal may return to (<code>
        ['https://app.example.com']
      </code>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rateLimiter
      </code>
    </td>
    
    <td>
      Your <code>
        setupRateLimiter
      </code>
      
       instance: throttles every client-callable function that reaches the provider, against <code>
        billingSync
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        multipleSubscriptions
      </code>
    </td>
    
    <td>
      Let one entity hold several live subscriptions at once. <code>
        getCurrentSubscription
      </code>
      
       then leads with a <code>
        subscriptions
      </code>
      
       array, and the lifecycle actions take a <code>
        subscriptionId
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        requireAdmin
      </code>
    </td>
    
    <td>
      Your gate for the admin functions, <code>
        refundOrder
      </code>
      
      , the webhook log and <code>
        getRevenue
      </code>
      
      . The default requires the <code>
        admin
      </code>
      
       role on the caller's account, read fresh.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        canGift
      </code>
      
       · <code>
        giftLimit
      </code>
    </td>
    
    <td>
      Who may receive a gift, on top of the package's own rules, and how many gifts one purchaser may buy in a window (10 in 30 days by default). See <a href="https://nuxt-backend.dev/docs/build/growth/offers/gifts#who-can-receive-a-gift">
        Send and receive gifts
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        checkoutDiscount
      </code>
    </td>
    
    <td>
      Pick a catalog promotion for a plan's checkout that names none, such as founder pricing for an early cohort. See <a href="https://nuxt-backend.dev/docs/build/growth/offers#pick-one-per-customer">
        Run a promotion
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        events
      </code>
      
       · <code>
        onUnknownEvent
      </code>
    </td>
    
    <td>
      Your handlers for the provider's events, after the package's own work, and for a verified event too new for the installed SDK. See <a href="https://nuxt-backend.dev/docs/build/billing/events">
        React to billing events
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        accessToken
      </code>
      
       · <code>
        webhookSecret
      </code>
    </td>
    
    <td>
      Override <code>
        BILLING_ACCESS_TOKEN
      </code>
      
       and <code>
        BILLING_WEBHOOK_SECRET
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

`BACKEND_ENVIRONMENT` decides the provider environment; there is no `environment` option. The billing lifecycle takes `lifecycle`, each part off until named, with `saveOffers` for the [cancel flow](https://nuxt-backend.dev/docs/build/growth/engage/cancel-flow), `abandonedCheckout`, `renewalReminders` and `withdrawal` ([React to billing events](https://nuxt-backend.dev/docs/build/billing/events#lifecycle-events)).

## What it returns

`setupBilling` returns `api`, the functions to re-export, and the helpers your own server code calls. The [billing API reference](https://nuxt-backend.dev/docs/reference/api/billing) has every signature.

<table>
<thead>
  <tr>
    <th>
      Part
    </th>
    
    <th>
      What it is for
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        api
      </code>
    </td>
    
    <td>
      Every registered function, for the composables, <code>
        /pricing
      </code>
      
       and DevTools. The scaffold re-exports them.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        webhookHandler
      </code>
    </td>
    
    <td>
      The verified endpoint <code>
        registerBackendRoutes
      </code>
      
       mounts at <code>
        /billing/events
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        checkout
      </code>
      
       · <code>
        portal
      </code>
    </td>
    
    <td>
      A checkout or a portal session from your own action, with the trial or discount your server chose (<a href="https://nuxt-backend.dev/docs/build/billing/subscriptions/checkout#a-different-trial-or-discount-from-the-server">
        Open checkout and the portal
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hasFeature
      </code>
      
       · <code>
        requireFeature
      </code>
      
       · <code>
        activePlans
      </code>
    </td>
    
    <td>
      The plan's features, read from the entitlement cache (<a href="https://nuxt-backend.dev/docs/build/billing/subscriptions/feature-gating">
        Gate features by plan
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getQuota
      </code>
      
       · <code>
        requireQuota
      </code>
      
       · <code>
        releaseQuota
      </code>
    </td>
    
    <td>
      Resource quotas, counted in your own mutations (<a href="https://nuxt-backend.dev/docs/build/billing/subscriptions/quotas">
        Limit resources per plan
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        spendCredits
      </code>
      
       · <code>
        reserveCredits
      </code>
      
       · <code>
        settleSpend
      </code>
      
       · <code>
        releaseSpend
      </code>
      
       · <code>
        refundCredits
      </code>
    </td>
    
    <td>
      Prepaid credits, spent from your functions (<a href="https://nuxt-backend.dev/docs/build/billing/credits/spending">
        Spend credits in your functions
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        updateSubscription
      </code>
      
       · <code>
        cancelSubscription
      </code>
      
       · <code>
        uncancelSubscription
      </code>
      
       · <code>
        cancelPendingChange
      </code>
      
       · <code>
        pauseSubscription
      </code>
      
       · <code>
        resumeSubscription
      </code>
    </td>
    
    <td>
      The plan's lifecycle from server code, with the whole proration set (<a href="https://nuxt-backend.dev/docs/build/billing/subscriptions#from-server-code">
        Manage subscriptions
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getOrders
      </code>
      
       · <code>
        getInvoiceUrl
      </code>
      
       · <code>
        getUsageHistory
      </code>
      
       · <code>
        refundOrder
      </code>
    </td>
    
    <td>
      History read live from the provider, and refunds (<a href="https://nuxt-backend.dev/docs/build/billing/subscriptions/orders">
        Show orders, invoices and usage
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        discounts
      </code>
      
       · <code>
        applyDiscount
      </code>
    </td>
    
    <td>
      Discounts outside the catalog, and a catalog promotion put on a subscription (<a href="https://nuxt-backend.dev/docs/build/growth/offers/discounts">
        Mint discounts from your server
      </a>
      
      , <a href="https://nuxt-backend.dev/docs/build/growth/offers#put-one-on-a-subscription">
        Run a promotion
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        requireEntity
      </code>
      
       · <code>
        resolveEntity
      </code>
    </td>
    
    <td>
      The caller's billing entity, checked the way the package's functions check it (<a href="#in-your-own-functions">
        In your own functions
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        startFreePlan
      </code>
    </td>
    
    <td>
      Put an entity your code created on the <a href="https://nuxt-backend.dev/docs/build/billing/catalog#the-free-plan">
        free plan
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getCustomerState
      </code>
    </td>
    
    <td>
      An entity's plans, benefits and balances, read live from the provider in an action.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forgetEntity
      </code>
      
       · <code>
        forgetAccount
      </code>
      
       · <code>
        exportAccount
      </code>
    </td>
    
    <td>
      Billing's part of an erasure and an export (<a href="#when-an-account-or-a-workspace-is-deleted">
        below
      </a>
      
      ).
    </td>
  </tr>
</tbody>
</table>

## Who pays

The billing entity is what owns a subscription and a credit balance. Every billing call resolves it on the server, from the session, never from an id the browser sends:

- **A workspace**, with the default `billTo: 'workspace'`: the session's active workspace. Its members share its plan, features and credits. Its owner and admins manage them, and every call checks the caller's membership and role fresh ([Who may buy for a workspace](#who-may-buy-for-a-workspace)).
- **A user**, with `billTo: 'user'`: the signed-in account, which manages its own billing ([Bill each person](#bill-each-person)).
- **Your own entity**, with `resolveEntity` beside `billTo: 'user'`: a studio in your own tables, say, where your resolver decides who acts for it ([Billing a user instead](#billing-a-user-instead)).

### One customer per billing entity

Every billing entity pays through a Polar customer of its own, keyed by the entity's id as the customer's external id. With a [free plan](https://nuxt-backend.dev/docs/build/billing/catalog#the-free-plan) in the catalog, the free plan's start creates the customer as the entity is made, so the owner's email (or the user's) reaches the provider at sign-up. Without one, the first checkout creates it. Every live call after that finds the customer by that id: customer state, usage events, orders and the portal. Webhooks resolve the entity from the customer's external id first, then from the entity tag in its metadata, then from the cache.

- **A workspace** is a team customer named after it, with the workspace's owner as its owner member. One person can own several workspaces, and each still bills through its own customer, with its own plan, credits and orders. Members are never seats: the customer pays, and its billing managers act for it.
- **A user** (`billTo: 'user'`) is an individual customer with the user's email. The provider keeps an individual customer's email unique, so an email it already holds for another account is refused with `forbidden` (reason `customer_taken`).
- **An earlier customer** of the owner's verified email that no entity keyed becomes the entity's own for a personal workspace or a user. An example is one the provider made from a checkout that named no customer. It never does for a shared workspace, for a customer another entity holds, or for an email its owner has not proved with a sign-in code.
- **A customer from before 0.2**, mapped by the old email lookup and carrying no external id, gets the entity's id on its first checkout or entitlement read. Production billing from 0.1 carries over with nothing to run. A customer that two entities shared is refused for the second as `forbidden` (reason `customer_taken`), and the deployment logs `billing.customer_mapping_shared` until its billing data is reset.
- **A customer of another organization.** The deployment keeps which customer each entity maps to, and the subscriptions synced for it. Point `BILLING_ACCESS_TOKEN` at another Polar organization (a second sandbox, say) and those customers are unknown there. A billing call for such an entity is refused `unavailable` (reason `customer_unknown`), its free plan does not start, and the deployment logs `billing.customer_mapping_stale`. `npx nuxt-backend doctor` reports it before anyone signs in ([`billing-customer-mapping`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing-customer-mapping)). When you switch a dev deployment to another organization, run [`npx nuxt-backend billing reset`](https://nuxt-backend.dev/docs/reference/cli#billing-reset): it syncs the catalog there, clears the deployment's billing data and puts every billing entity back on the free plan.

Trials run once per owner. A checkout for a workspace whose owner already had a trial starts without one, whatever the product or the server offers. The package records a trial by the owner's user id when a subscription starts one, so deleting the workspace that trialed changes nothing. A checkout that offers a trial holds it for its workspace for an hour, so two first checkouts of one owner's workspaces at once can't both start one.

## Who may buy for a workspace

A workspace pays for everyone in it, but only its owner and admins spend its money. They are its billing managers: they check out, open the portal, change or cancel the plan, and read the orders and invoices. Every other member reads the plan, the features and the balance, and spends the credits. The server reads the member table on every call, so a removed or demoted member loses access on their next call. With `billTo: 'user'` there is no workspace to manage: each account buys for itself.

### Who can do what

Each function the scaffolded `backend/billing.ts` re-exports, who may call it, and whether an administrator [impersonating](https://nuxt-backend.dev/docs/build/auth/admin/impersonation) that person may:

<table>
<thead>
  <tr>
    <th>
      Function
    </th>
    
    <th>
      Who
    </th>
    
    <th>
      Impersonating admin
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        getConfiguredProducts
      </code>
      
       · <code>
        getPricing
      </code>
    </td>
    
    <td>
      Anyone, signed out included
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getCurrentSubscription
      </code>
      
       · <code>
        listAllSubscriptions
      </code>
      
       · <code>
        getFeatures
      </code>
      
       · <code>
        getCredits
      </code>
      
       · <code>
        getBillingAccess
      </code>
      
       · <code>
        syncEntitlements
      </code>
      
       · <code>
        getUsageHistory
      </code>
    </td>
    
    <td>
      Any member of the workspace
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        spendCredits
      </code>
      
       · <code>
        reserveCredits
      </code>
      
       · <code>
        refundCredits
      </code>
      
       from your own function, and the <a href="https://nuxt-backend.dev/docs/build/ai/metered-actions">
        metered AI actions
      </a>
    </td>
    
    <td>
      Any member of the workspace
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        generateCheckoutLink
      </code>
      
       · <code>
        generateCustomerPortalUrl
      </code>
    </td>
    
    <td>
      Its owner and admins
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        updateSubscription
      </code>
      
       · <code>
        cancelSubscription
      </code>
      
       · <code>
        uncancelSubscription
      </code>
      
       · <code>
        cancelPendingChange
      </code>
      
       · <code>
        pauseSubscription
      </code>
      
       · <code>
        resumeSubscription
      </code>
    </td>
    
    <td>
      Its owner and admins
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getOrders
      </code>
      
       · <code>
        getInvoiceUrl
      </code>
    </td>
    
    <td>
      Its owner and admins
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        giftCheckout
      </code>
    </td>
    
    <td>
      Any signed-in account, paying from a billing entity it manages
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getReceivedGifts
      </code>
    </td>
    
    <td>
      Any signed-in account, for its own verified address
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        claimGift
      </code>
    </td>
    
    <td>
      The gift's recipient, into a billing entity they manage
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getBillingConsole
      </code>
    </td>
    
    <td>
      App admins
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        refundOrder
      </code>
    </td>
    
    <td>
      App admins, signed in within the last ten minutes
    </td>
    
    <td>
      No
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        getRevenue
      </code>
    </td>
    
    <td>
      App admins (<a href="https://nuxt-backend.dev/docs/build/growth/measure/revenue">
        Read revenue and usage
      </a>
      
      )
    </td>
    
    <td>
      No
    </td>
  </tr>
</tbody>
</table>

An impersonating administrator may look but not spend. Reading a workspace's billing helps them support it, and its money stays its own. Each refusal is listed under [What happens when…](#what-happens-when).

### Checked fresh, not from the token

The session token names the active workspace and the app-wide role, and it lives for up to 15 minutes. Billing reads neither from it. Every call reads the account, the caller's membership and the caller's role from the user and member tables, and an admin function reads the account's role. Each change takes effect on the next call, without waiting for a token to expire:

- A member you remove is refused.
- A member you demote stops managing billing.
- An account you ban is refused.
- An admin you demote loses `refundOrder`, the webhook log and the admin console's Billing tab.

Each read happens once per function call, and a second check in the same call reuses it. A function of yours that changes the caller's membership or role and then checks again passes `reread: true` to [`requireEntity`](#in-your-own-functions).

### Hide what a member can't do

`useBilling().canManage` says whether the caller manages the billing, as the server decides it. The scaffolded `getBillingAccess` runs the same check the portal does, so `canManage` is `true` for every account with `billTo: 'user'`, and `false` for an impersonating administrator. While the answer isn't known yet (signed out, or still loading), it reads `true`, so a pricing page still shows its plans to a visitor.

The package's own components read it. `<PricingTable>`, `<WorkspaceSettings>`, `<BillingCheckoutLink>` and `<BillingPortalLink>` show a member who doesn't manage billing the plans without their buttons. A note takes their place (the `pricing.managed` label), with no checkout or portal link. A page of your own does the same:

```vue [app/pages/studio/billing.vue]
<script setup lang="ts">
const { canManage, portal } = useBilling()
</script>

<template>
  <button v-if="canManage" type="button" @click="portal()">
    Manage billing
  </button>
  <p v-else>
    Ask your workspace's owner to change the plan.
  </p>
</template>
```

Hiding a button is a courtesy: the server refuses the call either way.

### In your own functions

`billing.requireEntity(ctx, rule)` checks a caller the way the package's functions do, and returns the billing entity it may act for. The rule takes:

- **access**: `'member'` for any member, `'manage'` for the owner and admins. Any other value is refused (`forbidden`, reason `permission`).
- **impersonation**: `'allowed'` by default; `'refused'` keeps an impersonating administrator out.
- **recentSignIn**: in a mutation or an action, how recent a sign-in it takes, in seconds.
- **reread**: read the member table again after the same call changed the caller's membership or role.

Only a workspace's billing managers set where its invoices go, and only in person:

```ts [backend/invoicing.ts]
import { v } from 'convex/values'
import { mutation } from './_generated/server'
import { billing } from './billing'

export const setInvoiceAddress = mutation({
  args: { address: v.string() },
  handler: async (ctx, { address }) => {
    const { userId: workspaceId } = await billing.requireEntity(ctx, {
      access: 'manage',
      impersonation: 'refused',
    })
    await ctx.db.insert('invoiceAddresses', { workspaceId, address })
  },
})
```

The entity comes back as `userId`, the name every billing call gives it: a workspace's id with `billTo: 'workspace'`, an account's with `billTo: 'user'`. To spend credits for that entity from the same function, pass it on: `billing.spendCredits(ctx, { userId, meter: 'credits' })` ([Spend credits in your functions](https://nuxt-backend.dev/docs/build/billing/credits/spending)).

### The billing portal

The portal opens as the caller's own member of the workspace's customer at Polar, so it shows who is signed in. The plan, the payment method and the invoices change there, so only a billing manager opens it, and only in person.

The member is found by the caller's user id. An adopted customer's owner member has none (the provider sets it only at creation), so it is matched by the caller's verified email instead, and only a member no account is keyed to. That owner loses the portal if they change their email, until you update the member at the provider.

Workspace admins pass the server's check, but the package registers only the workspace's owner as a billing manager of its team customer at the provider. An admin's portal is therefore refused with `forbidden` (reason `provider_owner_only`). Admins still check out, change or cancel the plan, and read orders and invoices: the portal is the one thing the owner opens for them. Registering every admin as a billing manager at the provider comes with workspace billing permissions, in a later release ([Roadmap](https://nuxt-backend.dev/docs/start/roadmap)).

### Billing a user instead

With `billTo: 'user'`, each account pays for itself and manages its own billing, so `canManage` is `true`. The impersonation rules and the ban still hold. [Bill each person](#bill-each-person) sets it up.

To bill something else, such as a studio in your own tables, keep `billTo: 'user'` and add a `resolveEntity`. Your resolver then decides who acts for the entity:

- A call that checks its caller hands the resolver its rule as the second argument, so the resolver can refuse a caller who may only read.
- Treat a missing rule as the strictest case.
- Refuse by throwing: a read then answers `null`, and `canManage` reads `false`.

```ts [backend/billing.ts]
import { setupBilling } from 'nuxt-backend/billing'
import { backendError } from 'nuxt-backend/functions'
import { components, internal } from './_generated/api'
import { audit } from './audit'
import { catalog } from './billing.generated'
import { email } from './email'

export const billing = setupBilling(components, {
  catalog,
  email,
  audit,
  billTo: 'user',
  // Bill the studio the caller picked; only its owners buy for it.
  resolveEntity: async (ctx, rule) => {
    const membership = await ctx.runQuery(internal.studios.currentMembership, {})
    if (!membership) return null
    if (rule?.access !== 'member' && membership.role !== 'owner') {
      throw backendError('forbidden', { reason: 'not_billing_manager' })
    }
    return { userId: membership.studioId, email: membership.billingEmail }
  },
})
```

`internal.studios.currentMembership` is your own query.

## Bill each person

For a product people buy for themselves, such as Panels, a writing tool or a course, a shared workspace bill is in the way. With `billTo: 'user'`, every account is its own billing entity: its own Polar customer, plan, features and credit balance, managed by the person alone. Workspaces still exist for sharing strips; they don't pay.

<steps level="3">

### Bill the account

Pass `billTo: 'user'` in `backend/billing.ts`. Every billing call now resolves the signed-in account instead of the active workspace.

You should see: after `nuxt-backend dev` redeploys, a second account in the same workspace reads its own plan and balance, not the first account's.

### Declare a free plan and a paid one

A plan priced `{ month: 0 }` is the free plan. With `billTo: 'user'`, each new account starts on it at its first sign-in, as a Polar customer with the person's email. Run `npx nuxt-backend billing sync` after you edit the catalog.

You should see: a new account's `/pricing` marks Free as the current plan, and the DevTools Billing tab shows its 20 credits.

### Gate a feature on the person's plan

The `withFeature` tier is built on the `workspace` tier and asks for a workspace member. With `billTo: 'user'`, gate a function with the `authed` tier and `billing.requireFeature` instead, which checks the caller's own plan. A refusal carries the plans that include the feature, for `<UpgradePrompt>`.

You should see: on Free, `exportMine` is refused as `feature_required` with `plans: ['creator']`. After a checkout of Creator with the test card, it runs.

### Show the plan where the person looks

`/pricing` works as it is. The billing and credits sections of `<WorkspaceSettings>` read the caller's billing entity, so they show the person's own plan wherever they render. Put them on an account page of yours, and keep `/settings` for workspaces.

You should see: `/account/billing` shows the plan, its state and the credit balance, and Cancel plan works.

</steps>

<code-tree default-value="backend/billing.ts">

```ts [backend/billing.ts]
import { setupBilling } from 'nuxt-backend/billing'
import { components } from './_generated/api'
import { audit } from './audit'
import { catalog } from './billing.generated'
import { email } from './email'

// Each account pays for itself: its own customer, plan, features and credits.
export const billing = setupBilling(components, { catalog, email, audit, billTo: 'user' })

// Keep the scaffold's re-exports of billing.api below.
```

```ts [backend/billing.catalog.ts]
import { defineBillingCatalog } from 'nuxt-backend/billing'

export default defineBillingCatalog({
  meters: { credits: {} },
  plans: {
    free: { name: 'Free', prices: { month: 0 }, credits: { meter: 'credits', units: 20 } },
    creator: {
      name: 'Creator',
      prices: { month: 1200, year: 12000 },
      credits: { meter: 'credits', units: 500 },
      features: ['exports'],
      trial: { interval: 'day', count: 7 },
    },
  },
  packs: {
    credits200: { name: '200 credits', price: 800, credits: { meter: 'credits', units: 200 } },
  },
  features: {
    exports: { description: 'Strip exports in full resolution' },
  },
})
```

```ts [backend/exports.ts]
import { billing } from './billing'
import { authed } from './functions'

export const exportMine = authed.action({
  args: {},
  handler: async (ctx) => {
    // The person's own plan: no workspace involved.
    await billing.requireFeature(ctx, 'exports')
    return exportStrips(ctx, ctx.user.id)
  },
})
```

```vue [app/pages/account/billing.vue]
<script setup lang="ts">
definePageMeta({ auth: true })
</script>

<template>
  <WorkspaceSettings :sections="['billing', 'credits']" />
</template>
```

</code-tree>

`exportStrips` is your own code. What changes with it:

- **Gifts.** A purchaser pays for a gift on their own account, and the recipient claims it into theirs: no workspace is involved on either side ([Send, receive and manage gifts](https://nuxt-backend.dev/docs/build/growth/offers/gifts)).
- **Erasure.** Deleting an account deletes and anonymizes its own customer at the provider, which keeps its orders for its books ([When an account or a workspace is deleted](#when-an-account-or-a-workspace-is-deleted)).
- **One email, one customer.** The provider keeps an individual customer's email unique, so an address it already holds for another customer is refused as `forbidden` (reason `customer_taken`).
- **Credits only, no plans.** Drop the paid plan and sell packs. The free plan still gives every account a monthly allowance.

Don't switch an app that already bills workspaces to `billTo: 'user'` in place. Each workspace's customer, plan and credits stay with the workspace's id, and the accounts start from nothing.

## When an account or a workspace is deleted

Deleting an account erases what billing holds of it, as one participant of the account's [erasure](https://nuxt-backend.dev/docs/build/auth/accounts/data#what-an-erasure-removes):

- **The entities that go with it** are its personal workspace, every workspace it was the only member of, or the account itself with `billTo: 'user'`. They are marked as deleting before anything else. Their customers are then deleted and anonymized at the provider, which keeps their orders for its books. Their cached plans, balances, reservations and quota counts are forgotten. The mark means the subscription that ends with a customer starts no free plan again, and the provider's later deliveries about it map, cache and record nothing.
- **A workspace it leaves** keeps its customer and its plan. Only the account's member of that team customer is removed.
- **Its export** lists the subscriptions and the newest orders (up to 100 each) of every entity it owns alone.

One thing stays for now. Polar's Convex component keeps the subscriptions it synced and the link from the entity's id to its deleted customer, since it has no way to delete them yet. They name the entity's id, never an address or a name, and a cancellation keeps the reason and comment the customer gave. [Privacy and data inventory](https://nuxt-backend.dev/docs/ship/compliance/privacy) lists it.

For a workspace your own code dissolves, call `billing.forgetEntity(ctx, workspaceId)`. It drops the entity's cache and quota counts, and leaves the provider's customer as it is.

## Environment

Two variables configure billing, and `BACKEND_ENVIRONMENT` picks which Polar they talk to: `production` bills live, and every other value bills in Polar's sandbox ([Environments and deployments](https://nuxt-backend.dev/docs/start/concepts/environments#sandbox-and-production-providers)).

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Purpose
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        BILLING_ACCESS_TOKEN
      </code>
    </td>
    
    <td>
      The Polar organization's access token: a sandbox one outside production, a live one in production. Unset, billing reads answer empty and provider calls are refused as <code>
        unavailable
      </code>
      
       (reason <code>
        not_configured
      </code>
      
      ); on production, billing is <a href="#before-billing-launches">
        not launched
      </a>
      
       yet. Workspaces need its <code>
        members:write
      </code>
      
       and <code>
        customer_sessions:write
      </code>
      
       scopes too, for team customers and the member's portal.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BILLING_WEBHOOK_SECRET
      </code>
    </td>
    
    <td>
      Verifies deliveries to <code>
        /billing/events
      </code>
      
      . Unset, the endpoint answers <code>
        503
      </code>
      
      , and entitlements refresh only on demand (<code>
        syncEntitlements
      </code>
      
      ). <code>
        billing sync
      </code>
      
       stores it when it creates the endpoint.
    </td>
  </tr>
</tbody>
</table>

`npx nuxt-backend env push` forwards both from `.env.local` to the deployment, and derives `BACKEND_ENVIRONMENT` from `CONVEX_DEPLOYMENT`. They live on the Convex deployment, not in the Nuxt app: see [Environment variables](https://nuxt-backend.dev/docs/reference/configuration/environment-variables#convex-deployment-variables). `BACKEND_ENVIRONMENT` replaces the `BILLING_ENVIRONMENT` of earlier previews.

## Before billing launches

A production deployment can open before its billing does: Polar reviews an organization before it takes payments for it, and an app in [early access](https://nuxt-backend.dev/docs/build/growth/launch) admits its first people by invitation. Until the production deployment holds `BILLING_ACCESS_TOKEN` and a production catalog, billing is **not launched**:

- **The package's pricing and gift views say so.** `getPricing` answers `launched: false`, `<PricingTable>` reads "Plans open soon" (the `pricing.soon` label, or its `soon` slot) with no plan, pack or switch, and the gifts page says gifts open with the plans (`gift.soon`).
- **Your own links can follow.** `usePricing().launched` is `false`: hide your pricing, gift and terms-of-sale links on it. In server code, `billing.launch` is `{ launched: false, reason }`, the reason `no_access_token` or `no_catalog`.
- **Nothing can be bought.** A checkout, a gift checkout and a switch to a paid plan are refused as `unavailable` (reason `not_launched`), whose label reads "Plans open soon", before anything reaches Polar.
- **The free plan waits too.** Nobody is a Polar customer yet, so no workspace starts on the free plan. Once billing launches, run the backfill, `npx convex run --prod billing:startFreePlan '{}'`: everyone who joined meanwhile starts on it, with its [welcome credits](https://nuxt-backend.dev/docs/build/billing/catalog#welcome-credits).

Every other deployment bills in Polar's sandbox, where billing is always launched and a missing token stays `not_configured`. Launching is the steps below.

`npx nuxt-backend doctor --prod` reports the state as [`billing-launch`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing-launch): a warning naming what production still lacks, with the steps that launch it. Until billing launches, the token, the webhook secret and the production catalog findings warn rather than fail, and `status --prod` reads billing as missing, not failing.

## Go live

<steps level="3">

### Create the production organization

Create an organization on Polar's production server, and an access token there with the scopes above. A sandbox token does not work in production.

### Set the token on the production deployment

Set `BILLING_ACCESS_TOKEN` on the production deployment. Its `BACKEND_ENVIRONMENT` is `production`, which `env push` derives from a `prod:` deployment.

### Sync the catalog to production

With the production deployment's `CONVEX_DEPLOY_KEY` in the shell and the production token as `BILLING_ACCESS_TOKEN`, run `npx nuxt-backend billing sync --env production`. The sync writes the `production` entry of `billing.generated.ts`, creates the webhook endpoint at the deployment's HTTP origin (or the URL `--webhook` names), and stores its secret there. Commit the file and deploy it with the backend.

### Check it

Run `npx nuxt-backend doctor --prod`, and fix what it reports for billing: [`billing-launch`](https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing-launch) passes once the token and the catalog are there, then the catalog's production ids, the webhook route, the token's access, and the organization settings the catalog relies on, such as trial-abuse prevention for a plan with a trial.

</steps>

The [Production checklist](https://nuxt-backend.dev/docs/ship/checklist) has the whole list across capabilities.

## What happens when…

A refused call throws a [refusal](https://nuxt-backend.dev/docs/reference/backend/errors) you can branch on, and a reactive read answers `null` instead:

<table>
<thead>
  <tr>
    <th>
      Refusal
    </th>
    
    <th>
      When
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        unauthenticated
      </code>
    </td>
    
    <td>
      Nobody is signed in.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        no_workspace
      </code>
    </td>
    
    <td>
      The session has no active workspace.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        banned
      </code>
    </td>
    
    <td>
      The account was banned after its token was minted.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        not_member
      </code>
    </td>
    
    <td>
      The caller is no longer a member of the workspace.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        not_billing_manager
      </code>
    </td>
    
    <td>
      A member who is neither its owner nor an admin.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        impersonating
      </code>
    </td>
    
    <td>
      A call the table refuses to an impersonating administrator.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        admin_only
      </code>
    </td>
    
    <td>
      An admin function, and the account is no admin.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        provider_owner_only
      </code>
    </td>
    
    <td>
      A workspace admin opened the portal (<a href="#the-billing-portal">
        The billing portal
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        customer_taken
      </code>
    </td>
    
    <td>
      An individual customer's email belongs to another customer at Polar.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        reauthentication_required
      </code>
    </td>
    
    <td>
      <code>
        refundOrder
      </code>
      
       with a sign-in older than ten minutes (<a href="https://nuxt-backend.dev/docs/build/auth/access/step-up">
        Require a recent sign-in
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        unavailable
      </code>
      
      , reason <code>
        not_configured
      </code>
    </td>
    
    <td>
      No <code>
        BILLING_ACCESS_TOKEN
      </code>
      
       on the deployment (<a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-billing-access-token">
        <code>
          deployment-billing-access-token
        </code>
      </a>
      
      ).
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        not_ready
      </code>
      
      , reason <code>
        no_catalog
      </code>
    </td>
    
    <td>
      No catalog for this environment: run <code>
        npx nuxt-backend billing sync
      </code>
      
       for it, and deploy <code>
        billing.generated.ts
      </code>
      
      .
    </td>
  </tr>
</tbody>
</table>

And when a symptom shows instead of a refusal:

<table>
<thead>
  <tr>
    <th>
      Symptom
    </th>
    
    <th>
      Fix
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        /pricing
      </code>
      
       shows no plans
    </td>
    
    <td>
      The deployment's products table is empty: run <code>
        npx convex run billing:syncProducts
      </code>
      
       once, or <code>
        billing sync
      </code>
      
       again.
    </td>
  </tr>
  
  <tr>
    <td>
      Plans don't update after a purchase
    </td>
    
    <td>
      The webhook is not reaching the deployment: see <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing-webhook-secret">
        <code>
          billing-webhook-secret
        </code>
      </a>
      
       and <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing-webhook-route">
        <code>
          billing-webhook-route
        </code>
      </a>
      
      . A local deployment gets no webhooks: <a href="https://nuxt-backend.dev/docs/develop/sandboxes#billing-on-polars-sandbox">
        Develop with real sandboxes
      </a>
      
       says what to do.
    </td>
  </tr>
  
  <tr>
    <td>
      A workspace admin can't open the portal
    </td>
    
    <td>
      The package registers only the owner as a billing manager at Polar: see <a href="#the-billing-portal">
        The billing portal
      </a>
      
      .
    </td>
  </tr>
</tbody>
</table>

## Limits

- **No seats.** A plan here never counts people, and a workspace is never billed per member ([Principles](https://nuxt-backend.dev/docs/start/concepts/principles#what-it-never-does)). Polar's seat-based pricing is beta and stays out of the catalog.
- **Built-in roles only.** The owner and admins manage billing, and every other member reads and spends. Billing as a permission you grant to a role of your own, and acting for another workspace than the active one, wait for a later release, with custom workspace roles ([Roadmap](https://nuxt-backend.dev/docs/start/roadmap)).
- **The portal is the owner's.** Polar's team customer has one billing manager the package registers: the workspace's owner.
- **One provider.** The catalog, the cache and the customer mapping are built on Polar's customers, products, benefits and meters.

## Test it

`asUser` from `nuxt-backend/test` signs a test caller in the way a real session does, so `requireEntity` reads the member table as in production:

```ts [backend/invoicing.test.ts]
import { getBackendError } from 'nuxt-backend/functions'
import { asUser, defineBackendTestApp, seedWorkspace } from 'nuxt-backend/test'
import { expect, test } from 'vitest'
import { api } from './_generated/api'
import schema from './schema'

const testApp = defineBackendTestApp(schema, import.meta.glob('./**/*.ts'))

test('only a billing manager sets the invoice address', async () => {
  const t = testApp()
  const workspace = await seedWorkspace(t)
  const owner = await asUser(t, { workspace, workspaceRole: 'owner' })
  const member = await asUser(t, { workspace })

  await owner.mutation(api.invoicing.setInvoiceAddress, { address: '1 Panel Street' })
  const refusal = await member.mutation(api.invoicing.setInvoiceAddress, { address: '2 Gutter Lane' }).catch(getBackendError)
  expect(refusal).toMatchObject({ code: 'forbidden', data: { reason: 'not_billing_manager' } })
})
```

Then check the deployment itself:

- `npx nuxt-backend status` shows the billing capability as `live`, or `test` while it runs in Polar's sandbox.
- `npx nuxt-backend doctor --only billing` runs every billing finding. Each one's id opens its entry on [Diagnostics](https://nuxt-backend.dev/docs/reference/cli/diagnostics#billing).
- The DevTools [Billing tab](https://nuxt-backend.dev/docs/develop/devtools#billing) shows the entity's plans, entitlements, quotas and webhook deliveries. The demo's [pricing page](https://nuxt-backend.dev/playground/pricing) runs checkout on Polar's sandbox, and its [settings page](https://nuxt-backend.dev/playground/settings) the plan, the portal and the credits.

## Related

- [Polar](https://nuxt-backend.dev/docs/services/polar): the account, the tokens and their scopes, and the sandbox.
- [Define and sync your catalog](https://nuxt-backend.dev/docs/build/billing/catalog): what to sell, and the generated id map.
- [Open checkout and the portal](https://nuxt-backend.dev/docs/build/billing/subscriptions/checkout): what the server checks on every checkout and plan change.
- [Define roles and permissions](https://nuxt-backend.dev/docs/build/auth/access/roles): app roles, the built-in workspace roles and fresh reads.
- [Billing API reference](https://nuxt-backend.dev/docs/reference/api/billing): every option and method, generated from the code.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
