@openmeter/client 1.0.0-beta.231 → 1.0.0-beta.232

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +24 -14
  2. package/dist/core.js +7 -4
  3. package/dist/funcs/addons.js +59 -11
  4. package/dist/funcs/apps.d.ts +41 -1
  5. package/dist/funcs/apps.js +164 -3
  6. package/dist/funcs/billing.js +34 -7
  7. package/dist/funcs/currencies.d.ts +9 -1
  8. package/dist/funcs/currencies.js +62 -5
  9. package/dist/funcs/customers.js +214 -43
  10. package/dist/funcs/entitlements.js +12 -3
  11. package/dist/funcs/events.js +3 -0
  12. package/dist/funcs/features.js +48 -9
  13. package/dist/funcs/invoices.d.ts +58 -1
  14. package/dist/funcs/invoices.js +202 -7
  15. package/dist/funcs/llmCost.js +26 -5
  16. package/dist/funcs/meters.js +59 -11
  17. package/dist/funcs/planAddons.js +65 -17
  18. package/dist/funcs/plans.js +59 -11
  19. package/dist/funcs/subscriptions.js +87 -17
  20. package/dist/funcs/tax.js +34 -7
  21. package/dist/index.d.ts +1 -2
  22. package/dist/index.js +0 -1
  23. package/dist/lib/config.d.ts +2 -2
  24. package/dist/lib/paginate.d.ts +1 -1
  25. package/dist/lib/version.d.ts +1 -1
  26. package/dist/lib/version.js +1 -1
  27. package/dist/lib/wire.d.ts +1 -0
  28. package/dist/lib/wire.js +26 -4
  29. package/dist/models/operations/apps.d.ts +25 -1
  30. package/dist/models/operations/currencies.d.ts +10 -0
  31. package/dist/models/operations/customers.d.ts +2 -1
  32. package/dist/models/operations/invoices.d.ts +16 -0
  33. package/dist/models/schemas.d.ts +15256 -9856
  34. package/dist/models/schemas.js +938 -447
  35. package/dist/models/types.d.ts +503 -259
  36. package/dist/sdk/apps.d.ts +44 -2
  37. package/dist/sdk/apps.js +53 -1
  38. package/dist/sdk/internal.d.ts +151 -3
  39. package/dist/sdk/internal.js +182 -2
  40. package/dist/sdk/invoices.d.ts +15 -0
  41. package/dist/sdk/invoices.js +32 -0
  42. package/dist/sdk/sdk.d.ts +0 -3
  43. package/dist/sdk/sdk.js +0 -5
  44. package/package.json +3 -3
@@ -43,11 +43,11 @@ export interface CursorMetaPage {
43
43
  /** URI to the last page. */
44
44
  last?: string;
45
45
  /** URI to the next page. */
46
- next?: string;
46
+ next: string | null;
47
47
  /** URI to the previous page. */
48
- previous?: string;
48
+ previous: string | null;
49
49
  /** Requested page size. */
50
- size?: number;
50
+ size: number;
51
51
  }
52
52
  /** Standard error response. */
53
53
  export interface BaseError {
@@ -188,6 +188,52 @@ export interface RateCardBooleanEntitlement {
188
188
  /** The type of the entitlement template. */
189
189
  type: 'boolean';
190
190
  }
191
+ /**
192
+ * Labels store metadata of an entity that can be used for filtering an entity list
193
+ * or for searching across entity types.
194
+ *
195
+ * Keys must be of length 1-63 characters, and cannot start with "kong", "konnect",
196
+ * "mesh", "kic", or "\_".
197
+ */
198
+ export type UpdateLabels = Record<string, string>;
199
+ /** Model for installing an app from the catalog with an API key. */
200
+ export interface InstallAppStripeWithApiKey {
201
+ /** Type of the app. */
202
+ type: 'stripe';
203
+ /** Name of the app. */
204
+ name: string;
205
+ /**
206
+ * If true, a billing profile will be created for the app. The Stripe app will be
207
+ * also set as the default billing profile if the current default is a Sandbox app.
208
+ */
209
+ createBillingProfile: boolean;
210
+ /** API key for the app. */
211
+ apiKey: string;
212
+ }
213
+ /** Base model for installing an app from the catalog. */
214
+ export interface InstallAppSandbox {
215
+ /** Type of the app. */
216
+ type: 'sandbox';
217
+ /** Name of the app. */
218
+ name: string;
219
+ /**
220
+ * If true, a billing profile will be created for the app. The Stripe app will be
221
+ * also set as the default billing profile if the current default is a Sandbox app.
222
+ */
223
+ createBillingProfile: boolean;
224
+ }
225
+ /** Base model for installing an app from the catalog. */
226
+ export interface InstallAppExternalInvoicing {
227
+ /** Type of the app. */
228
+ type: 'external_invoicing';
229
+ /** Name of the app. */
230
+ name: string;
231
+ /**
232
+ * If true, a billing profile will be created for the app. The Stripe app will be
233
+ * also set as the default billing profile if the current default is a Sandbox app.
234
+ */
235
+ createBillingProfile: boolean;
236
+ }
191
237
  /**
192
238
  * BillingWorkflowCollectionAlignmentSubscription specifies the alignment for
193
239
  * collecting the pending line items into an invoice.
@@ -249,14 +295,6 @@ export interface InvoiceLineExternalReferences {
249
295
  /** The ID assigned by the external invoicing app. */
250
296
  invoicingId?: string;
251
297
  }
252
- /**
253
- * Labels store metadata of an entity that can be used for filtering an entity list
254
- * or for searching across entity types.
255
- *
256
- * Keys must be of length 1-63 characters, and cannot start with "kong", "konnect",
257
- * "mesh", "kic", or "\_".
258
- */
259
- export type UpdateLabels = Record<string, string>;
260
298
  /**
261
299
  * Invoice-level invoicing settings.
262
300
  *
@@ -484,6 +522,22 @@ export interface CurrencyFiat {
484
522
  * the currency, such as "$" for US Dollar or "€" for Euro.
485
523
  */
486
524
  symbol?: string;
525
+ /**
526
+ * The precision of the currency. It should be a number that represents the number
527
+ * of decimal places used for the currency, such as 2 for US Dollar or Euro.
528
+ */
529
+ precision: number;
530
+ /**
531
+ * The decimal mark for the currency. It should be a string that represents the
532
+ * decimal mark of the currency, such as "." for US Dollar or "," for Euro.
533
+ */
534
+ decimalMark: string;
535
+ /**
536
+ * The thousand separator for the currency. It should be a string that represents
537
+ * the thousand separator of the currency, such as "," for US Dollar or "." for
538
+ * Euro.
539
+ */
540
+ thousandSeparator: string;
487
541
  code: string;
488
542
  }
489
543
  /** Filter options for listing cost bases. */
@@ -491,6 +545,36 @@ export interface ListCostBasesParamsFilter {
491
545
  /** Filter cost bases by fiat currency code. */
492
546
  fiatCode?: string;
493
547
  }
548
+ /** CurrencyCustom create request. */
549
+ export interface CreateCurrencyCustomRequest {
550
+ /**
551
+ * The name of the currency. It should be a human-readable string that represents
552
+ * the name of the currency, such as "US Dollar" or "Euro".
553
+ */
554
+ name: string;
555
+ /**
556
+ * The symbol of the currency. It should be a string that represents the symbol of
557
+ * the currency, such as "$" for US Dollar or "€" for Euro.
558
+ */
559
+ symbol?: string;
560
+ /**
561
+ * The precision of the currency. It should be a number that represents the number
562
+ * of decimal places used for the currency, such as 2 for US Dollar or Euro.
563
+ */
564
+ precision: number;
565
+ /**
566
+ * The decimal mark for the currency. It should be a string that represents the
567
+ * decimal mark of the currency, such as "." for US Dollar or "," for Euro.
568
+ */
569
+ decimalMark: string;
570
+ /**
571
+ * The thousand separator for the currency. It should be a string that represents
572
+ * the thousand separator of the currency, such as "," for US Dollar or "." for
573
+ * Euro.
574
+ */
575
+ thousandSeparator: string;
576
+ code: string;
577
+ }
494
578
  /** Monetary amount in a specific currency. */
495
579
  export interface CurrencyAmount {
496
580
  amount: string;
@@ -1514,9 +1598,10 @@ export interface CreateCreditGrantPurchase {
1514
1598
  /**
1515
1599
  * Cost basis per credit unit used to calculate the purchase amount.
1516
1600
  *
1517
- * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
1518
- * is $50.00. The value must be greater than 0. If the cost basis is 0, use
1519
- * `funding_method=none` instead.
1601
+ * If `per_unit_cost_basis` is 0.50 and credit amount is
1602
+ * $100.00, the total
1603
+ * charge is $50.00. The value must be greater than 0. If the
1604
+ * cost basis is 0, use `funding_method=none` instead.
1520
1605
  *
1521
1606
  * Defaults to 1.0.
1522
1607
  */
@@ -1564,9 +1649,10 @@ export interface CreditGrantPurchase {
1564
1649
  /**
1565
1650
  * Cost basis per credit unit used to calculate the purchase amount.
1566
1651
  *
1567
- * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
1568
- * is $50.00. The value must be greater than 0. If the cost basis is 0, use
1569
- * `funding_method=none` instead.
1652
+ * If `per_unit_cost_basis` is 0.50 and credit amount is
1653
+ * $100.00, the total
1654
+ * charge is $50.00. The value must be greater than 0. If the
1655
+ * cost basis is 0, use `funding_method=none` instead.
1570
1656
  *
1571
1657
  * Defaults to 1.0.
1572
1658
  */
@@ -1781,20 +1867,6 @@ export interface UnitConfig {
1781
1867
  */
1782
1868
  displayUnit?: string;
1783
1869
  }
1784
- /**
1785
- * Available apps for billing integrations to connect with third-party services.
1786
- * Apps can have various capabilities like syncing data from or to external
1787
- * systems, integrating with third-party services for tax calculation, delivery of
1788
- * invoices, collection of payments, etc.
1789
- */
1790
- export interface AppCatalogItem {
1791
- /** Type of the app. */
1792
- type: 'sandbox' | 'stripe' | 'external_invoicing';
1793
- /** Name of the app. */
1794
- name: string;
1795
- /** Description of the app. */
1796
- description: string;
1797
- }
1798
1870
  /** Mapping of app types to tax codes. */
1799
1871
  export interface TaxCodeAppMapping {
1800
1872
  /** The app type that the tax code is associated with. */
@@ -1802,6 +1874,97 @@ export interface TaxCodeAppMapping {
1802
1874
  /** Tax code. */
1803
1875
  taxCode: string;
1804
1876
  }
1877
+ /** App capability describes a function that an App can perform. */
1878
+ export interface AppCapability {
1879
+ /** Type of the capability. */
1880
+ type: 'report_usage' | 'report_events' | 'calculate_tax' | 'invoice_customers' | 'collect_payments';
1881
+ /** Key of the capability. */
1882
+ key: string;
1883
+ /** Name of the capability. */
1884
+ name: string;
1885
+ /** Description of the capability. */
1886
+ description: string;
1887
+ }
1888
+ /** AppStripe update request. */
1889
+ export interface UpdateAppStripeRequest {
1890
+ /**
1891
+ * Display name of the resource.
1892
+ *
1893
+ * Between 1 and 256 characters.
1894
+ */
1895
+ name: string;
1896
+ /**
1897
+ * Optional description of the resource.
1898
+ *
1899
+ * Maximum 1024 characters.
1900
+ */
1901
+ description?: string;
1902
+ labels?: UpdateLabels;
1903
+ /** The app type. */
1904
+ type: 'stripe';
1905
+ /** The Stripe secret API key used to authenticate API requests. */
1906
+ secretApiKey?: string;
1907
+ }
1908
+ /** AppSandbox update request. */
1909
+ export interface UpdateAppSandboxRequest {
1910
+ /**
1911
+ * Display name of the resource.
1912
+ *
1913
+ * Between 1 and 256 characters.
1914
+ */
1915
+ name: string;
1916
+ /**
1917
+ * Optional description of the resource.
1918
+ *
1919
+ * Maximum 1024 characters.
1920
+ */
1921
+ description?: string;
1922
+ labels?: UpdateLabels;
1923
+ /** The app type. */
1924
+ type: 'sandbox';
1925
+ }
1926
+ /** AppExternalInvoicing update request. */
1927
+ export interface UpdateAppExternalInvoicingRequest {
1928
+ /**
1929
+ * Display name of the resource.
1930
+ *
1931
+ * Between 1 and 256 characters.
1932
+ */
1933
+ name: string;
1934
+ /**
1935
+ * Optional description of the resource.
1936
+ *
1937
+ * Maximum 1024 characters.
1938
+ */
1939
+ description?: string;
1940
+ labels?: UpdateLabels;
1941
+ /** The app type. */
1942
+ type: 'external_invoicing';
1943
+ /**
1944
+ * Enable draft synchronization hook.
1945
+ *
1946
+ * When enabled, invoices will pause at the draft state and wait for the
1947
+ * integration to call the draft synchronized endpoint before progressing to the
1948
+ * issuing state. This allows the external system to validate and prepare the
1949
+ * invoice data.
1950
+ *
1951
+ * When disabled, invoices automatically progress through the draft state based on
1952
+ * the configured workflow timing.
1953
+ */
1954
+ enableDraftSyncHook: boolean;
1955
+ /**
1956
+ * Enable issuing synchronization hook.
1957
+ *
1958
+ * When enabled, invoices will pause at the issuing state and wait for the
1959
+ * integration to call the issuing synchronized endpoint before progressing to the
1960
+ * issued state. This ensures the external invoicing system has successfully
1961
+ * created and finalized the invoice before it is marked as issued.
1962
+ *
1963
+ * When disabled, invoices automatically progress through the issuing state and are
1964
+ * immediately marked as issued.
1965
+ */
1966
+ enableIssuingSyncHook: boolean;
1967
+ }
1805
1968
  /**
1806
1969
  * Identity stores the details required to identify an entity for tax purposes in a
1807
1970
  * specific country.
@@ -1912,39 +2075,6 @@ export interface ListCurrenciesParamsFilter {
1912
2075
  type?: 'fiat' | 'custom';
1913
2076
  code?: StringFieldFilter;
1914
2077
  }
1915
- /** Describes custom currency. */
1916
- export interface CurrencyCustom {
1917
- /** The type of the currency. */
1918
- type: 'custom';
1919
- /**
1920
- * The name of the currency. It should be a human-readable string that represents
1921
- * the name of the currency, such as "US Dollar" or "Euro".
1922
- */
1923
- name: string;
1924
- /**
1925
- * The symbol of the currency. It should be a string that represents the symbol of
1926
- * the currency, such as "$" for US Dollar or "€" for Euro.
1927
- */
1928
- symbol?: string;
1929
- id: string;
1930
- code: string;
1931
- /** An ISO-8601 timestamp representation of the custom currency creation date. */
1932
- createdAt: Date;
1933
- }
1934
- /** CurrencyCustom create request. */
1935
- export interface CreateCurrencyCustomRequest {
1936
- /**
1937
- * The name of the currency. It should be a human-readable string that represents
1938
- * the name of the currency, such as "US Dollar" or "Euro".
1939
- */
1940
- name: string;
1941
- /**
1942
- * The symbol of the currency. It should be a string that represents the symbol of
1943
- * the currency, such as "$" for US Dollar or "€" for Euro.
1944
- */
1945
- symbol?: string;
1946
- code: string;
1947
- }
1948
2078
  /** Query to evaluate feature access for a list of customers. */
1949
2079
  export interface GovernanceQueryRequest {
1950
2080
  /**
@@ -2017,7 +2147,12 @@ export interface CreditAdjustment {
2017
2147
  /** The credit balance by currency. */
2018
2148
  export interface CreditBalance {
2019
2149
  currency: BillingCurrencyCode;
2020
- /** Credits available after applying currently live charge impacts. */
2150
+ /**
2151
+ * Credits available after applying currently live charge impacts.
2152
+ *
2153
+ * Always zero for historical balance queries using the `timestamp` parameter
2154
+ * because live charge impacts cannot be reconstructed historically.
2155
+ */
2021
2156
  live: string;
2022
2157
  /** Credits that have been booked on the ledger as of the balance timestamp. */
2023
2158
  settled: string;
@@ -2524,6 +2659,46 @@ export interface MeterQueryResult {
2524
2659
  /** The usage data. If no data is available, an empty array is returned. */
2525
2660
  data: MeterQueryRow[];
2526
2661
  }
2662
+ /** Describes custom currency. */
2663
+ export interface CurrencyCustom {
2664
+ /** The type of the currency. */
2665
+ type: 'custom';
2666
+ /**
2667
+ * The name of the currency. It should be a human-readable string that represents
2668
+ * the name of the currency, such as "US Dollar" or "Euro".
2669
+ */
2670
+ name: string;
2671
+ /**
2672
+ * The symbol of the currency. It should be a string that represents the symbol of
2673
+ * the currency, such as "$" for US Dollar or "€" for Euro.
2674
+ */
2675
+ symbol?: string;
2676
+ /**
2677
+ * The precision of the currency. It should be a number that represents the number
2678
+ * of decimal places used for the currency, such as 2 for US Dollar or Euro.
2679
+ */
2680
+ precision: number;
2681
+ /**
2682
+ * The decimal mark for the currency. It should be a string that represents the
2683
+ * decimal mark of the currency, such as "." for US Dollar or "," for Euro.
2684
+ */
2685
+ decimalMark: string;
2686
+ /**
2687
+ * The thousand separator for the currency. It should be a string that represents
2688
+ * the thousand separator of the currency, such as "," for US Dollar or "." for
2689
+ * Euro.
2690
+ */
2691
+ thousandSeparator: string;
2692
+ id: string;
2693
+ code: string;
2694
+ /** An ISO-8601 timestamp representation of the custom currency creation date. */
2695
+ createdAt: Date;
2696
+ /**
2697
+ * The list of active and scheduled cost bases for the custom currency. Expired and
2698
+ * deleted cost bases are excluded.
2699
+ */
2700
+ costBasis?: CostBasis[];
2701
+ }
2527
2702
  /** Result of a feature cost query. */
2528
2703
  export interface FeatureCostQueryResult {
2529
2704
  /** Start of the queried period. */
@@ -2847,159 +3022,24 @@ export interface CreateSubscriptionAddonRequest {
2847
3022
  * Usage quantity details on an invoice line item when UnitConfig is in effect.
2848
3023
  *
2849
3024
  * Provides the full audit trail from raw meter output to the invoiced amount.
2850
- */
2851
- export interface InvoiceUsageQuantityDetail {
2852
- /** The raw quantity as reported by the meter (native units). */
2853
- rawQuantity: string;
2854
- /**
2855
- * The precise decimal value after applying the conversion operation and factor,
2856
- * before rounding.
2857
- */
2858
- convertedQuantity: string;
2859
- /** The quantity after rounding, used for pricing. */
2860
- invoicedQuantity: string;
2861
- /** The display unit label (e.g., "GB", "hours", "M tokens"). */
2862
- displayUnit?: string;
2863
- /**
2864
- * Snapshot of the UnitConfig that was in effect at billing time. Ensures
2865
- * historical invoices reflect the config that was actually applied.
2866
- */
2867
- appliedUnitConfig: UnitConfig;
2868
- }
2869
- /** Stripe app. */
2870
- export interface AppStripe {
2871
- id: string;
2872
- /**
2873
- * Display name of the resource.
2874
- *
2875
- * Between 1 and 256 characters.
2876
- */
2877
- name: string;
2878
- /**
2879
- * Optional description of the resource.
2880
- *
2881
- * Maximum 1024 characters.
2882
- */
2883
- description?: string;
2884
- labels?: Labels;
2885
- /** An ISO-8601 timestamp representation of entity creation date. */
2886
- createdAt: Date;
2887
- /** An ISO-8601 timestamp representation of entity last update date. */
2888
- updatedAt: Date;
2889
- /** An ISO-8601 timestamp representation of entity deletion date. */
2890
- deletedAt?: Date;
2891
- /** The app type. */
2892
- type: 'stripe';
2893
- /** The app catalog definition that this installed app is based on. */
2894
- definition: AppCatalogItem;
2895
- /** Status of the app connection. */
2896
- status: 'ready' | 'unauthorized';
2897
- /** The Stripe account ID associated with the connected Stripe account. */
2898
- accountId: string;
2899
- /** Indicates whether the app is connected to a live Stripe account. */
2900
- livemode: boolean;
2901
- /** The masked Stripe API key that only exposes the first and last few characters. */
2902
- maskedApiKey: string;
2903
- }
2904
- /** Sandbox app can be used for testing billing features. */
2905
- export interface AppSandbox {
2906
- id: string;
2907
- /**
2908
- * Display name of the resource.
2909
- *
2910
- * Between 1 and 256 characters.
2911
- */
2912
- name: string;
2913
- /**
2914
- * Optional description of the resource.
2915
- *
2916
- * Maximum 1024 characters.
2917
- */
2918
- description?: string;
2919
- labels?: Labels;
2920
- /** An ISO-8601 timestamp representation of entity creation date. */
2921
- createdAt: Date;
2922
- /** An ISO-8601 timestamp representation of entity last update date. */
2923
- updatedAt: Date;
2924
- /** An ISO-8601 timestamp representation of entity deletion date. */
2925
- deletedAt?: Date;
2926
- /** The app type. */
2927
- type: 'sandbox';
2928
- /** The app catalog definition that this installed app is based on. */
2929
- definition: AppCatalogItem;
2930
- /** Status of the app connection. */
2931
- status: 'ready' | 'unauthorized';
2932
- }
2933
- /**
2934
- * External Invoicing app enables integration with third-party invoicing or payment
2935
- * system.
2936
- *
2937
- * The app supports a bi-directional synchronization pattern where OpenMeter
2938
- * Billing manages the invoice lifecycle while the external system handles invoice
2939
- * presentation and payment collection.
2940
- *
2941
- * Integration workflow:
2942
- *
2943
- * 1. The billing system creates invoices and transitions them through lifecycle
2944
- * states (draft → issuing → issued)
2945
- * 2. The integration receives webhook notifications about invoice state changes
2946
- * 3. The integration calls back to provide external system IDs and metadata
2947
- * 4. The integration reports payment events back via the payment status API
2948
- *
2949
- * State synchronization is controlled by hooks that pause invoice progression
2950
- * until the external system confirms synchronization via API callbacks.
2951
- */
2952
- export interface AppExternalInvoicing {
2953
- id: string;
2954
- /**
2955
- * Display name of the resource.
2956
- *
2957
- * Between 1 and 256 characters.
2958
- */
2959
- name: string;
2960
- /**
2961
- * Optional description of the resource.
2962
- *
2963
- * Maximum 1024 characters.
2964
- */
2965
- description?: string;
2966
- labels?: Labels;
2967
- /** An ISO-8601 timestamp representation of entity creation date. */
2968
- createdAt: Date;
2969
- /** An ISO-8601 timestamp representation of entity last update date. */
2970
- updatedAt: Date;
2971
- /** An ISO-8601 timestamp representation of entity deletion date. */
2972
- deletedAt?: Date;
2973
- /** The app type. */
2974
- type: 'external_invoicing';
2975
- /** The app catalog definition that this installed app is based on. */
2976
- definition: AppCatalogItem;
2977
- /** Status of the app connection. */
2978
- status: 'ready' | 'unauthorized';
2979
- /**
2980
- * Enable draft synchronization hook.
2981
- *
2982
- * When enabled, invoices will pause at the draft state and wait for the
2983
- * integration to call the draft synchronized endpoint before progressing to the
2984
- * issuing state. This allows the external system to validate and prepare the
2985
- * invoice data.
2986
- *
2987
- * When disabled, invoices automatically progress through the draft state based on
2988
- * the configured workflow timing.
3025
+ */
3026
+ export interface InvoiceUsageQuantityDetail {
3027
+ /** The raw quantity as reported by the meter (native units). */
3028
+ rawQuantity: string;
3029
+ /**
3030
+ * The precise decimal value after applying the conversion operation and factor,
3031
+ * before rounding.
2989
3032
  */
2990
- enableDraftSyncHook: boolean;
3033
+ convertedQuantity: string;
3034
+ /** The quantity after rounding, used for pricing. */
3035
+ invoicedQuantity: string;
3036
+ /** The display unit label (e.g., "GB", "hours", "M tokens"). */
3037
+ displayUnit?: string;
2991
3038
  /**
2992
- * Enable issuing synchronization hook.
2993
- *
2994
- * When enabled, invoices will pause at the issuing state and wait for the
2995
- * integration to call the issuing synchronized endpoint before progressing to the
2996
- * issued state. This ensures the external invoicing system has successfully
2997
- * created and finalized the invoice before it is marked as issued.
2998
- *
2999
- * When disabled, invoices automatically progress through the issuing state and are
3000
- * immediately marked as issued.
3039
+ * Snapshot of the UnitConfig that was in effect at billing time. Ensures
3040
+ * historical invoices reflect the config that was actually applied.
3001
3041
  */
3002
- enableIssuingSyncHook: boolean;
3042
+ appliedUnitConfig: UnitConfig;
3003
3043
  }
3004
3044
  /** TaxCode create request. */
3005
3045
  export interface CreateTaxCodeRequest {
@@ -3064,6 +3104,24 @@ export interface UpsertTaxCodeRequest {
3064
3104
  /** Mapping of app types to tax codes. */
3065
3105
  appMappings: TaxCodeAppMapping[];
3066
3106
  }
3107
+ /**
3108
+ * Available apps for billing integrations to connect with third-party services.
3109
+ * Apps can have various capabilities like syncing data from or to external
3110
+ * systems, integrating with third-party services for tax calculation, delivery of
3111
+ * invoices, collection of payments, etc.
3112
+ */
3113
+ export interface AppCatalogItem {
3114
+ /** Type of the app. */
3115
+ type: 'sandbox' | 'stripe' | 'external_invoicing';
3116
+ /** Name of the app. */
3117
+ name: string;
3118
+ /** Description of the app. */
3119
+ description: string;
3120
+ /** Capabilities of the app. */
3121
+ capabilities: AppCapability[];
3122
+ /** Available install methods of the app. */
3123
+ installMethods: ('with_oauth2' | 'with_api_key' | 'no_credentials_required')[];
3124
+ }
3067
3125
  /**
3068
3126
  * Invoice-level snapshot of the workflow configuration.
3069
3127
  *
@@ -3277,8 +3335,9 @@ export interface CreateCreditGrantRequest {
3277
3335
  /**
3278
3336
  * Idempotency key for the credit grant creation request.
3279
3337
  *
3280
- * When provided, reusing the same key returns an HTTP 409 Conflict instead of
3281
- * creating a duplicate grant, which makes create requests safe to retry.
3338
+ * Unique per customer: reusing the same key for the same customer returns an HTTP
3339
+ * 409 Conflict instead of creating a duplicate grant, which makes create requests
3340
+ * safe to retry. The same key may be reused across different customers.
3282
3341
  */
3283
3342
  key?: string;
3284
3343
  }
@@ -3340,8 +3399,9 @@ export interface CreditGrant {
3340
3399
  /**
3341
3400
  * Idempotency key for the credit grant creation request.
3342
3401
  *
3343
- * When provided, reusing the same key returns an HTTP 409 Conflict instead of
3344
- * creating a duplicate grant, which makes create requests safe to retry.
3402
+ * Unique per customer: reusing the same key for the same customer returns an HTTP
3403
+ * 409 Conflict instead of creating a duplicate grant, which makes create requests
3404
+ * safe to retry. The same key may be reused across different customers.
3345
3405
  */
3346
3406
  key?: string;
3347
3407
  /**
@@ -3616,6 +3676,146 @@ export interface TaxCodePagePaginatedResponse {
3616
3676
  data: TaxCode[];
3617
3677
  meta: PaginatedMeta;
3618
3678
  }
3679
+ /** Stripe app. */
3680
+ export interface AppStripe {
3681
+ id: string;
3682
+ /**
3683
+ * Display name of the resource.
3684
+ *
3685
+ * Between 1 and 256 characters.
3686
+ */
3687
+ name: string;
3688
+ /**
3689
+ * Optional description of the resource.
3690
+ *
3691
+ * Maximum 1024 characters.
3692
+ */
3693
+ description?: string;
3694
+ labels?: Labels;
3695
+ /** An ISO-8601 timestamp representation of entity creation date. */
3696
+ createdAt: Date;
3697
+ /** An ISO-8601 timestamp representation of entity last update date. */
3698
+ updatedAt: Date;
3699
+ /** An ISO-8601 timestamp representation of entity deletion date. */
3700
+ deletedAt?: Date;
3701
+ /** The app type. */
3702
+ type: 'stripe';
3703
+ /** The app catalog definition that this installed app is based on. */
3704
+ definition: AppCatalogItem;
3705
+ /** Status of the app connection. */
3706
+ status: 'ready' | 'unauthorized';
3707
+ /** The Stripe account ID associated with the connected Stripe account. */
3708
+ accountId: string;
3709
+ /** Indicates whether the app is connected to a live Stripe account. */
3710
+ livemode: boolean;
3711
+ /** The masked Stripe API key that only exposes the first and last few characters. */
3712
+ maskedApiKey: string;
3713
+ }
3714
+ /** Sandbox app can be used for testing billing features. */
3715
+ export interface AppSandbox {
3716
+ id: string;
3717
+ /**
3718
+ * Display name of the resource.
3719
+ *
3720
+ * Between 1 and 256 characters.
3721
+ */
3722
+ name: string;
3723
+ /**
3724
+ * Optional description of the resource.
3725
+ *
3726
+ * Maximum 1024 characters.
3727
+ */
3728
+ description?: string;
3729
+ labels?: Labels;
3730
+ /** An ISO-8601 timestamp representation of entity creation date. */
3731
+ createdAt: Date;
3732
+ /** An ISO-8601 timestamp representation of entity last update date. */
3733
+ updatedAt: Date;
3734
+ /** An ISO-8601 timestamp representation of entity deletion date. */
3735
+ deletedAt?: Date;
3736
+ /** The app type. */
3737
+ type: 'sandbox';
3738
+ /** The app catalog definition that this installed app is based on. */
3739
+ definition: AppCatalogItem;
3740
+ /** Status of the app connection. */
3741
+ status: 'ready' | 'unauthorized';
3742
+ }
3743
+ /**
3744
+ * External Invoicing app enables integration with third-party invoicing or payment
3745
+ * system.
3746
+ *
3747
+ * The app supports a bi-directional synchronization pattern where OpenMeter
3748
+ * Billing manages the invoice lifecycle while the external system handles invoice
3749
+ * presentation and payment collection.
3750
+ *
3751
+ * Integration workflow:
3752
+ *
3753
+ * 1. The billing system creates invoices and transitions them through lifecycle
3754
+ * states (draft → issuing → issued)
3755
+ * 2. The integration receives webhook notifications about invoice state changes
3756
+ * 3. The integration calls back to provide external system IDs and metadata
3757
+ * 4. The integration reports payment events back via the payment status API
3758
+ *
3759
+ * State synchronization is controlled by hooks that pause invoice progression
3760
+ * until the external system confirms synchronization via API callbacks.
3761
+ */
3762
+ export interface AppExternalInvoicing {
3763
+ id: string;
3764
+ /**
3765
+ * Display name of the resource.
3766
+ *
3767
+ * Between 1 and 256 characters.
3768
+ */
3769
+ name: string;
3770
+ /**
3771
+ * Optional description of the resource.
3772
+ *
3773
+ * Maximum 1024 characters.
3774
+ */
3775
+ description?: string;
3776
+ labels?: Labels;
3777
+ /** An ISO-8601 timestamp representation of entity creation date. */
3778
+ createdAt: Date;
3779
+ /** An ISO-8601 timestamp representation of entity last update date. */
3780
+ updatedAt: Date;
3781
+ /** An ISO-8601 timestamp representation of entity deletion date. */
3782
+ deletedAt?: Date;
3783
+ /** The app type. */
3784
+ type: 'external_invoicing';
3785
+ /** The app catalog definition that this installed app is based on. */
3786
+ definition: AppCatalogItem;
3787
+ /** Status of the app connection. */
3788
+ status: 'ready' | 'unauthorized';
3789
+ /**
3790
+ * Enable draft synchronization hook.
3791
+ *
3792
+ * When enabled, invoices will pause at the draft state and wait for the
3793
+ * integration to call the draft synchronized endpoint before progressing to the
3794
+ * issuing state. This allows the external system to validate and prepare the
3795
+ * invoice data.
3796
+ *
3797
+ * When disabled, invoices automatically progress through the draft state based on
3798
+ * the configured workflow timing.
3799
+ */
3800
+ enableDraftSyncHook: boolean;
3801
+ /**
3802
+ * Enable issuing synchronization hook.
3803
+ *
3804
+ * When enabled, invoices will pause at the issuing state and wait for the
3805
+ * integration to call the issuing synchronized endpoint before progressing to the
3806
+ * issued state. This ensures the external invoicing system has successfully
3807
+ * created and finalized the invoice before it is marked as issued.
3808
+ *
3809
+ * When disabled, invoices automatically progress through the issuing state and are
3810
+ * immediately marked as issued.
3811
+ */
3812
+ enableIssuingSyncHook: boolean;
3813
+ }
3814
+ /** Page paginated response. */
3815
+ export interface AppCatalogItemPagePaginatedResponse {
3816
+ data: AppCatalogItem[];
3817
+ meta: PaginatedMeta;
3818
+ }
3619
3819
  /** Snapshot of the billing workflow configuration captured at invoice creation. */
3620
3820
  export interface InvoiceWorkflowSettings {
3621
3821
  /** The apps that will be used to orchestrate the invoice's workflow. */
@@ -3688,11 +3888,6 @@ export interface UpdateInvoiceWorkflowSettings {
3688
3888
  */
3689
3889
  workflow: UpdateBillingInvoiceWorkflow;
3690
3890
  }
3691
- /** Page paginated response. */
3692
- export interface CurrencyPagePaginatedResponse {
3693
- data: Currency[];
3694
- meta: PaginatedMeta;
3695
- }
3696
3891
  /** Access evaluation result for a single resolved customer. */
3697
3892
  export interface GovernanceQueryResult {
3698
3893
  /**
@@ -3800,6 +3995,11 @@ export interface CreditGrantPagePaginatedResponse {
3800
3995
  data: CreditGrant[];
3801
3996
  meta: PaginatedMeta;
3802
3997
  }
3998
+ /** Page paginated response. */
3999
+ export interface CurrencyPagePaginatedResponse {
4000
+ data: Currency[];
4001
+ meta: PaginatedMeta;
4002
+ }
3803
4003
  /** Bad Request. */
3804
4004
  export interface BadRequest extends BaseError {
3805
4005
  /** The list of parameters that failed validation. */
@@ -3888,20 +4088,6 @@ export interface WorkflowCollectionSettings {
3888
4088
  */
3889
4089
  interval: string;
3890
4090
  }
3891
- /** Page paginated response. */
3892
- export interface AppPagePaginatedResponse {
3893
- data: App[];
3894
- meta: PaginatedMeta;
3895
- }
3896
- /** Applications used by a billing profile. */
3897
- export interface ProfileApps {
3898
- /** The tax app used for this workflow. */
3899
- tax: App;
3900
- /** The invoicing app used for this workflow. */
3901
- invoicing: App;
3902
- /** The payment app used for this workflow. */
3903
- payment: App;
3904
- }
3905
4091
  /** Response of the governance query. */
3906
4092
  export interface GovernanceQueryResponse {
3907
4093
  /** Access evaluation results, one entry per resolved customer. */
@@ -4086,6 +4272,11 @@ export interface RateCard {
4086
4272
  key: string;
4087
4273
  /** The feature associated with the rate card. */
4088
4274
  feature?: FeatureReference;
4275
+ /**
4276
+ * Overrides the containing plan or add-on currency for this rate card. When
4277
+ * omitted, the containing resource currency applies.
4278
+ */
4279
+ currency?: BillingCurrencyCode;
4089
4280
  /**
4090
4281
  * The billing cadence of the rate card. When null, the charge is one-time
4091
4282
  * (non-recurring). Only valid for flat prices.
@@ -4134,6 +4325,11 @@ export interface InvoiceLineRateCard {
4134
4325
  featureKey?: string;
4135
4326
  /** Discount configuration from the rate card. */
4136
4327
  discounts?: RateCardDiscounts;
4328
+ /**
4329
+ * Unit config snapshot applied when this line was billed, converting the raw
4330
+ * metered quantity into the billed quantity. Frozen at billing time; read-only.
4331
+ */
4332
+ unitConfig?: UnitConfig;
4137
4333
  }
4138
4334
  /** Rate card configuration snapshot for a usage-based invoice line. */
4139
4335
  export interface UpdateInvoiceLineRateCard {
@@ -4162,6 +4358,25 @@ export interface Workflow {
4162
4358
  /** The tax settings for this workflow */
4163
4359
  tax?: WorkflowTaxSettings;
4164
4360
  }
4361
+ /** Page paginated response. */
4362
+ export interface AppPagePaginatedResponse {
4363
+ data: App[];
4364
+ meta: PaginatedMeta;
4365
+ }
4366
+ /** Response of the app install. */
4367
+ export interface BillingInstallAppResponse {
4368
+ app: App;
4369
+ defaultForCapabilityTypes: ('report_usage' | 'report_events' | 'calculate_tax' | 'invoice_customers' | 'collect_payments')[];
4370
+ }
4371
+ /** Applications used by a billing profile. */
4372
+ export interface ProfileApps {
4373
+ /** The tax app used for this workflow. */
4374
+ tax: App;
4375
+ /** The invoicing app used for this workflow. */
4376
+ invoicing: App;
4377
+ /** The payment app used for this workflow. */
4378
+ payment: App;
4379
+ }
4165
4380
  /** A usage-based charge for a customer. */
4166
4381
  export interface ChargeUsageBased {
4167
4382
  id: string;
@@ -4655,7 +4870,7 @@ export interface Plan {
4655
4870
  */
4656
4871
  version: number;
4657
4872
  /** The currency code of the plan. */
4658
- currency: string;
4873
+ currency: BillingCurrencyCode;
4659
4874
  /** The billing cadence for subscriptions using this plan. */
4660
4875
  billingCadence: string;
4661
4876
  /** Whether pro-rating is enabled for this plan. */
@@ -4723,7 +4938,7 @@ export interface CreatePlanRequest {
4723
4938
  */
4724
4939
  key: string;
4725
4940
  /** The currency code of the plan. */
4726
- currency: string;
4941
+ currency: BillingCurrencyCode;
4727
4942
  /** The billing cadence for subscriptions using this plan. */
4728
4943
  billingCadence: string;
4729
4944
  /** Whether pro-rating is enabled for this plan. */
@@ -4934,9 +5149,9 @@ export type StringFieldFilterExact = string | {
4934
5149
  /** The payment term of a flat price. */
4935
5150
  export type PricePaymentTerm = 'in_advance' | 'in_arrears';
4936
5151
  /** Fiat or custom currency code. */
4937
- export type BillingCurrencyCode = string;
5152
+ export type BillingCurrencyCode = string | string;
4938
5153
  /** Fiat or custom currency code. */
4939
- export type CreateCurrencyCode = string;
5154
+ export type CreateCurrencyCode = string | string;
4940
5155
  /**
4941
5156
  * Filters on the given ULID field value by exact match. All properties are
4942
5157
  * optional; provide exactly one to specify the comparison.
@@ -4963,6 +5178,8 @@ export type DateTimeFieldFilter = Date | {
4963
5178
  * returned.
4964
5179
  */
4965
5180
  export type SubscriptionEditTiming = 'immediate' | 'next_billing_cycle' | Date;
5181
+ /** Request to install an app from the catalog. */
5182
+ export type InstallAppRequest = InstallAppStripeWithApiKey | InstallAppSandbox | InstallAppExternalInvoicing;
4966
5183
  /** Payment settings for a billing workflow. */
4967
5184
  export type WorkflowPaymentSettings = WorkflowPaymentChargeAutomaticallySettings | WorkflowPaymentSendInvoiceSettings;
4968
5185
  /** Payment settings for a billing workflow. */
@@ -4974,13 +5191,15 @@ export type InvalidParameter = InvalidParameterStandard | InvalidParameterMinimu
4974
5191
  * rate card itself, so it is omitted here.
4975
5192
  */
4976
5193
  export type RateCardEntitlement = RateCardMeteredEntitlement | RateCardStaticEntitlement | RateCardBooleanEntitlement;
4977
- /** Fiat or custom currency. */
4978
- export type Currency = CurrencyFiat | CurrencyCustom;
5194
+ /** Request to update an installed app. */
5195
+ export type UpdateAppRequest = UpdateAppStripeRequest | UpdateAppSandboxRequest | UpdateAppExternalInvoicingRequest;
4979
5196
  /**
4980
5197
  * Per-unit cost configuration for a feature. Either a fixed manual amount or a
4981
5198
  * dynamic LLM cost lookup.
4982
5199
  */
4983
5200
  export type FeatureUnitCost = FeatureManualUnitCost | FeatureLlmUnitCost;
5201
+ /** Fiat or custom currency. */
5202
+ export type Currency = CurrencyFiat | CurrencyCustom;
4984
5203
  /**
4985
5204
  * The alignment for collecting the pending line items into an invoice.
4986
5205
  *
@@ -4989,12 +5208,12 @@ export type FeatureUnitCost = FeatureManualUnitCost | FeatureLlmUnitCost;
4989
5208
  * arrears items).
4990
5209
  */
4991
5210
  export type WorkflowCollectionAlignment = WorkflowCollectionAlignmentSubscription | WorkflowCollectionAlignmentAnchored;
4992
- /** Installed application. */
4993
- export type App = AppStripe | AppSandbox | AppExternalInvoicing;
4994
5211
  /** Price. */
4995
5212
  export type Price = PriceFree | PriceFlat | PriceUnit | PriceGraduated | PriceVolume;
4996
5213
  /** Price. */
4997
5214
  export type UpdatePrice = UpdatePriceFree | UpdatePriceFlat | UpdatePriceUnit | UpdatePriceGraduated | UpdatePriceVolume;
5215
+ /** Installed application. */
5216
+ export type App = AppStripe | AppSandbox | AppExternalInvoicing;
4998
5217
  /** Customer charge. */
4999
5218
  export type CreateChargeRequest = CreateChargeFlatFeeRequest | CreateChargeUsageBasedRequest;
5000
5219
  /** Customer charge. */
@@ -5217,9 +5436,10 @@ export interface CreateCreditGrantPurchaseInput {
5217
5436
  /**
5218
5437
  * Cost basis per credit unit used to calculate the purchase amount.
5219
5438
  *
5220
- * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
5221
- * is $50.00. The value must be greater than 0. If the cost basis is 0, use
5222
- * `funding_method=none` instead.
5439
+ * If `per_unit_cost_basis` is 0.50 and credit amount is
5440
+ * $100.00, the total
5441
+ * charge is $50.00. The value must be greater than 0. If the
5442
+ * cost basis is 0, use `funding_method=none` instead.
5223
5443
  *
5224
5444
  * Defaults to 1.0.
5225
5445
  */
@@ -5260,9 +5480,10 @@ export interface CreditGrantPurchaseInput {
5260
5480
  /**
5261
5481
  * Cost basis per credit unit used to calculate the purchase amount.
5262
5482
  *
5263
- * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
5264
- * is $50.00. The value must be greater than 0. If the cost basis is 0, use
5265
- * `funding_method=none` instead.
5483
+ * If `per_unit_cost_basis` is 0.50 and credit amount is
5484
+ * $100.00, the total
5485
+ * charge is $50.00. The value must be greater than 0. If the
5486
+ * cost basis is 0, use `funding_method=none` instead.
5266
5487
  *
5267
5488
  * Defaults to 1.0.
5268
5489
  */
@@ -5487,8 +5708,9 @@ export interface CreateCreditGrantRequestInput {
5487
5708
  /**
5488
5709
  * Idempotency key for the credit grant creation request.
5489
5710
  *
5490
- * When provided, reusing the same key returns an HTTP 409 Conflict instead of
5491
- * creating a duplicate grant, which makes create requests safe to retry.
5711
+ * Unique per customer: reusing the same key for the same customer returns an HTTP
5712
+ * 409 Conflict instead of creating a duplicate grant, which makes create requests
5713
+ * safe to retry. The same key may be reused across different customers.
5492
5714
  */
5493
5715
  key?: string;
5494
5716
  }
@@ -5550,8 +5772,9 @@ export interface CreditGrantInput {
5550
5772
  /**
5551
5773
  * Idempotency key for the credit grant creation request.
5552
5774
  *
5553
- * When provided, reusing the same key returns an HTTP 409 Conflict instead of
5554
- * creating a duplicate grant, which makes create requests safe to retry.
5775
+ * Unique per customer: reusing the same key for the same customer returns an HTTP
5776
+ * 409 Conflict instead of creating a duplicate grant, which makes create requests
5777
+ * safe to retry. The same key may be reused across different customers.
5555
5778
  */
5556
5779
  key?: string;
5557
5780
  /**
@@ -5841,6 +6064,11 @@ export interface RateCardInput {
5841
6064
  key: string;
5842
6065
  /** The feature associated with the rate card. */
5843
6066
  feature?: FeatureReference;
6067
+ /**
6068
+ * Overrides the containing plan or add-on currency for this rate card. When
6069
+ * omitted, the containing resource currency applies.
6070
+ */
6071
+ currency?: BillingCurrencyCode;
5844
6072
  /**
5845
6073
  * The billing cadence of the rate card. When null, the charge is one-time
5846
6074
  * (non-recurring). Only valid for flat prices.
@@ -5879,6 +6107,22 @@ export interface RateCardInput {
5879
6107
  */
5880
6108
  entitlement?: RateCardEntitlementInput;
5881
6109
  }
6110
+ /** Rate card configuration snapshot for a usage-based invoice line. */
6111
+ export interface InvoiceLineRateCardInput {
6112
+ /** The price definition used to calculate charges for this line. */
6113
+ price: Price;
6114
+ /** Tax configuration snapshot for this line. */
6115
+ taxConfig?: RateCardTaxConfig;
6116
+ /** The feature key associated with this line's rate card. */
6117
+ featureKey?: string;
6118
+ /** Discount configuration from the rate card. */
6119
+ discounts?: RateCardDiscounts;
6120
+ /**
6121
+ * Unit config snapshot applied when this line was billed, converting the raw
6122
+ * metered quantity into the billed quantity. Frozen at billing time; read-only.
6123
+ */
6124
+ unitConfig?: UnitConfigInput;
6125
+ }
5882
6126
  /** Billing workflow settings. */
5883
6127
  export interface WorkflowInput {
5884
6128
  /** The collection settings for this workflow */
@@ -6094,7 +6338,7 @@ export interface InvoiceStandardLineInput {
6094
6338
  /** Reference to the subscription item that generated this line. */
6095
6339
  subscription?: SubscriptionReference;
6096
6340
  /** The rate card configuration snapshot used to price this line item. */
6097
- rateCard: InvoiceLineRateCard;
6341
+ rateCard: InvoiceLineRateCardInput;
6098
6342
  /**
6099
6343
  * Detailed sub-lines that this line has been broken down into.
6100
6344
  *
@@ -6267,7 +6511,7 @@ export interface PlanInput {
6267
6511
  */
6268
6512
  version?: number;
6269
6513
  /** The currency code of the plan. */
6270
- currency: string;
6514
+ currency: BillingCurrencyCode;
6271
6515
  /** The billing cadence for subscriptions using this plan. */
6272
6516
  billingCadence: string;
6273
6517
  /** Whether pro-rating is enabled for this plan. */
@@ -6335,7 +6579,7 @@ export interface CreatePlanRequestInput {
6335
6579
  */
6336
6580
  key: string;
6337
6581
  /** The currency code of the plan. */
6338
- currency: string;
6582
+ currency: BillingCurrencyCode;
6339
6583
  /** The billing cadence for subscriptions using this plan. */
6340
6584
  billingCadence: string;
6341
6585
  /** Whether pro-rating is enabled for this plan. */