---
title: "nuxt-backend/billing"
description: "Every export of nuxt-backend/billing, with its signature and where it is defined."
canonical_url: "https://nuxt-backend.dev/docs/reference/api/billing"
---
# nuxt-backend/billing

## Interfaces

### CatalogCreditGrant

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

A credit grant a plan or pack carries (a provider meter-credit benefit).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meter">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The catalog meter key the credits land on.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="units">
        
      </a>
      
       <code>
        units
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Units granted (per cycle for plans, once for packs).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="rollover">
        
      </a>
      
       <code>
        rollover?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Carry unused credits into the next cycle. Defaults to <code>
        false
      </code>
      
       for plan grants (use-it-or-lose-it monthly allowances) and <code>
        true
      </code>
      
       for packs (purchased credits keep).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CatalogMeter

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

A usage meter, keyed by the event name spends use (`spendCredits({ meter })`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="aggregation">
        
      </a>
      
       <code>
        aggregation?
      </code>
    </td>
    
    <td>
      <code>
        "count"
      </code>
      
       | <code>
        "sum"
      </code>
    </td>
    
    <td>
      How events aggregate: <code>
        'sum'
      </code>
      
       (default) sums <code>
        property
      </code>
      
       across events — multi-credit spends in one event; <code>
        'count'
      </code>
      
       counts events (1 credit per event, not refundable).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property">
        
      </a>
      
       <code>
        property?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The metadata property summed by <code>
        'sum'
      </code>
      
       meters. Default <code>
        'amount'
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="eventname">
        
      </a>
      
       <code>
        eventName?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Event name the meter filters on. Defaults to the catalog key.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CatalogPlan

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

A subscription plan (recurring product).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="description">
        
      </a>
      
       <code>
        description?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="interval">
        
      </a>
      
       <code>
        interval
      </code>
    </td>
    
    <td>
      <code>
        "month"
      </code>
      
       | <code>
        "year"
      </code>
    </td>
    
    <td>
      Billing interval.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="price">
        
      </a>
      
       <code>
        price
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Price in cents.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="credits">
        
      </a>
      
       <code>
        credits?
      </code>
    </td>
    
    <td>
      <a href="#catalogcreditgrant">
        <code>
          CatalogCreditGrant
        </code>
      </a>
    </td>
    
    <td>
      Credits included with the plan, granted every cycle.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="features">
        
      </a>
      
       <code>
        features?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Feature-benefit keys (from <a href="#features-1">
        BillingCatalog.features
      </a>
      
      ) this plan grants.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="trial">
        
      </a>
      
       <code>
        trial?
      </code>
    </td>
    
    <td>
      <code>
        CatalogTrial
      </code>
    </td>
    
    <td>
      Free trial before the first charge.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="usage">
        
      </a>
      
       <code>
        usage?
      </code>
    </td>
    
    <td>
      <code>
        CatalogUsagePrice
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Metered prices charged on top of <code>
        price
      </code>
      
       (pay-as-you-go overage).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="taxbehavior">
        
      </a>
      
       <code>
        taxBehavior?
      </code>
    </td>
    
    <td>
      <code>
        CatalogTaxBehavior
      </code>
    </td>
    
    <td>
      Tax treatment of the price. Defaults to the organization's setting.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="customfields">
        
      </a>
      
       <code>
        customFields?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Checkout field keys (from <a href="#customfields-2">
        BillingCatalog.customFields
      </a>
      
      ) to collect.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CatalogPack

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

A one-time credit pack.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name-1">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="description-1">
        
      </a>
      
       <code>
        description?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="price-1">
        
      </a>
      
       <code>
        price
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Price in cents.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="credits-1">
        
      </a>
      
       <code>
        credits
      </code>
    </td>
    
    <td>
      <a href="#catalogcreditgrant">
        <code>
          CatalogCreditGrant
        </code>
      </a>
    </td>
    
    <td>
      Credits granted once at purchase.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="taxbehavior-1">
        
      </a>
      
       <code>
        taxBehavior?
      </code>
    </td>
    
    <td>
      <code>
        CatalogTaxBehavior
      </code>
    </td>
    
    <td>
      Tax treatment of the price. Defaults to the organization's setting.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="customfields-1">
        
      </a>
      
       <code>
        customFields?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Checkout field keys (from <a href="#customfields-2">
        BillingCatalog.customFields
      </a>
      
      ) to collect.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CatalogFeature

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

A feature benefit, gate-checked client-side via `useFeatures().has(key)`.
Pushed as the provider's native feature-flag benefit; the catalog key rides
along in the benefit metadata, which is what the gate matches on.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="description-2">
        
      </a>
      
       <code>
        description
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingCatalog

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="currency">
        
      </a>
      
       <code>
        currency?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO 4217 currency every <code>
        price
      </code>
      
       is created in, lowercase (<code>
        'usd'
      </code>
      
      , <code>
        'eur'
      </code>
      
      ). Defaults to the organization's default presentment currency, which the provider requires on every product.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meters">
        
      </a>
      
       <code>
        meters?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#catalogmeter">
        <code>
          CatalogMeter
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="plans">
        
      </a>
      
       <code>
        plans?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#catalogplan">
        <code>
          CatalogPlan
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="packs">
        
      </a>
      
       <code>
        packs?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#catalogpack">
        <code>
          CatalogPack
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="features-1">
        
      </a>
      
       <code>
        features?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#catalogfeature">
        <code>
          CatalogFeature
        </code>
      </a>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="customfields-2">
        
      </a>
      
       <code>
        customFields?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        CatalogCustomField
      </code>
      
      >
    </td>
    
    <td>
      Checkout fields plans and packs can collect, keyed by catalog key.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts" rel="nofollow">
        src/convex/catalog.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingRateLimiter

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

A structural rate limiter for throttling `syncEntitlements` — satisfied by
`setupRateLimiter(...)` from `nuxt-backend/rate-limit`, which seeds the
`billingSync` limit by default. Kept structural (rather than importing the
rate-limiter's own type) so any compatible limiter is assignable.

#### Methods

##### limit()

```ts
limit(
   ctx, 
   name, 
   options?
): Promise<{
  ok: boolean;
  retryAfter?: number;
}>;
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

###### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx
      </code>
    </td>
    
    <td>
      <code>
        RunWriteCtx
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        "billingSync"
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options?
      </code>
    </td>
    
    <td>
      { <code>
        key?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        throws?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.key?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        options.throws?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
  </tr>
</tbody>
</table>

###### Returns

`Promise`<{
`ok`: `boolean`;
`retryAfter?`: `number`;
}>

---

### SubscriptionTarget

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Shared addressing for the subscription-lifecycle operations.

#### Extended by

- [`UpdateSubscriptionOptions`](#updatesubscriptionoptions)
- [`CancelSubscriptionOptions`](#cancelsubscriptionoptions)
- [`PauseSubscriptionOptions`](#pausesubscriptionoptions)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="subscriptionid">
        
      </a>
      
       <code>
        subscriptionId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which subscription to act on. Omit for the account's single live subscription — required once <code>
        multipleSubscriptions
      </code>
      
       (<a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ) is on and an entity can hold several at once.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UpdateSubscriptionOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.updateSubscription](#updatesubscription) (upgrade / downgrade).

#### Extends

- [`SubscriptionTarget`](#subscriptiontarget)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="subscriptionid-1">
        
      </a>
      
       <code>
        subscriptionId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which subscription to act on. Omit for the account's single live subscription — required once <code>
        multipleSubscriptions
      </code>
      
       (<a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ) is on and an entity can hold several at once.
    </td>
    
    <td>
      <a href="#subscriptiontarget">
        <code>
          SubscriptionTarget
        </code>
      </a>
      
      .<a href="#subscriptionid">
        <code>
          subscriptionId
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="productid">
        
      </a>
      
       <code>
        productId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The product to switch to.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="proration">
        
      </a>
      
       <code>
        proration?
      </code>
    </td>
    
    <td>
      <a href="#prorationbehavior">
        <code>
          ProrationBehavior
        </code>
      </a>
    </td>
    
    <td>
      How to settle the mid-period money difference.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CancelSubscriptionOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.cancelSubscription](#cancelsubscription).

#### Extends

- [`SubscriptionTarget`](#subscriptiontarget)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="subscriptionid-2">
        
      </a>
      
       <code>
        subscriptionId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which subscription to act on. Omit for the account's single live subscription — required once <code>
        multipleSubscriptions
      </code>
      
       (<a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ) is on and an entity can hold several at once.
    </td>
    
    <td>
      <a href="#subscriptiontarget">
        <code>
          SubscriptionTarget
        </code>
      </a>
      
      .<a href="#subscriptionid">
        <code>
          subscriptionId
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="atperiodend">
        
      </a>
      
       <code>
        atPeriodEnd?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Keep the subscription running until the period it is paid for ends (default). <code>
        false
      </code>
      
       revokes it immediately — benefits are withdrawn on the spot and the remainder is not refunded.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reason">
        
      </a>
      
       <code>
        reason?
      </code>
    </td>
    
    <td>
      <a href="#cancellationreason">
        <code>
          CancellationReason
        </code>
      </a>
    </td>
    
    <td>
      The customer's own churn reason.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="comment">
        
      </a>
      
       <code>
        comment?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The customer's own words. Never an internal note — they can read it back.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### PauseSubscriptionOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.pauseSubscription](#pausesubscription).

#### Extends

- [`SubscriptionTarget`](#subscriptiontarget)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Inherited from
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="subscriptionid-3">
        
      </a>
      
       <code>
        subscriptionId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which subscription to act on. Omit for the account's single live subscription — required once <code>
        multipleSubscriptions
      </code>
      
       (<a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ) is on and an entity can hold several at once.
    </td>
    
    <td>
      <a href="#subscriptiontarget">
        <code>
          SubscriptionTarget
        </code>
      </a>
      
      .<a href="#subscriptionid">
        <code>
          subscriptionId
        </code>
      </a>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resumesat">
        
      </a>
      
       <code>
        resumesAt?
      </code>
    </td>
    
    <td>
      <code>
        Date
      </code>
    </td>
    
    <td>
      When the paused subscription resumes by itself (must be after the current period ends). Omit to pause until it is resumed by hand.
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### OrdersOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.getOrders](#getorders).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="limit-1">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Orders per page (1–100, default 10).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cursor">
        
      </a>
      
       <code>
        cursor?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      An opaque page token from a previous page's <code>
        nextCursor
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="page">
        
      </a>
      
       <code>
        page?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The provider's 1-based page number — the raw form of <code>
        cursor
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingPage

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

A page of provider records, plus the token that reads the next one.

#### Type Parameters

<table>
<thead>
  <tr>
    <th>
      Type Parameter
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="type-parameter-item">
        
      </a>
      
       <code>
        Item
      </code>
    </td>
  </tr>
</tbody>
</table>

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="items">
        
      </a>
      
       <code>
        items
      </code>
    </td>
    
    <td>
      <code>
        Item
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pagination">
        
      </a>
      
       <code>
        pagination
      </code>
    </td>
    
    <td>
      { <code>
        totalCount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        maxPage
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pagination.totalCount
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        pagination.maxPage
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="nextcursor">
        
      </a>
      
       <code>
        nextCursor?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Pass back as <code>
        cursor
      </code>
      
       to read the next page; absent on the last one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UsageHistoryOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.getUsageHistory](#getusagehistory).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meter-1">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Which meter's consumption to read: a configured credit-meter name (<code>
        'credits'
      </code>
      
      ) or a raw meter id. Omit for every ingested event on the account.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-2">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Events per page (1–100, default 10).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cursor-1">
        
      </a>
      
       <code>
        cursor?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      An opaque page token from a previous page's <code>
        nextCursor
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="page-1">
        
      </a>
      
       <code>
        page?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The provider's 1-based page number — the raw form of <code>
        cursor
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="starttimestamp">
        
      </a>
      
       <code>
        startTimestamp?
      </code>
    </td>
    
    <td>
      <code>
        Date
      </code>
    </td>
    
    <td>
      Only events at or after this moment.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="endtimestamp">
        
      </a>
      
       <code>
        endTimestamp?
      </code>
    </td>
    
    <td>
      <code>
        Date
      </code>
    </td>
    
    <td>
      Only events at or before this moment.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RefundOrderOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Options for [Billing.refundOrder](#refundorder).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="orderid">
        
      </a>
      
       <code>
        orderId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="amount">
        
      </a>
      
       <code>
        amount?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Amount to refund in the currency's minor unit (cents). Omit to refund everything still refundable on the order.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reason-1">
        
      </a>
      
       <code>
        reason
      </code>
    </td>
    
    <td>
      <a href="#refundreason">
        <code>
          RefundReason
        </code>
      </a>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="revokebenefits">
        
      </a>
      
       <code>
        revokeBenefits?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Withdraw the order's benefits as well. The provider only allows this for one-time purchases — a subscription's benefits are withdrawn when the subscription itself is revoked.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="metadata">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Extra key-value data stored on the refund.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RefundRecord

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

The outcome of [Billing.refundOrder](#refundorder), JSON-normalized.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="orderid-1">
        
      </a>
      
       <code>
        orderId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reason-2">
        
      </a>
      
       <code>
        reason
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="amount-1">
        
      </a>
      
       <code>
        amount
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Refunded amount in the currency's minor unit (cents).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="currency-1">
        
      </a>
      
       <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="revokebenefits-1">
        
      </a>
      
       <code>
        revokeBenefits
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### DiscountListOptions

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Filters for [BillingDiscounts.list](#list).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="query">
        
      </a>
      
       <code>
        query?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Match against the discount's name.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="limit-3">
        
      </a>
      
       <code>
        limit?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Discounts per page (1–100, default 10).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="page-2">
        
      </a>
      
       <code>
        page?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The provider's 1-based page number.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingDiscounts

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Discount (coupon) management. Privileged by design — a public action that
mints discounts would let anyone create a 100%-off code — so these are
server-side methods, not registered functions: call them from an
`internalAction` or an admin-tier action of your own.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="create">
        
      </a>
      
       <code>
        create
      </code>
    </td>
    
    <td>
      (<code>
        discount
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        code
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }>
    </td>
    
    <td>
      Create a discount / coupon. Accepts the full provider shape (fixed or percentage).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="list">
        
      </a>
      
       <code>
        list
      </code>
    </td>
    
    <td>
      (<code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#billingpage">
        <code>
          BillingPage
        </code>
      </a>
      
      <<code>
        Discount
      </code>
      
      >>
    </td>
    
    <td>
      List discounts (newest provider order), one page at a time.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="remove">
        
      </a>
      
       <code>
        remove
      </code>
    </td>
    
    <td>
      (<code>
        discountId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Permanently delete a discount. Redemptions already applied stay applied.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CheckoutPrefill

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Pre-filled customer details for a checkout session. Every field is only a
default the customer can still change — the provider owns the form.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name-2">
        
      </a>
      
       <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email">
        
      </a>
      
       <code>
        email?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billingname">
        
      </a>
      
       <code>
        billingName?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The name that should appear on the invoice, when it differs from <code>
        name
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billingaddress">
        
      </a>
      
       <code>
        billingAddress?
      </code>
    </td>
    
    <td>
      { <code>
        country
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        line1?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        line2?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        postalCode?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        city?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        state?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.country
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      ISO 3166-1 alpha-2 country code — the one field the provider requires.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.line1?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.line2?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.postalCode?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.city?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        billingAddress.state?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="taxid">
        
      </a>
      
       <code>
        taxId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      VAT / tax identification number.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="business">
        
      </a>
      
       <code>
        business?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Bill a business rather than an individual. Turning this on makes the provider require a full billing address and billing name.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CampaignAttribution

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Campaign attribution a checkout carries, as a campaign link's UTM
parameters. Stored on the order or subscription as flat `utm_source`,
`utm_medium`, … metadata, the way the provider's own checkout links store
it; each value is trimmed and cut to 100 characters.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="source">
        
      </a>
      
       <code>
        source?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="medium">
        
      </a>
      
       <code>
        medium?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="campaign">
        
      </a>
      
       <code>
        campaign?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="term">
        
      </a>
      
       <code>
        term?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="content">
        
      </a>
      
       <code>
        content?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CheckoutTrial

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

A trial the server grants at checkout in place of the product's own: 1 to
30 days, in days or weeks. No months: the provider counts a month as a
calendar month, up to 31 days.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="interval-1">
        
      </a>
      
       <code>
        interval
      </code>
    </td>
    
    <td>
      <code>
        "day"
      </code>
      
       | <code>
        "week"
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="count">
        
      </a>
      
       <code>
        count?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Number of intervals. Defaults to 1.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### EntitlementBenefit

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A single granted benefit (entitlement) in a customer's billing state.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-1">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="benefitid">
        
      </a>
      
       <code>
        benefitId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="type">
        
      </a>
      
       <code>
        type
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="metadata-2">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      The benefit's <strong>
        live
      </strong>
      
       provider metadata (read from the benefit, not the grant-time snapshot in customer state). Lets consumers feature-gate by a friendly key — set e.g. <code>
        { key: 'premium' }
      </code>
      
       on the benefit and check <code>
        useFeatures().has('premium')
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### EntitlementMeter

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A credit-meter balance in a customer's billing state (prepaid credits).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meterid">
        
      </a>
      
       <code>
        meterId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="consumedunits">
        
      </a>
      
       <code>
        consumedUnits
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="creditedunits">
        
      </a>
      
       <code>
        creditedUnits
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="balance">
        
      </a>
      
       <code>
        balance
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cyclestart">
        
      </a>
      
       <code>
        cycleStart?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      The granting subscription's current period (epoch ms) — a meter has no period of its own in the provider's model. Absent for meters granted only by one-time credit packs.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cycleend">
        
      </a>
      
       <code>
        cycleEnd?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="rollover-1">
        
      </a>
      
       <code>
        rollover?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Whether unspent credited units carry into the next cycle.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CustomerEntitlements

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A user's full billing entitlement state — active plans, granted benefits, and
credit-meter balances — normalized for caching into the reactive component table.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="customerid">
        
      </a>
      
       <code>
        customerId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="activeproductids">
        
      </a>
      
       <code>
        activeProductIds
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="benefits">
        
      </a>
      
       <code>
        benefits
      </code>
    </td>
    
    <td>
      <a href="#entitlementbenefit">
        <code>
          EntitlementBenefit
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meters-1">
        
      </a>
      
       <code>
        meters
      </code>
    </td>
    
    <td>
      <a href="#entitlementmeter">
        <code>
          EntitlementMeter
        </code>
      </a>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CreditMeterConfig

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A named credit meter: how a spend by friendly name (`meter: 'credits'`)
resolves to the provider meter and its ingestion shape. Declared in
`setupBilling({ credits })` or generated into `billing.generated.ts` by
`nuxt-backend billing sync`.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="meterid-1">
        
      </a>
      
       <code>
        meterId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The provider meter id the balance guard runs against.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="eventname-1">
        
      </a>
      
       <code>
        eventName?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Event name the meter's filter matches. Defaults to the config key.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="property-1">
        
      </a>
      
       <code>
        property?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      For sum-aggregation meters: the metadata property carrying the amount — ingested as <code>
        metadata[property] = value
      </code>
      
      . Omit for count meters (which count events, so each spend is exactly 1 credit).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingCatalogIds

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

The environment-keyed id map `nuxt-backend billing sync` generates.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="products">
        
      </a>
      
       <code>
        products?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      Catalog key → provider product id (plans and packs).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="packs-1">
        
      </a>
      
       <code>
        packs?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The catalog keys of <code>
        products
      </code>
      
       that are credit packs: what a gift may buy.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="gifts">
        
      </a>
      
       <code>
        gifts?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      Pack key → the provider id of its private gift product: the same prices, no benefits, bought by a purchaser for someone else. Never sold on its own, so it is outside <code>
        products
      </code>
      
       and the checkout allow-list.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meters-2">
        
      </a>
      
       <code>
        meters?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#creditmeterconfig">
        <code>
          CreditMeterConfig
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Catalog key → credit meter config.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SpendCreditsEvent

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A prepaid-credit consumption event (drawn from the customer's meter balance).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The billing entity id — the workspace id (<code>
        billTo: 'organization'
      </code>
      
      , the default) or the auth user id (<code>
        billTo: 'user'
      </code>
      
      ). Omit to resolve it from the caller's identity (the active workspace / signed-in user).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-2">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      A configured credit meter name (<code>
        setupBilling({ credits })
      </code>
      
       / catalog key) — the preferred spend target: resolves the meter id, event name, and ingestion shape in one word.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="name-3">
        
      </a>
      
       <code>
        name?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The meter event name. Defaults to the configured meter's <code>
        eventName
      </code>
      
      /key.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meterid-2">
        
      </a>
      
       <code>
        meterId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      A raw credit meter id to guard against (escape hatch when no named meter config exists). When a meter resolves (by <code>
        meter
      </code>
      
       or <code>
        meterId
      </code>
      
      ), the spend is <strong>
        reserved
      </strong>
      
       against the cached balance first and <strong>
        blocked
      </strong>
      
       (throws) if it is below <code>
        value
      </code>
      
       — keeping credits strictly prepaid (never billed as overage). The reservation settles after the provider event ingests, or releases on failure, so a failed run never consumes credits.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="value">
        
      </a>
      
       <code>
        value?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Credits required for this spend (default <code>
        1
      </code>
      
      ): a finite number above zero. Anything else is refused before the balance or the provider sees it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="allowoverage">
        
      </a>
      
       <code>
        allowOverage?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Let the balance go negative instead of refusing the spend — the pay-as-you-go case: the meter has no credit benefit behind it, so every unit is overage the provider invoices at the end of the cycle. Off by default: credits stay strictly prepaid.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="metadata-3">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Event properties used by the meter's aggregation/filter.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="externalid">
        
      </a>
      
       <code>
        externalId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Idempotency key to prevent double-counting (defaults to a random UUID).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="timestamp">
        
      </a>
      
       <code>
        timestamp?
      </code>
    </td>
    
    <td>
      <code>
        Date
      </code>
    </td>
    
    <td>
      Event time (defaults to now).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SpendReservation

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A credit reservation's addressing data — serializable, so a spend can
reserve in one function and settle/release in another (the streaming HTTP
dispatcher does exactly that). Being plain data, it is checked again when it
settles: a `value` that is not a finite number above zero is refused.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="entityid">
        
      </a>
      
       <code>
        entityId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The billing entity the spend belongs to.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="externalid-1">
        
      </a>
      
       <code>
        externalId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Idempotency key shared by the reservation and the provider event.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reserved">
        
      </a>
      
       <code>
        reserved
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Whether a meter guard actually reserved cached balance.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-3">
        
      </a>
      
       <code>
        meter?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The configured meter name (when reserved via one).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meterid-3">
        
      </a>
      
       <code>
        meterId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The raw meter id (when reserved).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="value-1">
        
      </a>
      
       <code>
        value
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Credits reserved.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### RefundCreditsEvent

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A prepaid-credit refund (compensating event on a sum meter).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid-1">
        
      </a>
      
       <code>
        userId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The billing entity id; omit to resolve from the caller's identity.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="meter-4">
        
      </a>
      
       <code>
        meter
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The configured credit meter name to refund on (must be a sum meter).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="value-2">
        
      </a>
      
       <code>
        value
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Credits to give back: a finite number above zero.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="metadata-4">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Extra event properties.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="externalid-2">
        
      </a>
      
       <code>
        externalId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Idempotency key (defaults to a random UUID).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### GiftRecord

Defined in: [src/convex/integrations/billing/types/records.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts)

A gift purchase record, as stored by the `backend` component
(`components.backend.gifts.*`).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="id-2">
        
      </a>
      
       <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="recipientemail">
        
      </a>
      
       <code>
        recipientEmail
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="purchaseruserid">
        
      </a>
      
       <code>
        purchaserUserId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="purchaseremail">
        
      </a>
      
       <code>
        purchaserEmail?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Before 0.2 only: gifts no longer keep the purchaser's email.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="purchasername">
        
      </a>
      
       <code>
        purchaserName?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="productids-1">
        
      </a>
      
       <code>
        productIds
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      The credit pack's provider product: what the recipient's claim grants.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="message">
        
      </a>
      
       <code>
        message?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="status-1">
        
      </a>
      
       <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'pending'
      </code>
      
       (the purchaser's checkout is open) → <code>
        'paid'
      </code>
      
       (the purchase is paid and claimable) → <code>
        'claimed'
      </code>
      
      , or <code>
        'refunded'
      </code>
      
       when the purchase was refunded before the claim.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billingcustomerid">
        
      </a>
      
       <code>
        billingCustomerId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Before 0.2 only: the customer keyed by the recipient's email that the purchase was billed to.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billingorderid">
        
      </a>
      
       <code>
        billingOrderId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The purchase order, on the purchaser's own customer.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="purchaserentityid">
        
      </a>
      
       <code>
        purchaserEntityId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The billing entity that paid.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pack">
        
      </a>
      
       <code>
        pack?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The pack's catalog key.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="giftproductid">
        
      </a>
      
       <code>
        giftProductId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The private gift product the purchaser bought.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="amount-2">
        
      </a>
      
       <code>
        amount?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      What the purchase charged, in the currency's smallest unit.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="currency-2">
        
      </a>
      
       <code>
        currency?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="discountid">
        
      </a>
      
       <code>
        discountId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The single-use 100% discount the recipient claims the pack with.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claimingentityid">
        
      </a>
      
       <code>
        claimingEntityId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claiminguserid">
        
      </a>
      
       <code>
        claimingUserId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claimorderid">
        
      </a>
      
       <code>
        claimOrderId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claimedbyuserid">
        
      </a>
      
       <code>
        claimedByUserId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claimedentityid">
        
      </a>
      
       <code>
        claimedEntityId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="createdat">
        
      </a>
      
       <code>
        createdAt
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="paidat">
        
      </a>
      
       <code>
        paidAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="notifiedat">
        
      </a>
      
       <code>
        notifiedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      When the recipient's notification email went out — stamped only after the send succeeded.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="claimedat">
        
      </a>
      
       <code>
        claimedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="refundedat">
        
      </a>
      
       <code>
        refundedAt?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/records.ts" rel="nofollow">
        src/convex/integrations/billing/types/records.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingComponents

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

The component handles `setupBilling` reads from your generated `components`
object. Pass the whole object — each key is picked structurally:

- `polar` — the upstream billing-provider component (checkout / portal /
webhooks / customer mapping).
- `backend` — the package's all-in-one component: `billing` is the reactive
entitlement cache, `gifts` the gift-purchase records, and `email` (optional)
delivers gift notifications.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="polar">
        
      </a>
      
       <code>
        polar
      </code>
    </td>
    
    <td>
      <code>
        ComponentApi
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="backend">
        
      </a>
      
       <code>
        backend
      </code>
    </td>
    
    <td>
      { <code>
        billing
      </code>
      
      : { <code>
        getByUser
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        CachedEntitlements
      </code>
      
       | <code>
        null
      </code>
      
      >; <code>
        upsert
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        customerId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        activeProductIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        benefits
      </code>
      
      : <a href="#entitlementbenefit">
        <code>
          EntitlementBenefit
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        meters
      </code>
      
      : <a href="#entitlementmeter">
        <code>
          EntitlementMeter
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        userByCustomer
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        customerId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >; <code>
        entityProfile
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#entityprofile">
        <code>
          EntityProfile
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >; <code>
        claimTrial
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        holdMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markTrialUsed
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        reserveDiscountCode
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        max
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        windowMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, | { <code>
        reserved
      </code>
      
      : <code>
        true
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; } | { <code>
        reserved
      </code>
      
      : <code>
        false
      </code>
      
      ; <code>
        retryAfter
      </code>
      
      : <code>
        number
      </code>
      
      ; }>; <code>
        releaseDiscountCode
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        debit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>; <code>
        settle
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        release
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        credit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        clearPendingSpends
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        deleteByUser
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        getBenefitMetadata
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        benefitIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; <code>
        updatedAt
      </code>
      
      : <code>
        number
      </code>
      
      ; }<span>
        
      </span>
      
      >; <code>
        upsertBenefitMetadata
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entries
      </code>
      
      : { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; }<span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >; }; <code>
        gifts
      </code>
      
      : { <code>
        create
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        recipientEmail
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserEntityId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserName?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        pack?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        productIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        giftProductId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      >; <code>
        markPaid
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        billingOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        currency?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        setDiscount
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        discountId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markNotified
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        startClaim
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markClaimed
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        claimOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        markRefunded
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        listByEmail
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status?
      </code>
      
      : <code>
        "paid"
      </code>
      
       | <code>
        "claimed"
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
      <span>
        
      </span>
      
      >; <code>
        countBought
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        pendingSince
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        excludeGiftId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        count
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        oldest
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; }>; <code>
        get
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >; <code>
        personalEntity
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >; }; <code>
        webhooks
      </code>
      
      : <code>
        WebhookLogRefs
      </code>
      
      ; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing
      </code>
    </td>
    
    <td>
      { <code>
        getByUser
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        CachedEntitlements
      </code>
      
       | <code>
        null
      </code>
      
      >; <code>
        upsert
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        customerId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        activeProductIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        benefits
      </code>
      
      : <a href="#entitlementbenefit">
        <code>
          EntitlementBenefit
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        meters
      </code>
      
      : <a href="#entitlementmeter">
        <code>
          EntitlementMeter
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        userByCustomer
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        customerId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >; <code>
        entityProfile
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#entityprofile">
        <code>
          EntityProfile
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >; <code>
        claimTrial
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        holdMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markTrialUsed
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        reserveDiscountCode
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        max
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        windowMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, | { <code>
        reserved
      </code>
      
      : <code>
        true
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; } | { <code>
        reserved
      </code>
      
      : <code>
        false
      </code>
      
      ; <code>
        retryAfter
      </code>
      
      : <code>
        number
      </code>
      
      ; }>; <code>
        releaseDiscountCode
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        debit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>; <code>
        settle
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        release
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        credit
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        clearPendingSpends
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        deleteByUser
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        getBenefitMetadata
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        benefitIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; <code>
        updatedAt
      </code>
      
      : <code>
        number
      </code>
      
      ; }<span>
        
      </span>
      
      >; <code>
        upsertBenefitMetadata
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entries
      </code>
      
      : { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; }<span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.getByUser
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        CachedEntitlements
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.upsert
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        customerId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        activeProductIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        benefits
      </code>
      
      : <a href="#entitlementbenefit">
        <code>
          EntitlementBenefit
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; <code>
        meters
      </code>
      
      : <a href="#entitlementmeter">
        <code>
          EntitlementMeter
        </code>
      </a>
      
      <span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.userByCustomer
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        customerId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.entityProfile
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#entityprofile">
        <code>
          EntityProfile
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Who stands behind a workspace entity: its name, whether it is personal, its owner and the workspaces that owner owns; <code>
        null
      </code>
      
       for anything else.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.claimTrial
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        holdMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Hold the owner's one trial for this entity's checkout, or say no when it is spent or held for another entity.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.markTrialUsed
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        ownerUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Record that a subscription of this entity started its owner's trial.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.reserveDiscountCode
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        max
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        windowMs
      </code>
      
      : <code>
        number
      </code>
      
      ; }, | { <code>
        reserved
      </code>
      
      : <code>
        true
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; } | { <code>
        reserved
      </code>
      
      : <code>
        false
      </code>
      
      ; <code>
        retryAfter
      </code>
      
      : <code>
        number
      </code>
      
      ; }>
    </td>
    
    <td>
      Count one discount-code attempt for an entity before the provider is asked, in a fixed window of at most <code>
        max
      </code>
      
      : the window's start, or the wait once <code>
        max
      </code>
      
       are counted.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.releaseDiscountCode
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        windowStart
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Give back an attempt <code>
        reserveDiscountCode
      </code>
      
       counted, in the window it was counted in.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.debit
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        allowOverage?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, { <code>
        ok
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        balance
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        reason?
      </code>
      
      : <code>
        "no-row"
      </code>
      
       | <code>
        "no-meter"
      </code>
      
       | <code>
        "insufficient"
      </code>
      
      ; }>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.settle
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        finalAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.release
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        externalId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.credit
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        meterId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.clearPendingSpends
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Drop every in-flight spend reservation for one entity, without re-crediting: used after a refund, where the provider's balance is already the truth and re-subtracting local reservations would push the cache below it.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.deleteByUser
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Delete one entity's entitlement cache row (account erasure).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.getBenefitMetadata
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        benefitIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; }, { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; <code>
        updatedAt
      </code>
      
      : <code>
        number
      </code>
      
      ; }<span>
        
      </span>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.billing.upsertBenefitMetadata
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        entries
      </code>
      
      : { <code>
        benefitId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >; }<span>
        
      </span>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts
      </code>
    </td>
    
    <td>
      { <code>
        create
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        recipientEmail
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserEntityId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserName?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        pack?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        productIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        giftProductId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      >; <code>
        markPaid
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        billingOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        currency?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        setDiscount
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        discountId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markNotified
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        startClaim
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        markClaimed
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        claimOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >; <code>
        markRefunded
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >; <code>
        listByEmail
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status?
      </code>
      
      : <code>
        "paid"
      </code>
      
       | <code>
        "claimed"
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
      <span>
        
      </span>
      
      >; <code>
        countBought
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        pendingSince
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        excludeGiftId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        count
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        oldest
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; }>; <code>
        get
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >; <code>
        personalEntity
      </code>
      
      : <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >; }
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.create
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        recipientEmail
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserEntityId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        purchaserName?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        pack?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        productIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        giftProductId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.markPaid
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        billingOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        amount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        currency?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.setDiscount
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        discountId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.markNotified
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.startClaim
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.markClaimed
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        entityId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        claimOrderId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.markRefunded
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "mutation"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.listByEmail
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        status?
      </code>
      
      : <code>
        "paid"
      </code>
      
       | <code>
        "claimed"
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
      <span>
        
      </span>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.countBought
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        purchaserUserId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        since
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        pendingSince
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        excludeGiftId?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, { <code>
        count
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        oldest
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; }>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.get
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        giftId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <a href="#giftrecord">
        <code>
          GiftRecord
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.gifts.personalEntity
      </code>
    </td>
    
    <td>
      <a href="https://docs.convex.dev/api/modules/server#functionreference" rel="nofollow">
        <code>
          FunctionReference
        </code>
      </a>
      
      <<code>
        "query"
      </code>
      
      , <code>
        "internal"
      </code>
      
      , { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        backend.webhooks
      </code>
    </td>
    
    <td>
      <code>
        WebhookLogRefs
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### EntityProfile

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

A workspace entity as its provider customer needs it: the team customer is
named after the workspace and owned by its owner, a personal workspace may
adopt its owner's earlier customer, and one trial counts across every
workspace the owner owns.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="name-4">
        
      </a>
      
       <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="personal">
        
      </a>
      
       <code>
        personal
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="owner">
        
      </a>
      
       <code>
        owner
      </code>
    </td>
    
    <td>
      | { <code>
        userId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        email
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        emailVerified
      </code>
      
      : <code>
        boolean
      </code>
      
      ; } | <code>
        null
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ownedentityids">
        
      </a>
      
       <code>
        ownedEntityIds
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingEntity

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

Who a billing operation runs for: the entity that owns the subscription and
the credits — a workspace, or a user with `billTo: 'user'` — and the email
the provider customer is created with. `userId` is the entity's id either
way.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="userid-2">
        
      </a>
      
       <code>
        userId
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="email-1">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingEntityCtx

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

The context [SetupBillingConfig.resolveEntity](#resolveentity) receives: the caller's
auth, and `runQuery` to read the app's own tables. Queries, mutations and
actions all provide both, so one resolver serves the reactive reads and the
provider calls alike. `auth` is always there; an internal call with no
caller has a `null` identity.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="auth">
        
      </a>
      
       <code>
        auth
      </code>
    </td>
    
    <td>
      <code>
        Auth
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="runquery">
        
      </a>
      
       <code>
        runQuery
      </code>
    </td>
    
    <td>
      <<code>
        Query
      </code>
      
      >(<code>
        query
      </code>
      
      , ...<code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        FunctionReturnType
      </code>
      
      <<code>
        Query
      </code>
      
      >>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### SetupBillingConfig

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

Billing configuration: every option `setupBilling` reads, and nothing else.
The access token, environment and webhook secret default to the required
`BILLING_ACCESS_TOKEN` / `BILLING_ENVIRONMENT` / `BILLING_WEBHOOK_SECRET`
env vars, so `setupBilling(components, { email })` needs no env plumbing.

The billing entity resolves from identity claims out of the box — the
active workspace (`billTo: 'organization'`, the default) or the signed-in
user (`billTo: 'user'`) — so [SetupBillingConfig.resolveEntity](#resolveentity) is an
override, not required wiring.

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="email-2">
        
      </a>
      
       <code>
        email
      </code>
    </td>
    
    <td>
      <a href="#billingemail">
        <code>
          BillingEmail
        </code>
      </a>
    </td>
    
    <td>
      The app's <code>
        setupEmail
      </code>
      
       instance. A gift's recipient hears of it through its <code>
        gift
      </code>
      
       template once the purchase is paid; restyle it there, with <code>
        setupEmail(components, { templates: { gift } })
      </code>
      
      . Checked when <code>
        setupBilling
      </code>
      
       runs: an import cycle through <code>
        email.ts
      </code>
      
       can hand it over as <code>
        undefined
      </code>
      
       despite the type, and that fails the deploy instead of the first paid gift.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="accesstoken">
        
      </a>
      
       <code>
        accessToken?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Provider access token. Defaults to the required <code>
        BILLING_ACCESS_TOKEN
      </code>
      
       env var.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="environment">
        
      </a>
      
       <code>
        environment?
      </code>
    </td>
    
    <td>
      <code>
        "sandbox"
      </code>
      
       | <code>
        "production"
      </code>
    </td>
    
    <td>
      Provider environment. Defaults to the required <code>
        BILLING_ENVIRONMENT
      </code>
      
       env var (<code>
        'sandbox'
      </code>
      
       otherwise).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="webhooksecret">
        
      </a>
      
       <code>
        webhookSecret?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Webhook signature secret. Defaults to the required <code>
        BILLING_WEBHOOK_SECRET
      </code>
      
       env var.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="products-1">
        
      </a>
      
       <code>
        products?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      Friendly product keys → provider product ids (<code>
        { pro: '…' }
      </code>
      
      ), so a current subscription reads with its <code>
        productKey
      </code>
      
      . Usually supplied via <code>
        catalog
      </code>
      
      ; an explicit map wins.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="trustedorigins">
        
      </a>
      
       <code>
        trustedOrigins?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Origins, besides <code>
        SITE_URL
      </code>
      
      's, a checkout, a gift checkout or the customer portal may send the buyer back to (<code>
        ['https://app.example.com']
      </code>
      
      ) — a second domain the app is served from, say. Every other return or embed URL is refused as <code>
        invalid_input
      </code>
      
      . With <code>
        AUTH_TRUST_LOCAL_ORIGINS=1
      </code>
      
       (local development) loopback origins are trusted too.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="billto">
        
      </a>
      
       <code>
        billTo?
      </code>
    </td>
    
    <td>
      <code>
        "user"
      </code>
      
       | <code>
        "organization"
      </code>
    </td>
    
    <td>
      Who owns subscriptions and credits: the active workspace (<code>
        'organization'
      </code>
      
      , the default — members share the workspace's plan and credits) or the individual user (<code>
        'user'
      </code>
      
      , for B2C apps without shared billing).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resolveentity">
        
      </a>
      
       <code>
        resolveEntity?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#billingentity">
        <code>
          BillingEntity
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Resolve the billing entity yourself, in place of the identity claims <code>
        billTo
      </code>
      
       reads. One resolver for every context: the reactive reads (<code>
        getCurrentSubscription
      </code>
      
      , <code>
        getFeatures
      </code>
      
      , <code>
        getCredits
      </code>
      
      ), checkout and the portal, spends and the subscription lifecycle. It is called with every context, signed in or not, so it must return <code>
        null
      </code>
      
       when <code>
        ctx.auth.getUserIdentity()
      </code>
      
       does: reads then answer <code>
        null
      </code>
      
      , and provider operations refuse.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="ratelimiter">
        
      </a>
      
       <code>
        rateLimiter?
      </code>
    </td>
    
    <td>
      <a href="#billingratelimiter">
        <code>
          BillingRateLimiter
        </code>
      </a>
    </td>
    
    <td>
      Throttle every client-callable function that reaches the live provider — <code>
        syncEntitlements
      </code>
      
      , <code>
        syncProducts
      </code>
      
      , checkout, the subscription-lifecycle actions, order history and invoices. Pass your <code>
        setupRateLimiter(...)
      </code>
      
       limiter and each authenticated call is checked against the <code>
        billingSync
      </code>
      
       limit (10/min, keyed by the workspace/user), so a caller can't loop one to amplify the provider fan-out. <code>
        giftCheckout
      </code>
      
       burns the same limit keyed by the purchaser. Omit to leave them unthrottled.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="multiplesubscriptions">
        
      </a>
      
       <code>
        multipleSubscriptions?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Let one billing entity hold several live subscriptions at once (a plan plus add-ons, say). The upstream single-subscription read throws the moment a second one exists, so this switches <code>
        getCurrentSubscription
      </code>
      
       to the subscriptions-array-first shape (<a href="#currentsubscriptions">
        CurrentSubscriptions
      </a>
      
      ) and makes <code>
        subscriptionId
      </code>
      
       the way lifecycle actions pick their target.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requireadmin">
        
      </a>
      
       <code>
        requireAdmin?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Gate the admin-tier billing actions (<code>
        refundOrder
      </code>
      
       — moving real money). Throw from here to refuse. The default requires an <code>
        admin
      </code>
      
       role claim on the caller's identity (the admin plugin's role, carried on the JWT); supply your own to check permissions, a workspace role, or an allowlist.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="events">
        
      </a>
      
       <code>
        events?
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        WebhookEventHandlers
      </code>
      
      >
    </td>
    
    <td>
      React to billing webhook events, keyed by the provider's own event names (<code>
        'order.paid'
      </code>
      
      , <code>
        'subscription.active'
      </code>
      
      , …). Your handler runs <strong>
        after
      </strong>
      
       the built-in entitlement-cache refresh (and gift fulfilment), so features/credits read fresh inside it. Events outside the built-in refresh set are mounted too.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cangift">
        
      </a>
      
       <code>
        canGift?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        input
      </code>
      
      ) => | <code>
        true
      </code>
      
       | <code>
        Promise
      </code>
      
      < | <code>
        true
      </code>
      
       | { <code>
        allowed
      </code>
      
      : <code>
        false
      </code>
      
      ; <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }> | { <code>
        allowed
      </code>
      
      : <code>
        false
      </code>
      
      ; <code>
        message?
      </code>
      
      : <code>
        string
      </code>
      
      ; }
    </td>
    
    <td>
      Decide who may receive a gift, before <code>
        giftCheckout
      </code>
      
       opens the purchaser's checkout — only addresses on your own domain, say, or only sandbox addresses on a public demo. It adds to the package's own rules, which always hold: no gift to the purchaser's own address, an earlier paid order of the purchaser's first, and <a href="#giftlimit">
        SetupBillingConfig.giftLimit
      </a>
      
      . Return <code>
        true
      </code>
      
       to allow, or a refusal whose <code>
        message
      </code>
      
       <code>
        giftCheckout
      </code>
      
       throws as a <code>
        ConvexError
      </code>
      
      , so it reaches the purchaser even where production redacts other errors (default: "This address can't receive gifts."). Called with the action ctx, so it can read your own tables; <code>
        recipientEmail
      </code>
      
       is lower-cased, and <code>
        purchaserEntityId
      </code>
      
       is the billing entity that pays.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="giftlimit">
        
      </a>
      
       <code>
        giftLimit?
      </code>
    </td>
    
    <td>
      { <code>
        max?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        days?
      </code>
      
      : <code>
        number
      </code>
      
      ; }
    </td>
    
    <td>
      How many gifts one purchaser may buy in a window: <code>
        max
      </code>
      
       paid gifts in <code>
        days
      </code>
      
       days (default 10 in 30). A stolen card that can buy gifts for strangers is a way to cash it out, and a claimed gift can't be taken back, so the cap holds whatever rate limiter the app passes. A further purchase is <code>
        rate_limited
      </code>
      
       (<code>
        limit: 'gifts'
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        giftLimit.max?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        giftLimit.days?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="credits-2">
        
      </a>
      
       <code>
        credits?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <a href="#creditmeterconfig">
        <code>
          CreditMeterConfig
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Named credit meters: spend by friendly name (<code>
        spendCredits({ meter: 'credits' })
      </code>
      
      , <code>
        useCredits('credits')
      </code>
      
      ) instead of provider meter ids. Usually supplied via <code>
        catalog
      </code>
      
      ; explicit entries here win.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="catalog">
        
      </a>
      
       <code>
        catalog?
      </code>
    </td>
    
    <td>
      <code>
        Partial
      </code>
      
      <<code>
        Record
      </code>
      
      <<code>
        "sandbox"
      </code>
      
       | <code>
        "production"
      </code>
      
      , <a href="#billingcatalogids">
        <code>
          BillingCatalogIds
        </code>
      </a>
      
       | <code>
        undefined
      </code>
      
      >>
    </td>
    
    <td>
      The environment-keyed id map generated by <code>
        nuxt-backend billing sync
      </code>
      
       (<code>
        backend/billing.generated.ts
      </code>
      
      ): fills <code>
        products
      </code>
      
       and <code>
        credits
      </code>
      
       for the active <code>
        BILLING_ENVIRONMENT
      </code>
      
      , so provider UUIDs live in exactly one generated file. Explicit <code>
        products
      </code>
      
      /<code>
        credits
      </code>
      
       config wins.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="onunknownevent">
        
      </a>
      
       <code>
        onUnknownEvent?
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Called for an <strong>
        authentic
      </strong>
      
       (signature-verified) webhook event whose type this package's provider SDK cannot parse — e.g. an event newer than the installed package. The delivery is acknowledged with 202 either way, so unknown types can never put the endpoint into a retry loop.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts" rel="nofollow">
        src/convex/integrations/billing/types/setup.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### Billing

Defined in: [src/convex/integrations/billing/types/surface.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts)

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="api">
        
      </a>
      
       <code>
        api
      </code>
    </td>
    
    <td>
      <code>
        Pick
      </code>
      
      <{ <code>
        changeCurrentSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        productId
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >>; <code>
        cancelCurrentSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        revokeImmediately?
      </code>
      
      : <code>
        boolean
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >>; <code>
        getConfiguredProducts
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { }, <code>
        Promise
      </code>
      
      <{ [<code>
        key
      </code>
      
      : <code>
        string
      </code>
      
      ]: | { <code>
        benefits?
      </code>
      
      : { <code>
        createdAt
      </code>
      
      : ...; <code>
        deletable
      </code>
      
      : ...; <code>
        description
      </code>
      
      : ...; <code>
        id
      </code>
      
      : ...; <code>
        metadata?
      </code>
      
      : ...; <code>
        modifiedAt
      </code>
      
      : ...; <code>
        organizationId
      </code>
      
      : ...; <code>
        properties?
      </code>
      
      : ...; <code>
        selectable
      </code>
      
      : ...; <code>
        type
      </code>
      
      : ...; }<span>
        
      </span>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        description
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isArchived
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        isRecurring
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        medias
      </code>
      
      : { <code>
        checksumEtag
      </code>
      
      : ... | ...; <code>
        checksumSha256Base64
      </code>
      
      : ... | ...; <code>
        checksumSha256Hex
      </code>
      
      : ... | ...; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isUploaded
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        lastModifiedAt
      </code>
      
      : ... | ...; <code>
        mimeType
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        path
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        publicUrl
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        service?
      </code>
      
      : ... | ...; <code>
        size
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        sizeReadable
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        storageVersion
      </code>
      
      : ... | ...; <code>
        version
      </code>
      
      : ... | ...; }<span>
        
      </span>
      
      ; <code>
        metadata?
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        any
      </code>
      
      >; <code>
        modifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        priceAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        prices
      </code>
      
      : { <code>
        amountType?
      </code>
      
      : ... | ...; <code>
        capAmount?
      </code>
      
      : ... | ... | ...; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isArchived
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        maximumAmount?
      </code>
      
      : ... | ... | ...; <code>
        meter?
      </code>
      
      : ... | ...; <code>
        meterId?
      </code>
      
      : ... | ...; <code>
        minimumAmount?
      </code>
      
      : ... | ... | ...; <code>
        modifiedAt
      </code>
      
      : ... | ...; <code>
        presetAmount?
      </code>
      
      : ... | ... | ...; <code>
        priceAmount?
      </code>
      
      : ... | ...; <code>
        priceCurrency?
      </code>
      
      : ... | ...; <code>
        productId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        recurringInterval?
      </code>
      
      : ... | ... | ...; <code>
        seatTiers?
      </code>
      
      : ... | ...; <code>
        source?
      </code>
      
      : ... | ...; <code>
        type?
      </code>
      
      : ... | ...; <code>
        unitAmount?
      </code>
      
      : ... | ...; }<span>
        
      </span>
      
      ; <code>
        recurringInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        recurringIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; } | <code>
        undefined
      </code>
      
      ; }>>; <code>
        listAllProducts
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { }, <code>
        Promise
      </code>
      
      <{ <code>
        benefits?
      </code>
      
      : { <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        deletable
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        description
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata?
      </code>
      
      : ... | ...; <code>
        modifiedAt
      </code>
      
      : ... | ...; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        properties?
      </code>
      
      : <code>
        any
      </code>
      
      ; <code>
        selectable
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        type
      </code>
      
      : <code>
        string
      </code>
      
      ; }<span>
        
      </span>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        description
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isArchived
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        isRecurring
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        medias
      </code>
      
      : { <code>
        checksumEtag
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        checksumSha256Base64
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        checksumSha256Hex
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isUploaded
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        lastModifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        mimeType
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        path
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        publicUrl
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        service?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        size
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        sizeReadable
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        storageVersion
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        version
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }<span>
        
      </span>
      
      ; <code>
        metadata?
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        any
      </code>
      
      >; <code>
        modifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        priceAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        prices
      </code>
      
      : { <code>
        amountType?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        capAmount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isArchived
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        maximumAmount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        meter?
      </code>
      
      : { <code>
        id
      </code>
      
      : ...; <code>
        name
      </code>
      
      : ...; }; <code>
        meterId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        minimumAmount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        modifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        presetAmount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        priceAmount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        priceCurrency?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        productId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        recurringInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        seatTiers?
      </code>
      
      : ...<span>
        
      </span>
      
      ; <code>
        source?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        type?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        unitAmount?
      </code>
      
      : <code>
        string
      </code>
      
      ; }<span>
        
      </span>
      
      ; <code>
        recurringInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        recurringIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; }<span>
        
      </span>
      
      >>; <code>
        listAllSubscriptions
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      , { }, <code>
        Promise
      </code>
      
      <{ <code>
        amount
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        cancelAtPeriodEnd
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        canceledAt?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        checkoutId
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        currency
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        currentPeriodEnd
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        currentPeriodStart
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        customFieldData?
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        any
      </code>
      
      >; <code>
        customerCancellationComment?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        customerCancellationReason?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        customerId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        discountId?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        endedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        endsAt?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        metadata
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        any
      </code>
      
      >; <code>
        modifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        priceId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        product
      </code>
      
      : | { <code>
        benefits?
      </code>
      
      : ...<span>
        
      </span>
      
      ; <code>
        createdAt
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        description
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        id
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        isArchived
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        isRecurring
      </code>
      
      : <code>
        boolean
      </code>
      
      ; <code>
        medias
      </code>
      
      : { <code>
        checksumEtag
      </code>
      
      : ...; <code>
        checksumSha256Base64
      </code>
      
      : ...; <code>
        checksumSha256Hex
      </code>
      
      : ...; <code>
        createdAt
      </code>
      
      : ...; <code>
        id
      </code>
      
      : ...; <code>
        isUploaded
      </code>
      
      : ...; <code>
        lastModifiedAt
      </code>
      
      : ...; <code>
        mimeType
      </code>
      
      : ...; <code>
        name
      </code>
      
      : ...; <code>
        organizationId
      </code>
      
      : ...; <code>
        path
      </code>
      
      : ...; <code>
        publicUrl
      </code>
      
      : ...; <code>
        service?
      </code>
      
      : ...; <code>
        size
      </code>
      
      : ...; <code>
        sizeReadable
      </code>
      
      : ...; <code>
        storageVersion
      </code>
      
      : ...; <code>
        version
      </code>
      
      : ...; }<span>
        
      </span>
      
      ; <code>
        metadata?
      </code>
      
      : <code>
        Record
      </code>
      
      <..., ...>; <code>
        modifiedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        name
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        organizationId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        prices
      </code>
      
      : { <code>
        amountType?
      </code>
      
      : ...; <code>
        capAmount?
      </code>
      
      : ...; <code>
        createdAt
      </code>
      
      : ...; <code>
        id
      </code>
      
      : ...; <code>
        isArchived
      </code>
      
      : ...; <code>
        maximumAmount?
      </code>
      
      : ...; <code>
        meter?
      </code>
      
      : ...; <code>
        meterId?
      </code>
      
      : ...; <code>
        minimumAmount?
      </code>
      
      : ...; <code>
        modifiedAt
      </code>
      
      : ...; <code>
        presetAmount?
      </code>
      
      : ...; <code>
        priceAmount?
      </code>
      
      : ...; <code>
        priceCurrency?
      </code>
      
      : ...; <code>
        productId
      </code>
      
      : ...; <code>
        recurringInterval?
      </code>
      
      : ...; <code>
        seatTiers?
      </code>
      
      : ...; <code>
        source?
      </code>
      
      : ...; <code>
        type?
      </code>
      
      : ...; <code>
        unitAmount?
      </code>
      
      : ...; }<span>
        
      </span>
      
      ; <code>
        recurringInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        recurringIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; } | <code>
        null
      </code>
      
      ; <code>
        productId
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        recurringInterval
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        recurringIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
      ; <code>
        seats?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        startedAt
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        status
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        trialEnd?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialStart?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; }<span>
        
      </span>
      
      >>; <code>
        generateCheckoutLink
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        metadata?
      </code>
      
      : <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >; <code>
        trialInterval?
      </code>
      
      : <code>
        string
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        trialIntervalCount?
      </code>
      
      : <code>
        number
      </code>
      
       | <code>
        null
      </code>
      
      ; <code>
        subscriptionId?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        locale?
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        productIds
      </code>
      
      : <code>
        string
      </code>
      
      <span>
        
      </span>
      
      ; <code>
        origin
      </code>
      
      : <code>
        string
      </code>
      
      ; <code>
        successUrl
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>; <code>
        generateCustomerPortalUrl
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        returnUrl?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>; }, <code>
        "getConfiguredProducts"
      </code>
      
      > & { <code>
        listAllSubscriptions
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        giftCheckout
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        generateCheckoutLink
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , <a href="#checkoutoptions">
        <code>
          CheckoutOptions
        </code>
      </a>
      
      , <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>; <code>
        generateCustomerPortalUrl
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      , { <code>
        returnUrl?
      </code>
      
      : <code>
        string
      </code>
      
      ; }, <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>>; }
    </td>
    
    <td>
      The ready-made checkout, portal, price-list and gift functions to re-export from your Convex module. Of the provider's own <code>
        api()
      </code>
      
       only <code>
        getConfiguredProducts
      </code>
      
       (the price list) is kept; the rest are this package's, and refuse with catalog codes (see <code>
        backendError
      </code>
      
      ): - <code>
        generateCheckoutLink
      </code>
      
       sells only the app's catalog, returns only to the site (<code>
        SITE_URL
      </code>
      
       or <code>
        trustedOrigins
      </code>
      
      ), refuses the metadata keys the package reads back, and takes a discount code and campaign attribution; the trial and a discount by id are <a href="#checkout">
        Billing.checkout
      </a>
      
      's. - <code>
        generateCustomerPortalUrl
      </code>
      
       returns only to the site. - <code>
        giftCheckout
      </code>
      
       gifts a catalog credit pack, by its key. - <code>
        listAllSubscriptions
      </code>
      
       resolves the billing entity like the reactive reads do: <code>
        null
      </code>
      
       instead of a throw for claimless callers.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="functions">
        
      </a>
      
       <code>
        functions
      </code>
    </td>
    
    <td>
      { <code>
        getCurrentSubscription
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getFeatures
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getCredits
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        syncEntitlements
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        syncProducts
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      >; <code>
        getReceivedGifts
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        claimGift
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getWebhookDeliveries
      </code>
      
      : <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        updateSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        cancelSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        uncancelSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        pauseSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        resumeSubscription
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getOrders
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getInvoiceUrl
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        getUsageHistory
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; <code>
        refundOrder
      </code>
      
      : <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >; }
    </td>
    
    <td>
      Ready-made, client-callable functions to re-export from your <code>
        billing.ts
      </code>
      
       so <code>
        useBilling
      </code>
      
       / <code>
        useFeatures
      </code>
      
       / <code>
        useCredits
      </code>
      
       / <code>
        useGifts
      </code>
      
       work with zero hand-wiring: the reactive current-subscription, feature-gating and credit-balance queries, a <code>
        syncEntitlements
      </code>
      
       action to refresh the cache after checkout / top-up, an <strong>
        internal
      </strong>
      
       <code>
        syncProducts
      </code>
      
       action to pull the provider's product catalog into the reactive products table (fresh deployments render empty pricing until <code>
        npx convex run billing:syncProducts
      </code>
      
       runs once — webhooks keep it fresh afterwards), and the gift queries/claim action.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getCurrentSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getFeatures
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getCredits
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.syncEntitlements
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.syncProducts
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "internal"
      </code>
      
      >
    </td>
    
    <td>
      Ops-only (internal): <code>
        npx convex run billing:syncProducts
      </code>
      
      .
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getReceivedGifts
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.claimGift
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getWebhookDeliveries
      </code>
    </td>
    
    <td>
      <code>
        RegisteredQuery
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      The webhook delivery log, newest first — admin-tier, like <code>
        refundOrder
      </code>
      
       (see <code>
        requireAdmin
      </code>
      
       on <a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ): <code>
        null
      </code>
      
       for anyone else, signed out included.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.updateSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Switch the caller's subscription to another product.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.cancelSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Cancel at period end (default) or revoke immediately.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.uncancelSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Undo a scheduled cancellation.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.pauseSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Pause at period end.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.resumeSubscription
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Resume a paused subscription immediately.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getOrders
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      The caller's order history, read live from the provider.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getInvoiceUrl
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      A signed invoice URL for one of the caller's orders.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.getUsageHistory
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      The caller's metered consumption history, read live from the provider.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        functions.refundOrder
      </code>
    </td>
    
    <td>
      <code>
        RegisteredAction
      </code>
      
      <<code>
        "public"
      </code>
      
      >
    </td>
    
    <td>
      Refund an order — admin-tier (see <code>
        requireAdmin
      </code>
      
       on <a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="webhookevents">
        
      </a>
      
       <code>
        webhookEvents
      </code>
    </td>
    
    <td>
      <a href="#billingwebhookeventhandlers">
        <code>
          BillingWebhookEventHandlers
        </code>
      </a>
    </td>
    
    <td>
      Typed billing webhook handlers for <code>
        registerBackendRoutes
      </code>
      
       (mounted at <code>
        /billing/events
      </code>
      
      ) that keep the reactive cache fresh (subscriptions, benefit grants, credit balances) and fulfil paid gifts.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="webhookhandler">
        
      </a>
      
       <code>
        webhookHandler
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        request
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Response
      </code>
      
      >
    </td>
    
    <td>
      The guarded <code>
        /billing/events
      </code>
      
       endpoint <code>
        registerBackendRoutes
      </code>
      
       mounts: fail-closed (503 while the secret is unset, 413 over the size cap, 403 on bad signatures across the rotation list, 200 on redeliveries of processed ids, 202 for authentic-but-unknown types) with every delivery outcome recorded in the component's delivery log.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getcustomerstate">
        
      </a>
      
       <code>
        getCustomerState
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        args
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#customerentitlements">
        <code>
          CustomerEntitlements
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Resolve a user's full billing entitlement state (active plans, benefits, and credit-meter balances) live from the provider. Call from an <strong>
        action
      </strong>
      
      ; the ready-made <code>
        syncEntitlements
      </code>
      
       already caches the result for you.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="checkout">
        
      </a>
      
       <code>
        checkout
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      A checkout for the caller's billing entity, from server code — the <code>
        generateCheckoutLink
      </code>
      
       checks, plus what only the server chooses: a <code>
        trial
      </code>
      
       of at most 30 days (or <code>
        false
      </code>
      
       to remove the product's own) and a <code>
        discountId
      </code>
      
      . Call it from your own action, after deciding the caller qualifies. <strong>
        Example
      </strong>
      
       <code>
        // A 30-day trial for people who came through a partner. The product is // still checked against the catalog, and the URLs against the site. export const partnerCheckout = action({ args: { productId: v.string(), origin: v.string(), successUrl: v.string() }, handler: async (ctx, { productId, ...urls }) => { if (!(await cameThroughPartner(ctx))) throw backendError('forbidden', { reason: 'permission' }) return billing.checkout(ctx, { productIds: [productId], ...urls, trial: { interval: 'day', count: 30 } }) }, })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="portal">
        
      </a>
      
       <code>
        portal
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <{ <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; }>
    </td>
    
    <td>
      A customer-portal session for the caller's billing entity, from server code — what <code>
        generateCustomerPortalUrl
      </code>
      
       returns. With workspaces the session is the caller's own member of the workspace's billing customer, and only its owner or a billing manager gets one: anyone else is <code>
        forbidden
      </code>
      
       (reason <code>
        not_billing_manager
      </code>
      
      ). An entity that never paid is <code>
        not_ready
      </code>
      
       (reason <code>
        no_customer
      </code>
      
      ). <code>
        returnUrl
      </code>
      
       must be on the site's own origin or a <code>
        trustedOrigins
      </code>
      
       entry. <strong>
        Example
      </strong>
      
       <code>
        export const openBilling = action({ args: {}, handler: ctx => billing.portal(ctx, { returnUrl:
      </code>
      
      ${process.env.SITE_URL}/app/billing<code>
        }), })
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="spendcredits">
        
      </a>
      
       <code>
        spendCredits
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Spend prepaid credits — call from your own <strong>
        server
      </strong>
      
       action when a metered feature is used. The billing entity (workspace or user, per <code>
        billTo
      </code>
      
      ) resolves from the caller's identity; pass <code>
        userId
      </code>
      
       to spend for a specific entity. With a configured <code>
        meter
      </code>
      
       (or raw <code>
        meterId
      </code>
      
      ), the spend reserves against the cached balance atomically (strictly prepaid — two concurrent spends can never both pass), ingests the provider event, then settles; a failed run releases the reservation and consumes nothing.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="refundcredits">
        
      </a>
      
       <code>
        refundCredits
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Give credits back on a <strong>
        sum
      </strong>
      
       meter (compensating negative-value event + optimistic cache re-credit). Count meters cannot be refunded.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="reservecredits">
        
      </a>
      
       <code>
        reserveCredits
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        event
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#spendreservation">
        <code>
          SpendReservation
        </code>
      </a>
      
      >
    </td>
    
    <td>
      The reserve step of a spend, alone — for flows that run work between the guard and the charge (<code>
        setupAi().meteredAction
      </code>
      
       / streaming). Atomically reserves against the cached balance (throws when insufficient) and returns serializable addressing data for <a href="#settlespend">
        Billing.settleSpend
      </a>
      
       / <a href="#releasespend">
        Billing.releaseSpend
      </a>
      
      . <code>
        allowRefresh: false
      </code>
      
       skips the cold-cache self-heal (required from mutation contexts — the refresh fetches).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="settlespend">
        
      </a>
      
       <code>
        settleSpend
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        reservation
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Ingest the provider event for a reservation and finalize the spend.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="releasespend">
        
      </a>
      
       <code>
        releaseSpend
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        reservation
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Undo a reservation whose work failed — nothing is charged.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resolveentity-1">
        
      </a>
      
       <code>
        resolveEntity
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#billingentity">
        <code>
          BillingEntity
        </code>
      </a>
      
       | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      Resolve the caller's billing entity the way every billing function does: <code>
        setupBilling
      </code>
      
      's <code>
        resolveEntity
      </code>
      
       when given, else identity claims — the active workspace (<code>
        billTo: 'organization'
      </code>
      
      ) or the signed-in user. <code>
        null
      </code>
      
       when signed out. Any query, mutation or action context will do.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="forgetentity">
        
      </a>
      
       <code>
        forgetEntity
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        userId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        void
      </code>
      
      >
    </td>
    
    <td>
      Forget a billing entity: drop its cached entitlements (plans, benefits, credit balances, in-flight reservations). The provider's customer record is untouched — this is the app-side erasure step, e.g. from the <code>
        onUserDeleted
      </code>
      
       auth hook with the deleted user's id (<code>
        billTo: 'user'
      </code>
      
      ) or a dissolved workspace's id. A no-op for an unknown entity.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="discounts">
        
      </a>
      
       <code>
        discounts
      </code>
    </td>
    
    <td>
      <a href="#billingdiscounts">
        <code>
          BillingDiscounts
        </code>
      </a>
    </td>
    
    <td>
      Discount (coupon) management: <code>
        create
      </code>
      
      , <code>
        list
      </code>
      
      , <code>
        remove
      </code>
      
      . Server-side by design — minting discounts is privileged, so wire it through an <code>
        internalAction
      </code>
      
       or your own admin-tier action.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="updatesubscription">
        
      </a>
      
       <code>
        updateSubscription
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Subscription
      </code>
      
      >
    </td>
    
    <td>
      Switch a subscription to another product (upgrade / downgrade), optionally choosing how the mid-period difference is settled. Call from an <strong>
        action
      </strong>
      
      ; the ready-made <code>
        updateSubscription
      </code>
      
       function does it for the caller.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="cancelsubscription">
        
      </a>
      
       <code>
        cancelSubscription
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Subscription
      </code>
      
      >
    </td>
    
    <td>
      Cancel a subscription — at period end by default, immediately with <code>
        atPeriodEnd: false
      </code>
      
      . The reason and comment are the customer's own words and are visible to them.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="uncancelsubscription">
        
      </a>
      
       <code>
        uncancelSubscription
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Subscription
      </code>
      
      >
    </td>
    
    <td>
      Undo a scheduled cancellation, putting the subscription back on renewal.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="pausesubscription">
        
      </a>
      
       <code>
        pauseSubscription
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Subscription
      </code>
      
      >
    </td>
    
    <td>
      Pause a subscription at the end of the current period, optionally with an automatic resume date. Pause/resume are newer than the rest of the lifecycle: the provider's <code>
        subscription.paused
      </code>
      
       / <code>
        subscription.resumed
      </code>
      
       webhooks are known to the installed SDK but not confirmed live here, so entitlement reads treat a paused subscription as still live rather than assuming an event will arrive to say so.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="resumesubscription">
        
      </a>
      
       <code>
        resumeSubscription
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<code>
        Subscription
      </code>
      
      >
    </td>
    
    <td>
      Resume a paused subscription immediately, starting a new billing period.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getorders">
        
      </a>
      
       <code>
        getOrders
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#billingpage">
        <code>
          BillingPage
        </code>
      </a>
      
      <<a href="#billingorder">
        <code>
          BillingOrder
        </code>
      </a>
      
      > | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      The billing entity's order history, read <strong>
        live
      </strong>
      
       from the provider — this package keeps no local order table (that would be a ledger, and the provider already is one). <code>
        null
      </code>
      
       when no access token is configured.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getinvoiceurl">
        
      </a>
      
       <code>
        getInvoiceUrl
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        orderId
      </code>
      
      ) => <code>
        Promise
      </code>
      
      < | { <code>
        url
      </code>
      
      : <code>
        string
      </code>
      
      ; } | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      A URL to one of the entity's own invoices. <code>
        null
      </code>
      
       when no access token is configured, and <code>
        null
      </code>
      
       while the provider is still generating the PDF (the call asks for generation, then the next call returns the URL). Throws if the order belongs to a different billing account.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="getusagehistory">
        
      </a>
      
       <code>
        getUsageHistory
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options?
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#billingpage">
        <code>
          BillingPage
        </code>
      </a>
      
      <<a href="#usageevent">
        <code>
          UsageEvent
        </code>
      </a>
      
      > | <code>
        null
      </code>
      
      >
    </td>
    
    <td>
      The billing entity's metered consumption history, read <strong>
        live
      </strong>
      
       from the provider's events API. There is no local usage ledger by design: the events this package ingests when it spends credits <em>
        are
      </em>
      
       the record, and the provider bills from them. <code>
        null
      </code>
      
       when no access token is configured.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="refundorder">
        
      </a>
      
       <code>
        refundOrder
      </code>
    </td>
    
    <td>
      (<code>
        ctx
      </code>
      
      , <code>
        options
      </code>
      
      ) => <code>
        Promise
      </code>
      
      <<a href="#refundrecord">
        <code>
          RefundRecord
        </code>
      </a>
      
      >
    </td>
    
    <td>
      Refund an order — admin-tier, gated by <code>
        requireAdmin
      </code>
      
       (<a href="#setupbillingconfig">
        SetupBillingConfig
      </a>
      
      ). Omit <code>
        amount
      </code>
      
       to refund whatever is still refundable. Credits are <strong>
        not
      </strong>
      
       reversed here: meter credits come from the provider's own benefit grants, so the refund's <code>
        order.refunded
      </code>
      
       webhook is what reverses them. This package only drops the entity's in-flight spend reservations and re-reads the provider's balance.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/surface.ts" rel="nofollow">
        src/convex/integrations/billing/types/surface.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

## Type Aliases

### DiscountInput

```ts
type DiscountInput = Parameters<typeof discountsCreate>[1];
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

Full discount-create payload (derived from the provider SDK) — fixed or percentage.

---

### ProrationBehavior

```ts
type ProrationBehavior = "invoice" | "prorate" | "next_period" | "reset";
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

How the provider settles the money difference when a subscription switches
product mid-period (`proration_behavior`). Omit to use the organization's
configured default.

---

### ClientProrationBehavior

```ts
type ClientProrationBehavior = "invoice" | "prorate";
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

The subset of [ProrationBehavior](#prorationbehavior) a **client** may choose. `invoice`
and `prorate` both settle the difference now; `next_period` and `reset`
hand over the new plan's credits and features immediately while deferring
(or waiving) the charge, so letting a caller pick one is letting them
upgrade themselves for free. Those two stay server-side: pass them from
app code through `billing.updateSubscription(ctx, …)`, or make them the
organization's configured default.

---

### CancellationReason

```ts
type CancellationReason = 
  | "customer_service"
  | "low_quality"
  | "missing_features"
  | "switched_service"
  | "too_complex"
  | "too_expensive"
  | "unused"
  | "other";
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

The provider's churn-reason enum, recorded with a cancellation. Only set it
when the customer actually told you — it surfaces to them in their purchases
library, so it is their words, not an internal note.

---

### RefundReason

```ts
type RefundReason = 
  | "duplicate"
  | "fraudulent"
  | "customer_request"
  | "service_disruption"
  | "satisfaction_guarantee"
  | "other";
```

Defined in: [src/convex/integrations/billing/types/base.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/base.ts)

Why an order was refunded (provider `refunds.create` reason).

---

### CurrentSubscriptions

```ts
type CurrentSubscriptions = {
  subscriptions: Record<string, unknown>[];
} & Record<string, unknown>;
```

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

What `getCurrentSubscription` returns once `multipleSubscriptions`
([SetupBillingConfig](#setupbillingconfig)) is on: the array leads,
because with add-ons there is no single "the" subscription. The primary
subscription's own fields are spread alongside it, so single-plan consumers
(`subscription.productId`, `subscription.status`) keep reading exactly as
before. Still `null` when the entity has no live subscription at all — the
"null means free plan" contract never changes.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        subscriptions
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        unknown
      </code>
      
      ><span>
        
      </span>
    </td>
    
    <td>
      Every live subscription, in the provider's order.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingOrder

```ts
type BillingOrder = {
  id: string;
  createdAt: string;
  status: string;
  totalAmount: number;
  currency: string;
  paid: boolean;
  invoiceNumber: string | null;
  isInvoiceGenerated: boolean;
} & Record<string, unknown>;
```

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

A past charge, normalized for a Convex action's return value: the provider's
`Order` fields with every date rendered as an ISO string (Convex cannot
serialize `Date`). The index signature keeps every other provider field
reachable without a cast.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        createdAt
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        status
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        totalAmount
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      Amount in the currency's minor unit (cents), after discounts and taxes.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        currency
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        paid
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      -
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        invoiceNumber
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
       | <code>
        null
      </code>
    </td>
    
    <td>
      Assigned when the invoice is finalized; <code>
        null
      </code>
      
       on draft orders.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        isInvoiceGenerated
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Whether an invoice PDF exists yet — <a href="#getinvoiceurl">
        Billing.getInvoiceUrl
      </a>
      
       needs one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### UsageEvent

```ts
type UsageEvent = {
  id: string;
  timestamp: string;
  name: string;
  units?: number;
  metadata?: Record<string, string | number | boolean>;
} & Record<string, unknown>;
```

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

One ingested usage event as the provider's events API returns it, normalized
for a Convex action's return value (dates as ISO strings). `units` is
resolved from the meter's value property — the same property a spend ingests
— and is absent when the meter is unknown or counts events rather than
summing a property.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        id
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        timestamp
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        name
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        units?
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### CheckoutOptions

```ts
type CheckoutOptions = {
  productIds: string[];
  origin: string;
  successUrl: string;
  subscriptionId?: string;
  metadata?: Record<string, string>;
  locale?: string;
  prefill?: CheckoutPrefill;
  customFields?: Record<string, string | number | boolean>;
  requireBillingAddress?: boolean;
  allowDiscountCodes?: boolean;
  discountCode?: string;
  utm?: CampaignAttribution;
};
```

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

Everything [Billing.api](#api)'s `generateCheckoutLink` accepts from a
client. A type alias rather than an interface so it can type the
registered action itself (Convex's `DefaultFunctionArgs` needs an implicit
index signature, which only aliases get).

What is bought and where the buyer lands are checked on the server: every
product must be in the app's catalog, and `origin` and `successUrl` on
the site's own origin (`SITE_URL`) or one of `trustedOrigins`. The trial
is the product's own, and a discount is the code the customer types or
`discountCode`: a different trial or a discount by id is the server's
choice, through [Billing.checkout](#checkout).

#### Properties

<table>
<thead>
  <tr>
    <th>
      Property
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a id="productids">
        
      </a>
      
       <code>
        productIds
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
      
      <span>
        
      </span>
    </td>
    
    <td>
      Provider product ids, each one from the app's catalog.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="origin">
        
      </a>
      
       <code>
        origin
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      The origin of the page embedding the checkout (for the iframe handshake).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="successurl">
        
      </a>
      
       <code>
        successUrl
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Where the buyer lands after paying.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="subscriptionid-4">
        
      </a>
      
       <code>
        subscriptionId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Upgrade one of the entity's own free subscriptions instead of starting a new one.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="metadata-1">
        
      </a>
      
       <code>
        metadata?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
      >
    </td>
    
    <td>
      The app's own keys: none the package reads back (see <code>
        RESERVED_METADATA_KEYS
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="locale">
        
      </a>
      
       <code>
        locale?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      BCP-47 language tag for the checkout UI.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="prefill">
        
      </a>
      
       <code>
        prefill?
      </code>
    </td>
    
    <td>
      <a href="#checkoutprefill">
        <code>
          CheckoutPrefill
        </code>
      </a>
    </td>
    
    <td>
      Pre-filled customer details.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="customfields-3">
        
      </a>
      
       <code>
        customFields?
      </code>
    </td>
    
    <td>
      <code>
        Record
      </code>
      
      <<code>
        string
      </code>
      
      , <code>
        string
      </code>
      
       | <code>
        number
      </code>
      
       | <code>
        boolean
      </code>
      
      >
    </td>
    
    <td>
      Values for the organization's custom checkout fields, keyed by field slug.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="requirebillingaddress">
        
      </a>
      
       <code>
        requireBillingAddress?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Require the full billing address, not just the country.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="allowdiscountcodes">
        
      </a>
      
       <code>
        allowDiscountCodes?
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      Let the customer type a discount code into the provider's own checkout (default <code>
        true
      </code>
      
      ). The provider validates it against the live catalog.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="discountcode">
        
      </a>
      
       <code>
        discountCode?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      A discount code to apply up front: a campaign link's code, say. The provider checks it like one the customer typed, and a code it does not know refuses the checkout as <code>
        invalid_input
      </code>
      
       (<code>
        discountCode
      </code>
      
      ).
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <a id="utm">
        
      </a>
      
       <code>
        utm?
      </code>
    </td>
    
    <td>
      <a href="#campaignattribution">
        <code>
          CampaignAttribution
        </code>
      </a>
    </td>
    
    <td>
      Campaign attribution, stored as <code>
        utm_*
      </code>
      
       metadata.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### ServerCheckoutOptions

```ts
type ServerCheckoutOptions = CheckoutOptions & {
  trial?: CheckoutTrial | false;
  discountId?: string;
};
```

Defined in: [src/convex/integrations/billing/types/options.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts)

What [Billing.checkout](#checkout) takes from server code: everything a client
may send, plus what only the server chooses.

#### Type Declaration

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
    
    <th>
      Defined in
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        trial?
      </code>
    </td>
    
    <td>
      <a href="#checkouttrial">
        <code>
          CheckoutTrial
        </code>
      </a>
      
       | <code>
        false
      </code>
    </td>
    
    <td>
      The trial for this checkout: <code>
        false
      </code>
      
       removes the product's own, an override grants at most 30 days. Omit to keep the product's own trial.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        discountId?
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      Pre-apply a discount by <strong>
        id
      </strong>
      
       — the form the provider's checkout payload takes, and the server's to choose: a 100% discount minted for one claim must never be a client's to name.
    </td>
    
    <td>
      <a href="https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/options.ts" rel="nofollow">
        src/convex/integrations/billing/types/options.ts
      </a>
    </td>
  </tr>
</tbody>
</table>

---

### BillingWebhookEventHandlers

```ts
type BillingWebhookEventHandlers = WebhookEventHandlers;
```

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

Per-event billing webhook handlers, keyed by the provider's event names
(`'order.paid'`, `'subscription.active'`, …). Service-neutral alias for the
shape `registerBackendRoutes` mounts at `/billing/events`.

---

### BillingEmail

```ts
type BillingEmail = Pick<Email, "sendTemplate">;
```

Defined in: [src/convex/integrations/billing/types/setup.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/types/setup.ts)

What billing sends its email through: the app's `setupEmail` instance.

## Variables

### ALL_BILLING_EVENTS

```ts
const ALL_BILLING_EVENTS: readonly ["checkout.created", "checkout.updated", "checkout.expired", "customer.created", "customer.updated", "customer.deleted", "customer.state_changed", "customer_seat.assigned", "customer_seat.claimed", "customer_seat.revoked", "member.created", "member.updated", "member.deleted", "order.created", "order.updated", "order.paid", "order.refunded", "subscription.created", "subscription.updated", "subscription.active", "subscription.canceled", "subscription.uncanceled", "subscription.revoked", "subscription.past_due", "refund.created", "refund.updated", "product.created", "product.updated", "benefit.created", "benefit.updated", "benefit_grant.created", "benefit_grant.cycled", "benefit_grant.updated", "benefit_grant.revoked", "organization.updated", "subscription.paused", "subscription.resumed"];
```

Defined in: [src/convex/integrations/billing/events.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing/events.ts)

The provider's full webhook catalog. The composed handler map covers every
one of these, so any verified delivery gets logging, dedupe, and consumer
dispatch — events outside it (a newer provider than this package) land in
`onUnknownEvent` with a 202 instead of an error loop.

## Functions

### defineBillingCatalog()

```ts
function defineBillingCatalog(catalog): BillingCatalog;
```

Defined in: [src/convex/catalog.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/catalog.ts)

Declare the billing catalog (typed identity). Push it with
`npx nuxt-backend billing sync`.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        catalog
      </code>
    </td>
    
    <td>
      <a href="#billingcatalog">
        <code>
          BillingCatalog
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`BillingCatalog`](#billingcatalog)

#### Example

```ts
export default defineBillingCatalog({
  meters: { credits: {} },
  plans: {
    pro: { name: 'Pro', interval: 'month', price: 2900,
      credits: { meter: 'credits', units: 500 }, features: ['priority_support'],
      trial: { interval: 'day', count: 14 },
      usage: [{ meter: 'credits', unitAmount: 5 }] },
  },
  packs: {
    credits500: { name: '500 credits', price: 2000, credits: { meter: 'credits', units: 500 } },
  },
  features: { priority_support: { description: 'Priority support' } },
})
```

---

### setupBilling()

```ts
function setupBilling(components, config): Billing;
```

Defined in: [src/convex/integrations/billing.ts](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/billing.ts)

Configure billing for subscriptions, discounts, prepaid credits, and gift
purchases — linked to your auth users and cached reactively inside the
`backend` component (so consumers add nothing to their own schema).

Subscription / feature / credit reads return `null`/empty until the provider
has synced, so a mid-configuration deployment degrades gracefully; checkout /
portal / credit / discount operations need the required
`BILLING_ACCESS_TOKEN` env var.

Billing follows the tenant: with the default `billTo: 'organization'` the
active workspace owns the subscription and credits (every member shares
them); with `billTo: 'user'` each user is their own customer. Either way
the entity resolves from identity claims — zero wiring — unless
`resolveEntity` says otherwise.

#### Parameters

<table>
<thead>
  <tr>
    <th>
      Parameter
    </th>
    
    <th>
      Type
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        components
      </code>
    </td>
    
    <td>
      <a href="#billingcomponents">
        <code>
          BillingComponents
        </code>
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        config
      </code>
    </td>
    
    <td>
      <a href="#setupbillingconfig">
        <code>
          SetupBillingConfig
        </code>
      </a>
    </td>
  </tr>
</tbody>
</table>

#### Returns

[`Billing`](#billing)

#### Example

```ts
import { setupBilling } from 'nuxt-backend/billing'
import { components } from './_generated/api'
import { email } from './email'

const billing = setupBilling(components, { email })

export const { generateCheckoutLink, generateCustomerPortalUrl, getConfiguredProducts, giftCheckout } = billing.api
export const {
  getCurrentSubscription, getFeatures, getCredits, syncEntitlements,
  getReceivedGifts, claimGift,
} = billing.functions
```


## Sitemap

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