lago-javascript-client 0.51.0-beta → 0.56.0-beta

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.
@@ -174,7 +174,7 @@ export interface AppliedCouponInput {
174
174
  * - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
175
175
  * @example "recurring"
176
176
  */
177
- frequency?: "once" | "recurring" | null;
177
+ frequency?: "once" | "recurring" | "forever" | null;
178
178
  /**
179
179
  * Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
180
180
  * @example 3
@@ -260,7 +260,7 @@ export interface AppliedCouponObject {
260
260
  * - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
261
261
  * @example "recurring"
262
262
  */
263
- frequency: "once" | "recurring";
263
+ frequency: "once" | "recurring" | "forever";
264
264
  /**
265
265
  * Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
266
266
  * @example 3
@@ -663,6 +663,11 @@ export interface ChargeProperties {
663
663
  * @example "1.75"
664
664
  */
665
665
  per_transaction_min_amount?: string | null;
666
+ /**
667
+ * The list of event properties that are used to group the events on the invoice for a `standard` charge model.
668
+ * @example ["agent_name"]
669
+ */
670
+ grouped_by?: string[];
666
671
  /** Volume ranges, sorted from bottom to top tiers, used for a `volume` charge model. */
667
672
  volume_ranges?: {
668
673
  /**
@@ -746,7 +751,7 @@ export interface CouponBaseInput {
746
751
  * - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
747
752
  * @example "recurring"
748
753
  */
749
- frequency?: "once" | "recurring";
754
+ frequency?: "once" | "recurring" | "forever";
750
755
  /**
751
756
  * Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
752
757
  * @example 6
@@ -859,7 +864,7 @@ export interface CouponObject {
859
864
  * - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
860
865
  * @example "recurring"
861
866
  */
862
- frequency: "once" | "recurring";
867
+ frequency: "once" | "recurring" | "forever";
863
868
  /**
864
869
  * Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
865
870
  * @example 6
@@ -1315,6 +1320,11 @@ export interface CustomerBillingConfiguration {
1315
1320
  * @example "stripe"
1316
1321
  */
1317
1322
  payment_provider?: "stripe" | "adyen" | "gocardless";
1323
+ /**
1324
+ * Unique code used to identify a payment provider connection.
1325
+ * @example "stripe-eu-1"
1326
+ */
1327
+ payment_provider_code?: string;
1318
1328
  /**
1319
1329
  * The customer ID within the payment provider's system. If this field is not provided, Lago has the option to create a new customer record within the payment provider's system on behalf of the customer
1320
1330
  * @example "cus_12345"
@@ -1341,6 +1351,64 @@ export interface CustomerBillingConfiguration {
1341
1351
  */
1342
1352
  provider_payment_methods?: string[] | null;
1343
1353
  }
1354
+ /** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
1355
+ export type CustomerChargeGroupedUsageObject = {
1356
+ /**
1357
+ * The amount in cents, tax excluded, consumed for a specific group related to a charge item.
1358
+ * @example 1000
1359
+ */
1360
+ amount_cents?: number;
1361
+ /**
1362
+ * The quantity of usage events that have been recorded for a particular charge during the specified time period. These events may also be referred to as the number of transactions in some contexts.
1363
+ * @example 10
1364
+ */
1365
+ events_count?: number;
1366
+ /**
1367
+ * The number of units consumed for a specific group related to a charge item.
1368
+ * @pattern ^[0-9]+.?[0-9]*$
1369
+ * @example "0.9"
1370
+ */
1371
+ units?: string;
1372
+ /** Key value list of event properties aggregated by the charge model */
1373
+ grouped_by?: Record<string, string>;
1374
+ /** Array of group object, representing multiple dimensions for a charge item. */
1375
+ groups?: CustomerChargeGroupsUsageObject;
1376
+ }[];
1377
+ /** Array of group object, representing multiple dimensions for a charge item. */
1378
+ export type CustomerChargeGroupsUsageObject = {
1379
+ /**
1380
+ * Unique identifier assigned to the group within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the group record within the Lago system.
1381
+ * @format uuid
1382
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
1383
+ */
1384
+ lago_id?: string;
1385
+ /**
1386
+ * The group key, only returned for groups with two dimensions.
1387
+ * @example null
1388
+ */
1389
+ key?: string | null;
1390
+ /**
1391
+ * The group value.
1392
+ * @example "europe"
1393
+ */
1394
+ value?: string;
1395
+ /**
1396
+ * The number of units consumed for a specific group related to a charge item.
1397
+ * @pattern ^[0-9]+.?[0-9]*$
1398
+ * @example "0.9"
1399
+ */
1400
+ units?: string;
1401
+ /**
1402
+ * The quantity of usage events that have been recorded for a particular charge during the specified time period. These events may also be referred to as the number of transactions in some contexts.
1403
+ * @example 10
1404
+ */
1405
+ events_count?: number;
1406
+ /**
1407
+ * The amount in cents, tax excluded, consumed for a specific group related to a charge item.
1408
+ * @example 1000
1409
+ */
1410
+ amount_cents?: number;
1411
+ }[];
1344
1412
  export interface CustomerChargeUsageObject {
1345
1413
  /**
1346
1414
  * The number of units consumed by the customer for a specific charge item.
@@ -1373,6 +1441,11 @@ export interface CustomerChargeUsageObject {
1373
1441
  * @example "graduated"
1374
1442
  */
1375
1443
  charge_model: "standard" | "graduated" | "package" | "percentage" | "volume";
1444
+ /**
1445
+ * Specifies the name that will be displayed on an invoice. If no value is set for this field, the name of the actual charge will be used as the default display name.
1446
+ * @example "Setup"
1447
+ */
1448
+ invoice_display_name?: string;
1376
1449
  };
1377
1450
  /** The related billable metric object. */
1378
1451
  billable_metric: {
@@ -1399,40 +1472,9 @@ export interface CustomerChargeUsageObject {
1399
1472
  aggregation_type: "count_agg" | "sum_agg" | "max_agg" | "unique_count_agg";
1400
1473
  };
1401
1474
  /** Array of group object, representing multiple dimensions for a charge item. */
1402
- groups: {
1403
- /**
1404
- * Unique identifier assigned to the group within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the group record within the Lago system.
1405
- * @format uuid
1406
- * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
1407
- */
1408
- lago_id?: string;
1409
- /**
1410
- * The group key, only returned for groups with two dimensions.
1411
- * @example null
1412
- */
1413
- key?: string | null;
1414
- /**
1415
- * The group value.
1416
- * @example "europe"
1417
- */
1418
- value?: string;
1419
- /**
1420
- * The number of units consumed for a specific group related to a charge item.
1421
- * @pattern ^[0-9]+.?[0-9]*$
1422
- * @example "0.9"
1423
- */
1424
- units?: string;
1425
- /**
1426
- * The quantity of usage events that have been recorded for a particular charge during the specified time period. These events may also be referred to as the number of transactions in some contexts.
1427
- * @example 10
1428
- */
1429
- events_count?: number;
1430
- /**
1431
- * The amount in cents, tax excluded, consumed for a specific group related to a charge item.
1432
- * @example 1000
1433
- */
1434
- amount_cents?: number;
1435
- }[];
1475
+ groups: CustomerChargeGroupsUsageObject;
1476
+ /** Array of aggregated fees, grouped by the event properties defined in a `standard` charge model. */
1477
+ grouped_usage?: CustomerChargeGroupedUsageObject;
1436
1478
  }
1437
1479
  export interface CustomerCreateInput {
1438
1480
  customer: {
@@ -1763,42 +1805,7 @@ export interface Event {
1763
1805
  event: EventObject;
1764
1806
  }
1765
1807
  export interface EventBatchInput {
1766
- event: {
1767
- /**
1768
- * This field represents a unique identifier for the event. It is crucial for ensuring idempotency, meaning that each event can be uniquely identified and processed without causing any unintended side effects.
1769
- * @example "transaction_1234567890"
1770
- */
1771
- transaction_id: string;
1772
- /**
1773
- * The customer external unique identifier (provided by your own application). This field is optional if you send the `external_subscription_ids`, targeting a specific subscription.
1774
- * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
1775
- */
1776
- external_customer_id?: string;
1777
- /**
1778
- * Array of unique identifiers of the targeted subscriptions within your application.
1779
- * @example ["sub_1234567890","sub_0987654321"]
1780
- */
1781
- external_subscription_ids: string[];
1782
- /**
1783
- * The code that identifies a targeted billable metric. It is essential that this code matches the `code` property of one of your active billable metrics. If the provided code does not correspond to any active billable metric, it will be ignored during the process.
1784
- * @example "storage"
1785
- */
1786
- code: string;
1787
- /**
1788
- * This field captures the Unix timestamp in seconds indicating the occurrence of the event in Coordinated Universal Time (UTC). If this timestamp is not provided, the API will automatically set it to the time of event reception.
1789
- * @example 1651240791
1790
- */
1791
- timestamp?: number;
1792
- /**
1793
- * This field represents additional properties associated with the event, which are utilized in the calculation of the final fee. This object becomes mandatory when the targeted billable metric employs a `sum_agg`, `max_agg`, or `unique_count_agg` aggregation method. However, when using a simple `count_agg`, this object is not required.
1794
- * @example {"gb":10}
1795
- */
1796
- properties?: {
1797
- /** The `operation_type` field is only necessary when adding or removing a specific unit when the targeted billable metric adopts a `unique_count_agg` aggregation method. In other cases, the `operation_type` field is not required. The valid values for the `operation_type` field are `add` or `remove`, which indicate whether the unit is being added or removed from the unique count aggregation, respectively. */
1798
- operation_type?: "add" | "remove";
1799
- [key: string]: any;
1800
- };
1801
- };
1808
+ events: EventInput[];
1802
1809
  }
1803
1810
  export interface EventEstimateFeesInput {
1804
1811
  event: {
@@ -1961,24 +1968,24 @@ export interface FeeObject {
1961
1968
  */
1962
1969
  lago_true_up_parent_fee_id?: string | null;
1963
1970
  /**
1964
- * Unique identifier assigned to the subscription, created by Lago. This field is specifically displayed when the fee type is charge and the payment for the fee is made in advance (`pay_in_advance` is set to true).
1971
+ * Unique identifier assigned to the subscription, created by Lago. This field is specifically displayed when the fee type is charge or subscription.
1965
1972
  * @format uuid
1966
1973
  * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
1967
1974
  */
1968
1975
  lago_subscription_id?: string | null;
1969
1976
  /**
1970
- * Unique identifier assigned to the customer, created by Lago. This field is specifically displayed when the fee type is charge and the payment for the fee is made in advance (`pay_in_advance` is set to true).
1977
+ * Unique identifier assigned to the customer, created by Lago. This field is specifically displayed when the fee type is charge or subscription.
1971
1978
  * @format uuid
1972
1979
  * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
1973
1980
  */
1974
1981
  lago_customer_id?: string | null;
1975
1982
  /**
1976
- * Unique identifier assigned to the customer in your application. This field is specifically displayed when the fee type is charge and the payment for the fee is made in advance (`pay_in_advance` is set to true).
1983
+ * Unique identifier assigned to the customer in your application. This field is specifically displayed when the fee type is charge or subscription.
1977
1984
  * @example "external_id"
1978
1985
  */
1979
1986
  external_customer_id?: string | null;
1980
1987
  /**
1981
- * Unique identifier assigned to the subscription in your application. This field is specifically displayed when the fee type is charge and the payment for the fee is made in advance (`pay_in_advance` is set to true).
1988
+ * Unique identifier assigned to the subscription in your application. This field is specifically displayed when the fee type is charge or subscription.
1982
1989
  * @example "external_id"
1983
1990
  */
1984
1991
  external_subscription_id?: string | null;
@@ -2082,6 +2089,178 @@ export interface FeeObject {
2082
2089
  * @example "transaction_1234567890"
2083
2090
  */
2084
2091
  event_transaction_id?: string | null;
2092
+ /** List of all unit amount details for calculating the fee. */
2093
+ amount_details?: {
2094
+ /** Graduated ranges, used for a `graduated` charge model. */
2095
+ graduated_ranges?: {
2096
+ /**
2097
+ * Total units received in Lago.
2098
+ * @pattern ^[0-9]+.?[0-9]*$
2099
+ * @example "10.0"
2100
+ */
2101
+ units: string;
2102
+ /**
2103
+ * Lower value of a tier. It is either 0 or the previous range's `to_value + 1`.
2104
+ * @example 0
2105
+ */
2106
+ from_value: number;
2107
+ /**
2108
+ * Highest value of a tier.
2109
+ * - This value is higher than the from_value of the same tier.
2110
+ * - This value is null for the last tier.
2111
+ * @example 10
2112
+ */
2113
+ to_value: number | null;
2114
+ /**
2115
+ * Flat unit amount within a specified tier.
2116
+ * @example "1.0"
2117
+ */
2118
+ flat_unit_amount: string;
2119
+ /**
2120
+ * Amount per unit within a specified tier.
2121
+ * @example "1.0"
2122
+ */
2123
+ per_unit_amount: string;
2124
+ /**
2125
+ * Total amount of received units to be charged within a specified tier.
2126
+ * @example "10.0"
2127
+ */
2128
+ per_unit_total_amount: string;
2129
+ /**
2130
+ * Total amount to be charged for a specific tier, taking into account the flat_unit_amount and the per_unit_total_amount.
2131
+ * @example "11.0"
2132
+ */
2133
+ total_with_flat_amount: string;
2134
+ }[];
2135
+ /** Graduated percentage ranges, used for a `graduated_percentage` charge model. */
2136
+ graduated_percentage_ranges?: {
2137
+ /**
2138
+ * Total units received in Lago.
2139
+ * @pattern ^[0-9]+.?[0-9]*$
2140
+ * @example "10.0"
2141
+ */
2142
+ units: string;
2143
+ /**
2144
+ * Lower value of a tier. It is either 0 or the previous range's `to_value + 1`.
2145
+ * @example 0
2146
+ */
2147
+ from_value: number;
2148
+ /**
2149
+ * Highest value of a tier.
2150
+ * - This value is higher than the from_value of the same tier.
2151
+ * - This value is null for the last tier.
2152
+ * @example 10
2153
+ */
2154
+ to_value: number | null;
2155
+ /**
2156
+ * Flat unit amount within a specified tier.
2157
+ * @example "1.0"
2158
+ */
2159
+ flat_unit_amount: string;
2160
+ /**
2161
+ * Percentage rate applied within a specified tier.
2162
+ * @format ^[0-9]+.?[0-9]*$
2163
+ * @example "1.0"
2164
+ */
2165
+ rate: string;
2166
+ /**
2167
+ * Total amount of received units to be charged within a specified tier.
2168
+ * @example "10.0"
2169
+ */
2170
+ per_unit_total_amount: string;
2171
+ /**
2172
+ * Total amount to be charged for a specific tier, taking into account the flat_unit_amount and the per_unit_total_amount.
2173
+ * @example "11.0"
2174
+ */
2175
+ total_with_flat_amount: string;
2176
+ }[];
2177
+ /**
2178
+ * The quantity of units that are provided free of charge for each billing period in a `package` charge model.
2179
+ * @pattern ^[0-9]+.?[0-9]*$
2180
+ * @example "10.0"
2181
+ */
2182
+ free_units?: string;
2183
+ /**
2184
+ * The quantity of units that are not provided free of charge for each billing period in a `package` charge model.
2185
+ * @pattern ^[0-9]+.?[0-9]*$
2186
+ * @example "40.0"
2187
+ */
2188
+ paid_units?: string;
2189
+ /**
2190
+ * The quantity of units included, defined for Package or Percentage charge model.
2191
+ * @example 1000
2192
+ */
2193
+ per_package_size?: number;
2194
+ /**
2195
+ * Total amount to charge for received paid_units, defined for Package or Percentage charge model.
2196
+ * @pattern ^[0-9]+.?[0-9]*$
2197
+ * @example "0.5"
2198
+ */
2199
+ per_package_unit_amount?: string;
2200
+ /**
2201
+ * The total units received in Lago for the Percentage charge model.
2202
+ * @pattern ^[0-9]+.?[0-9]*$
2203
+ * @example "20.0"
2204
+ */
2205
+ units?: string;
2206
+ /**
2207
+ * Total number of free events allowed for the Percentage charge model.
2208
+ * @example 10
2209
+ */
2210
+ free_events?: number;
2211
+ /**
2212
+ * Percentage rate applied for the Percentage charge model.
2213
+ * @format ^[0-9]+.?[0-9]*$
2214
+ * @example "1.0"
2215
+ */
2216
+ rate?: string;
2217
+ /**
2218
+ * Total amount of received units to be charged for the Percentage charge model.
2219
+ * @example "10.0"
2220
+ */
2221
+ per_unit_total_amount?: string;
2222
+ /**
2223
+ * Total number of paid events for the Percentage charge model.
2224
+ * @example 20
2225
+ */
2226
+ paid_events?: number;
2227
+ /**
2228
+ * Fixed fee unit price per received paid_event for the Percentage charge model.
2229
+ * @example "1.0"
2230
+ */
2231
+ fixed_fee_unit_amount?: string;
2232
+ /**
2233
+ * Total amount to charge for received paid_events for the Percentage charge model.
2234
+ * @example "20.0"
2235
+ */
2236
+ fixed_fee_total_amount?: string;
2237
+ /**
2238
+ * Total adjustment amount linked to minimum and maximum spending per transaction for the Percentage charge model.
2239
+ * @example "20.0"
2240
+ */
2241
+ min_max_adjustment_total_amount?: string;
2242
+ /** Volume ranges, used for a `volume` charge model. */
2243
+ volume_ranges?: {
2244
+ /**
2245
+ * The flat amount for a whole tier, excluding tax, for a `volume` charge model.
2246
+ * @pattern ^[0-9]+.?[0-9]*$
2247
+ * @example "0.5"
2248
+ */
2249
+ per_unit_amount: string;
2250
+ /**
2251
+ * The unit price, excluding tax, for a specific tier of a `volume` charge model.
2252
+ * @pattern ^[0-9]+.?[0-9]*$
2253
+ * @example "10.0"
2254
+ */
2255
+ flat_unit_amount: string;
2256
+ /**
2257
+ * Total amount of received units to be charged.
2258
+ * @pattern ^[0-9]+.?[0-9]*$
2259
+ * @example "10.0"
2260
+ */
2261
+ per_unit_total_amount: string;
2262
+ }[];
2263
+ };
2085
2264
  /** Item attached to the fee */
2086
2265
  item: {
2087
2266
  /**
@@ -2120,6 +2299,8 @@ export interface FeeObject {
2120
2299
  * @example "Subscription"
2121
2300
  */
2122
2301
  item_type: "AddOn" | "BillableMetric" | "Subscription" | "WalletTransaction";
2302
+ /** Key value list of event properties aggregated by the charge model */
2303
+ grouped_by?: Record<string, string>;
2123
2304
  };
2124
2305
  /** List of fee applied taxes */
2125
2306
  applied_taxes?: FeeAppliedTaxObject[];
@@ -2139,6 +2320,23 @@ export interface FeeUpdateInput {
2139
2320
  payment_status: "pending" | "succeeded" | "failed" | "refunded";
2140
2321
  };
2141
2322
  }
2323
+ export interface GrossRevenueObject {
2324
+ /**
2325
+ * Identifies the month to analyze revenue.
2326
+ * @example "2023-11-01T00:00:00.000Z"
2327
+ */
2328
+ month: string;
2329
+ /**
2330
+ * The total amount of revenue for a period, expressed in cents.
2331
+ * @example 50000
2332
+ */
2333
+ amount_cents?: number;
2334
+ /** The currency of revenue analytics. Format must be ISO 4217. */
2335
+ currency?: Currency;
2336
+ }
2337
+ export interface GrossRevenues {
2338
+ gross_revenues: GrossRevenueObject[];
2339
+ }
2142
2340
  export interface GroupObject {
2143
2341
  /**
2144
2342
  * Unique identifier of a specific group associated with the billable metric.
@@ -2176,6 +2374,23 @@ export interface GroupsPaginated {
2176
2374
  groups: GroupObject[];
2177
2375
  meta: PaginationMeta;
2178
2376
  }
2377
+ export interface MrrObject {
2378
+ /**
2379
+ * Identifies the month to analyze MRR.
2380
+ * @example "2023-11-01T00:00:00.000Z"
2381
+ */
2382
+ month: string;
2383
+ /**
2384
+ * The total amount of MRR, expressed in cents.
2385
+ * @example 50000
2386
+ */
2387
+ amount_cents?: number;
2388
+ /** The currency of MRR analytics. Format must be ISO 4217. */
2389
+ currency?: Currency;
2390
+ }
2391
+ export interface Mrrs {
2392
+ mrrs: MrrObject[];
2393
+ }
2179
2394
  export interface Invoice {
2180
2395
  invoice: InvoiceObjectExtended;
2181
2396
  }
@@ -2192,6 +2407,55 @@ export type InvoiceAppliedTaxObject = BaseAppliedTax & {
2192
2407
  */
2193
2408
  fees_amount_cents?: number;
2194
2409
  };
2410
+ export interface InvoiceCollectionObject {
2411
+ /**
2412
+ * Identifies the month to analyze revenue.
2413
+ * @example "2023-11-01T00:00:00.000Z"
2414
+ */
2415
+ month: string;
2416
+ /**
2417
+ * The payment status of the invoices.
2418
+ * @example "succeeded"
2419
+ */
2420
+ payment_status?: "pending" | "succeeded" | "failed";
2421
+ /**
2422
+ * Contains invoices count.
2423
+ * @example 10
2424
+ */
2425
+ invoices_count: number;
2426
+ /**
2427
+ * The total amount of revenue for a period, expressed in cents.
2428
+ * @example 50000
2429
+ */
2430
+ amount_cents: number;
2431
+ /** The currency of revenue analytics. Format must be ISO 4217. */
2432
+ currency?: Currency;
2433
+ }
2434
+ export interface InvoiceCollections {
2435
+ invoice_collections: InvoiceCollectionObject[];
2436
+ }
2437
+ export interface InvoicedUsageObject {
2438
+ /**
2439
+ * Identifies the month to analyze revenue.
2440
+ * @example "2023-11-01T00:00:00.000Z"
2441
+ */
2442
+ month: string;
2443
+ /**
2444
+ * The code of the usage-based billable metrics.
2445
+ * @example "code1"
2446
+ */
2447
+ code?: string;
2448
+ /**
2449
+ * The total amount of revenue for a period, expressed in cents.
2450
+ * @example 50000
2451
+ */
2452
+ amount_cents: number;
2453
+ /** The currency of revenue analytics. Format must be ISO 4217. */
2454
+ currency: Currency;
2455
+ }
2456
+ export interface InvoicedUsages {
2457
+ invoiced_usages: InvoicedUsageObject[];
2458
+ }
2195
2459
  export interface InvoiceMetadataObject {
2196
2460
  /**
2197
2461
  * Unique identifier assigned to the invoice metadata within the Lago application.
@@ -2259,9 +2523,10 @@ export interface InvoiceObject {
2259
2523
  * The status of the invoice. It indicates the current state of the invoice and can have two possible values:
2260
2524
  * - `draft`: the invoice is in the draft state, waiting for the end of the grace period to be finalized. During this period, events can still be ingested and added to the invoice.
2261
2525
  * - `finalized`: the invoice has been issued and finalized. In this state, events cannot be ingested or added to the invoice anymore.
2526
+ * - `voided`: the invoice has been issued and subsequently voided. In this state, events cannot be ingested or added to the invoice anymore.
2262
2527
  * @example "finalized"
2263
2528
  */
2264
- status: "draft" | "finalized";
2529
+ status: "draft" | "finalized" | "voided";
2265
2530
  /**
2266
2531
  * The status of the payment associated with the invoice. It can have one of the following values:
2267
2532
  * - `pending`: the payment is pending, waiting for payment processing in Stripe or when the invoice is emitted but users have not updated the payment status through the endpoint.
@@ -2464,6 +2729,8 @@ export interface OrganizationObject {
2464
2729
  webhook_urls?: string[] | null;
2465
2730
  /** The country of your organization. */
2466
2731
  country?: Country;
2732
+ /** The default currency of an organization. */
2733
+ default_currency?: Currency;
2467
2734
  /**
2468
2735
  * The first line of your organization’s billing address.
2469
2736
  * @example "100 Brex Street"
@@ -2505,6 +2772,21 @@ export interface OrganizationObject {
2505
2772
  * @example null
2506
2773
  */
2507
2774
  legal_number?: string | null;
2775
+ /**
2776
+ * This parameter configures the method of incrementing invoice numbers for your customers.
2777
+ *
2778
+ * - `per_customer`: Invoice numbers are incremented individually for each customer. This means every customer will have their own unique sequence of invoice numbers, separate from other customers. It ensures that each customer's invoice numbers follow a distinct and isolated numbering pattern.
2779
+ * - `per_organization`: Invoice number incrementation is made across your entire organization. Rather than individual sequences for each customer, all invoices within the organization follow a single, unified numbering system. This creates a continuous and organization-wide sequence for all invoice numbers. Invoices are incremented per month (dynamic value used is YYYYMM), and invoice numbers are reset at the end of each month.
2780
+ *
2781
+ * The default value for `document_numbering` is set to `per_customer`, meaning that, unless changed, invoice numbers will increment uniquely for each customer.
2782
+ * @example "per_customer"
2783
+ */
2784
+ document_numbering: "per_customer" | "per_organization";
2785
+ /**
2786
+ * Sets the prefix for invoices and credit notes. Default is the first three letters of your organization name plus the last four digits of your organization ID. Customizable within 1-10 characters, and automatically capitalized by Lago.
2787
+ * @example "ORG-1234"
2788
+ */
2789
+ document_number_prefix: string;
2508
2790
  /**
2509
2791
  * The net payment term, expressed in days, specifies the duration within which a customer is expected to remit payment after the invoice is finalized.
2510
2792
  * @example 30
@@ -2531,6 +2813,8 @@ export interface OrganizationUpdateInput {
2531
2813
  webhook_url?: string | null;
2532
2814
  /** The country of your organization. */
2533
2815
  country?: Country;
2816
+ /** The default currency of an organization. */
2817
+ default_currency?: Currency;
2534
2818
  /**
2535
2819
  * The first line of your organization’s billing address.
2536
2820
  * @example "100 Brex Street"
@@ -2572,6 +2856,21 @@ export interface OrganizationUpdateInput {
2572
2856
  * @example null
2573
2857
  */
2574
2858
  legal_number?: string | null;
2859
+ /**
2860
+ * This parameter configures the method of incrementing invoice numbers for your customers.
2861
+ *
2862
+ * - `per_customer`: Invoice numbers are incremented individually for each customer. This means every customer will have their own unique sequence of invoice numbers, separate from other customers. It ensures that each customer's invoice numbers follow a distinct and isolated numbering pattern.
2863
+ * - `per_organization`: Invoice number incrementation is made across your entire organization. Rather than individual sequences for each customer, all invoices within the organization follow a single, unified numbering system. This creates a continuous and organization-wide sequence for all invoice numbers. Invoices are incremented per month (dynamic value used is YYYYMM), and invoice numbers are reset at the end of each month.
2864
+ *
2865
+ * The default value for `document_numbering` is set to `per_customer`, meaning that, unless changed, invoice numbers will increment uniquely for each customer.
2866
+ * @example "per_customer"
2867
+ */
2868
+ document_numbering?: "per_customer" | "per_organization";
2869
+ /**
2870
+ * Sets the prefix for invoices and credit notes. Default is the first three letters of your organization name plus the last four digits of your organization ID. Customizable within 1-10 characters, and automatically capitalized by Lago.
2871
+ * @example "ORG-1234"
2872
+ */
2873
+ document_number_prefix?: string;
2575
2874
  /**
2576
2875
  * The net payment term, expressed in days, specifies the duration within which a customer is expected to remit payment after the invoice is finalized.
2577
2876
  * @example 30
@@ -2784,6 +3083,12 @@ export interface PlanOverridesObject {
2784
3083
  * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
2785
3084
  */
2786
3085
  id?: string;
3086
+ /**
3087
+ * Unique identifier of the billable metric created by Lago.
3088
+ * @format uuid
3089
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
3090
+ */
3091
+ billable_metric_id?: string;
2787
3092
  /**
2788
3093
  * Specifies the name that will be displayed on an invoice. If no value is set for this field, the name of the actual charge will be used as the default display name.
2789
3094
  * @example "Setup"
@@ -3067,6 +3372,11 @@ export interface SubscriptionCreateInput {
3067
3372
  };
3068
3373
  }
3069
3374
  export interface SubscriptionUpdateInput {
3375
+ /**
3376
+ * If the field is not defined and multiple `active` and `pending` subscriptions exists, Lago will update the `active` subscription. However, if you wish to update a `pending` subscription, please ensure that you include the `status` attribute with the `pending` value in your request body.
3377
+ * @example "active"
3378
+ */
3379
+ status?: "active" | "pending";
3070
3380
  subscription: {
3071
3381
  /**
3072
3382
  * The display name of the subscription on an invoice. This field allows for customization of the subscription's name for billing purposes, especially useful when a single customer has multiple subscriptions using the same plan.
@@ -3184,8 +3494,8 @@ export interface SubscriptionObject {
3184
3494
  next_plan_code?: string | null;
3185
3495
  /**
3186
3496
  * The date when the plan will be downgraded, represented in ISO 8601 date format.
3187
- * @format date-time
3188
- * @example null
3497
+ * @format date
3498
+ * @example "2022-04-30"
3189
3499
  */
3190
3500
  downgrade_plan_date?: string | null;
3191
3501
  }
@@ -3339,6 +3649,25 @@ export interface WalletCreateInput {
3339
3649
  * @example "2022-07-07T23:59:59Z"
3340
3650
  */
3341
3651
  expiration_at?: string | null;
3652
+ /** List of recurring transaction rules. Currently, we only allow one recurring rule per wallet. */
3653
+ recurring_transaction_rules?: {
3654
+ /**
3655
+ * The rule type. Possible values are `interval` or `threshold`.
3656
+ * @example "interval"
3657
+ */
3658
+ rule_type: "interval" | "threshold";
3659
+ /**
3660
+ * The interval used for recurring top-up. It represents the frequency at which automatic top-up occurs. The interval can be one of the following values: `weekly`, `monthly`, `quarterly` or `yearly`. Required only when rule type is `interval`.
3661
+ * @example "monthly"
3662
+ */
3663
+ interval?: "weekly" | "monthly" | "quarterly" | "yearly";
3664
+ /**
3665
+ * The threshold for recurring top-ups is the value at which an automatic top-up is triggered. For example, if this threshold is set at 10 credits, an automatic top-up will occur whenever the wallet balance falls to or below 10 credits. Required only when rule type is set to `threshold`.
3666
+ * @pattern ^[0-9]+.?[0-9]*$
3667
+ * @example "20.0"
3668
+ */
3669
+ threshold_credits?: string;
3670
+ }[];
3342
3671
  };
3343
3672
  }
3344
3673
  export interface WalletObject {
@@ -3424,6 +3753,71 @@ export interface WalletObject {
3424
3753
  * @example "2022-09-14T16:35:31Z"
3425
3754
  */
3426
3755
  terminated_at?: string | null;
3756
+ /** List of recurring transaction rules. Currently, we only allow one recurring rule per wallet. */
3757
+ recurring_transaction_rules?: {
3758
+ /**
3759
+ * A unique identifier for the recurring transaction rule in the Lago application. Can be used to update a recurring transaction rule.
3760
+ * @format uuid
3761
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
3762
+ */
3763
+ lago_id: string;
3764
+ /**
3765
+ * The rule type. Possible values are `interval` or `threshold`.
3766
+ * @example "interval"
3767
+ */
3768
+ rule_type: "interval" | "threshold";
3769
+ /**
3770
+ * The interval used for recurring top-up. It represents the frequency at which automatic top-up occurs. The interval can be one of the following values: `weekly`, `monthly`, `quarterly` or `yearly`. Required only if rule type is set to `interval`.
3771
+ * @example "monthly"
3772
+ */
3773
+ interval?: "weekly" | "monthly" | "quarterly" | "yearly";
3774
+ /**
3775
+ * The threshold for recurring top-ups is the value at which an automatic top-up is triggered. For example, if this threshold is set at 10 credits, an automatic top-up will occur whenever the wallet balance falls to or below 10 credits. Required only when rule type is set to `threshold`.
3776
+ * @pattern ^[0-9]+.?[0-9]*$
3777
+ * @example "20.0"
3778
+ */
3779
+ threshold_credits?: string;
3780
+ /**
3781
+ * The number of paid credits. Required only if there is no granted credits.
3782
+ * @pattern ^[0-9]+.?[0-9]*$
3783
+ * @example "20.0"
3784
+ */
3785
+ paid_credits: string;
3786
+ /**
3787
+ * The number of free granted credits. Required only if there is no paid credits.
3788
+ * @pattern ^[0-9]+.?[0-9]*$
3789
+ * @example "10.0"
3790
+ */
3791
+ granted_credits: string;
3792
+ /**
3793
+ * The date of the metadata object creation, represented in ISO 8601 datetime format and expressed in Coordinated Universal Time (UTC). The creation_date provides a standardized and internationally recognized timestamp for when the metadata object was created
3794
+ * @format date-time
3795
+ * @example "2022-04-29T08:59:51Z"
3796
+ */
3797
+ created_at: string;
3798
+ }[];
3799
+ /**
3800
+ * The wallet ongoing balance expressed in cents.
3801
+ * @example 800
3802
+ */
3803
+ ongoing_balance_cents: number;
3804
+ /**
3805
+ * The wallet ongoing usage balance expressed in cents.
3806
+ * @example 200
3807
+ */
3808
+ ongoing_usage_balance_cents: number;
3809
+ /**
3810
+ * The wallet ongoing balance expressed in credits.
3811
+ * @pattern ^[0-9]+.?[0-9]*$
3812
+ * @example "8.0"
3813
+ */
3814
+ credits_ongoing_balance: string;
3815
+ /**
3816
+ * The wallet ongoing usage balance expressed in credits.
3817
+ * @pattern ^[0-9]+.?[0-9]*$
3818
+ * @example "2.0"
3819
+ */
3820
+ credits_ongoing_usage_balance: string;
3427
3821
  }
3428
3822
  export interface WalletsPaginated {
3429
3823
  wallets: WalletObject[];
@@ -3518,6 +3912,43 @@ export interface WalletUpdateInput {
3518
3912
  * @example "2022-07-07T23:59:59Z"
3519
3913
  */
3520
3914
  expiration_at?: string | null;
3915
+ /** List of recurring transaction rules. Currently, we only allow one recurring rule per wallet. */
3916
+ recurring_transaction_rules?: {
3917
+ /**
3918
+ * A unique identifier for the recurring transaction rule in the Lago application. Can be used to update a recurring transaction rule.
3919
+ * @format uuid
3920
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
3921
+ */
3922
+ lago_id?: string;
3923
+ /**
3924
+ * The rule type. Possible values are `interval` or `threshold`.
3925
+ * @example "interval"
3926
+ */
3927
+ rule_type?: "interval" | "threshold";
3928
+ /**
3929
+ * The interval used for recurring top-up. It represents the frequency at which automatic top-up occurs. The interval can be one of the following values: `weekly`, `monthly`, `quarterly` or `yearly`. Required only when rule type is set to `interval`.
3930
+ * @example "monthly"
3931
+ */
3932
+ interval?: "weekly" | "monthly" | "quarterly" | "yearly";
3933
+ /**
3934
+ * The threshold for recurring top-ups is the value at which an automatic top-up is triggered. For example, if this threshold is set at 10 credits, an automatic top-up will occur whenever the wallet balance falls to or below 10 credits. Required only when rule type is set to `threshold`.
3935
+ * @pattern ^[0-9]+.?[0-9]*$
3936
+ * @example "20.0"
3937
+ */
3938
+ threshold_credits?: string;
3939
+ /**
3940
+ * The number of paid credits. Required only if there is no granted credits.
3941
+ * @pattern ^[0-9]+.?[0-9]*$
3942
+ * @example "20.0"
3943
+ */
3944
+ paid_credits?: string;
3945
+ /**
3946
+ * The number of free granted credits. Required only if there is no paid credits.
3947
+ * @pattern ^[0-9]+.?[0-9]*$
3948
+ * @example "10.0"
3949
+ */
3950
+ granted_credits?: string;
3951
+ }[];
3521
3952
  };
3522
3953
  }
3523
3954
  export interface WebhookEndpoint {
@@ -3645,7 +4076,7 @@ export declare class HttpClient<SecurityDataType = unknown> {
3645
4076
  }
3646
4077
  /**
3647
4078
  * @title Lago API documentation
3648
- * @version 0.49.0-beta
4079
+ * @version 0.56.0-beta
3649
4080
  * @license AGPLv3
3650
4081
  * @baseUrl https://api.getlago.com/api/v1
3651
4082
  * @externalDocs https://github.com/getlago
@@ -3717,6 +4148,77 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
3717
4148
  */
3718
4149
  destroyAddOn: (code: string, params?: RequestParams) => Promise<HttpResponse<AddOn, ApiErrorUnauthorized | ApiErrorNotFound>>;
3719
4150
  };
4151
+ analytics: {
4152
+ /**
4153
+ * @description Gross revenue is the sum of monthly `finalized` invoice payments and fees paid in advance that are not invoiceable. This total is calculated after deducting taxes and discounts.
4154
+ *
4155
+ * @tags analytics
4156
+ * @name FindAllGrossRevenues
4157
+ * @summary List gross revenue
4158
+ * @request GET:/analytics/gross_revenue
4159
+ * @secure
4160
+ */
4161
+ findAllGrossRevenues: (query?: {
4162
+ /** Currency of revenue analytics. Format must be ISO 4217. */
4163
+ currency?: Currency;
4164
+ /**
4165
+ * The customer external unique identifier (provided by your own application). Use it to filter revenue analytics at the customer level.
4166
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
4167
+ */
4168
+ external_customer_id?: string;
4169
+ }, params?: RequestParams) => Promise<HttpResponse<GrossRevenues, ApiErrorUnauthorized>>;
4170
+ /**
4171
+ * @description Represents a monthly aggregation, detailing both the total count and the cumulative amount of invoices that have been marked as `finalized`. This report sorts invoices categorically based on their `payment_status`.
4172
+ *
4173
+ * @tags analytics
4174
+ * @name FindAllInvoiceCollections
4175
+ * @summary List of finalized invoices
4176
+ * @request GET:/analytics/invoice_collection
4177
+ * @secure
4178
+ */
4179
+ findAllInvoiceCollections: (query?: {
4180
+ /** The currency of revenue analytics. Format must be ISO 4217. */
4181
+ currency?: Currency;
4182
+ }, params?: RequestParams) => Promise<HttpResponse<InvoiceCollections, ApiErrorUnauthorized>>;
4183
+ /**
4184
+ * @description Reports a monthly analysis focused on the revenue generated from all usage-based fees. It exclusively accounts for revenue that has been formally invoiced. Importantly, this report does not include revenue related to the usage in the current billing period, limiting its scope to previously invoiced amounts.
4185
+ *
4186
+ * @tags analytics
4187
+ * @name FindAllInvoicedUsages
4188
+ * @summary List usage revenue
4189
+ * @request GET:/analytics/invoiced_usage
4190
+ * @secure
4191
+ */
4192
+ findAllInvoicedUsages: (query?: {
4193
+ /** The currency of invoiced usage analytics. Format must be ISO 4217. */
4194
+ currency?: Currency;
4195
+ }, params?: RequestParams) => Promise<HttpResponse<InvoicedUsages, ApiErrorUnauthorized>>;
4196
+ /**
4197
+ * @description This endpoint is used to list MRR.
4198
+ *
4199
+ * @tags analytics
4200
+ * @name FindAllMrrs
4201
+ * @summary List MRR
4202
+ * @request GET:/analytics/mrr
4203
+ * @secure
4204
+ */
4205
+ findAllMrrs: (query?: {
4206
+ /**
4207
+ * Quantifies the revenue generated from `subscription` fees on a monthly basis. This figure is calculated post-application of applicable taxes and deduction of any applicable discounts. The method of calculation varies based on the subscription billing cycle:
4208
+ *
4209
+ * - Revenue from `monthly` subscription invoices is included in the MRR for the month in which the invoice is issued.
4210
+ * - Revenue from `quarterly` subscription invoices is distributed evenly over three months. This distribution applies to fees paid in advance (allocated to the next remaining months depending on calendar or anniversary billing) as well as to fees paid in arrears (allocated to the preceding months depending on calendar or anniversary billing).
4211
+ * - Revenue from `yearly` subscription invoices is distributed evenly over twelve months. This allocation is applicable for fees paid in advance (spread over the next remaining months depending on calendar or anniversary billing) and for fees paid in arrears (spread over the previous months depending on calendar or anniversary billing).
4212
+ * - Revenue from `weekly` subscription invoices, the total revenue from all invoices issued within a month is summed up. This total is then divided by the number of invoices issued during that month, and the result is multiplied by 4.33, representing the average number of weeks in a month.
4213
+ */
4214
+ currency?: Currency;
4215
+ /**
4216
+ * Show data only for given number of months.
4217
+ * @example 12
4218
+ */
4219
+ months?: number;
4220
+ }, params?: RequestParams) => Promise<HttpResponse<Mrrs, ApiErrorUnauthorized>>;
4221
+ };
3720
4222
  appliedCoupons: {
3721
4223
  /**
3722
4224
  * @description This endpoint is used to apply a specific coupon to a customer, before or during a subscription.
@@ -4127,6 +4629,39 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
4127
4629
  */
4128
4630
  periods_count?: number;
4129
4631
  }, params?: RequestParams) => Promise<HttpResponse<CustomerPastUsage, ApiErrorUnauthorized | ApiErrorUnprocessableEntity | ApiErrorNotFound>>;
4632
+ /**
4633
+ * @description This endpoint regenerates the Payment Provider Checkout URL of a Customer.
4634
+ *
4635
+ * @tags customers
4636
+ * @name GenerateCustomerCheckoutUrl
4637
+ * @summary Generate a Customer Payment Provider Checkout URL
4638
+ * @request POST:/customers/{external_customer_id}/checkout_url
4639
+ * @secure
4640
+ */
4641
+ generateCustomerCheckoutUrl: (externalCustomerId: string, params?: RequestParams) => Promise<HttpResponse<{
4642
+ customer?: {
4643
+ /**
4644
+ * Unique identifier assigned to the customer within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the customer's record within the Lago system
4645
+ * @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
4646
+ */
4647
+ lago_customer_id?: string | undefined;
4648
+ /**
4649
+ * The customer external unique identifier (provided by your own application)
4650
+ * @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
4651
+ */
4652
+ external_customer_id?: string | undefined;
4653
+ /**
4654
+ * The Payment Provider name linked to the Customer.
4655
+ * @example "stripe"
4656
+ */
4657
+ payment_provider?: string | undefined;
4658
+ /**
4659
+ * The new generated Payment Provider Checkout URL for the Customer.
4660
+ * @example "https://foo.bar"
4661
+ */
4662
+ checkout_url?: string | undefined;
4663
+ } | undefined;
4664
+ }, ApiErrorUnauthorized | ApiErrorUnprocessableEntity | ApiErrorNotFound>>;
4130
4665
  };
4131
4666
  events: {
4132
4667
  /**
@@ -4140,13 +4675,12 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
4140
4675
  */
4141
4676
  createEvent: (data: EventInput, params?: RequestParams) => Promise<HttpResponse<Event, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
4142
4677
  /**
4143
- * @description This endpoint is used for transmitting a batch of usage measurement events to multiple subscriptions for a single customer.
4678
+ * @description This endpoint is used to send a batch of usage records.
4144
4679
  *
4145
4680
  * @tags events
4146
4681
  * @name CreateBatchEvents
4147
4682
  * @summary Batch multiple events
4148
4683
  * @request POST:/events/batch
4149
- * @deprecated
4150
4684
  * @secure
4151
4685
  */
4152
4686
  createBatchEvents: (data: EventBatchInput, params?: RequestParams) => Promise<HttpResponse<void, ApiErrorBadRequest | ApiErrorUnauthorized | ApiErrorUnprocessableEntity>>;
@@ -4402,6 +4936,16 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
4402
4936
  * @secure
4403
4937
  */
4404
4938
  retryPayment: (lagoId: string, params?: RequestParams) => Promise<HttpResponse<void, ApiErrorUnauthorized | ApiErrorNotAllowed | ApiErrorNotFound>>;
4939
+ /**
4940
+ * @description This endpoint is used for voiding an invoice. You can void an invoice only when it's in a `finalized` status, and the payment status is not `succeeded`.
4941
+ *
4942
+ * @tags invoices
4943
+ * @name VoidInvoice
4944
+ * @summary Void an invoice
4945
+ * @request POST:/invoices/{lago_id}/void
4946
+ * @secure
4947
+ */
4948
+ voidInvoice: (lagoId: string, params?: RequestParams) => Promise<HttpResponse<Invoice, ApiErrorUnauthorized | ApiErrorNotFound>>;
4405
4949
  };
4406
4950
  organizations: {
4407
4951
  /**