lago-javascript-client
Version:
Lago JavaScript API Client
1,255 lines • 318 kB
TypeScript
export interface AddOnBaseInput {
/**
* The name of the add-on.
* @example "Setup Fee"
*/
name?: string;
/**
* 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.
* @example "Setup Fee (SF1)"
*/
invoice_display_name?: string;
/**
* Unique code used to identify the add-on.
* @example "setup_fee"
*/
code?: string;
/**
* The cost of the add-on in cents, excluding any applicable taxes, that is billed to a customer. By creating a one-off invoice, you will be able to override this value.
* @example 50000
*/
amount_cents?: number;
/**
* The currency of the add-on.
* @example "USD"
*/
amount_currency?: Currency;
/**
* The description of the add-on.
* @example "Implementation fee for new customers."
*/
description?: string | null;
/**
* List of unique code used to identify the taxes.
* @example ["french_standard_vat"]
*/
tax_codes?: string[];
}
export interface AddOnCreateInput {
add_on: AddOnBaseInput;
}
export interface AddOnObject {
/**
* Unique identifier of the add-on, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* The name of the add-on.
* @example "Setup Fee"
*/
name: string;
/**
* 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.
* @example "Setup Fee (SF1)"
*/
invoice_display_name?: string;
/**
* Unique code used to identify the add-on.
* @example "setup_fee"
*/
code: string;
/**
* The cost of the add-on in cents, excluding any applicable taxes, that is billed to a customer. By creating a one-off invoice, you will be able to override this value.
* @example 50000
*/
amount_cents: number;
/**
* The currency of the add-on.
* @example "USD"
*/
amount_currency: Currency;
/**
* The description of the add-on.
* @example "Implementation fee for new customers."
*/
description?: string | null;
/**
* The date and time when the add-on was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the add-on was initially created.
* @format date-time
* @example "2022-04-29T08:59:51Z"
*/
created_at: string;
/** All taxes applied to the add-on. */
taxes?: TaxObject[];
}
export interface AddOn {
add_on: AddOnObject;
}
export interface AddOnsPaginated {
add_ons: AddOnObject[];
meta: PaginationMeta;
}
export interface AddOnUpdateInput {
add_on: AddOnBaseInput;
}
export interface ApiErrorBadRequest {
/**
* @format int32
* @example 400
*/
status: number;
/** @example "Bad request" */
error: string;
}
export interface ApiErrorForbidden {
/**
* @format int32
* @example 403
*/
status: number;
/** @example "Forbidden" */
error: string;
/** @example "feature_unavailable" */
code: string;
}
export interface ApiErrorUnauthorized {
/**
* @format int32
* @example 401
*/
status: number;
/** @example "Unauthorized" */
error: string;
}
export interface ApiErrorUnprocessableEntity {
/**
* @format int32
* @example 422
*/
status: number;
/** @example "Unprocessable entity" */
error: string;
/** @example "validation_errors" */
code: string;
error_details: object;
}
export interface ApiErrorNotAllowed {
/**
* @format int32
* @example 405
*/
status: number;
/** @example "Method Not Allowed" */
error: string;
/** @example "not_allowed" */
code: string;
}
export interface ApiErrorNotFound {
/**
* @format int32
* @example 404
*/
status: number;
/** @example "Not Found" */
error: string;
/** @example "object_not_found" */
code: string;
}
export interface AppliedCoupon {
applied_coupon: AppliedCouponObject;
}
export interface AppliedCouponInput {
applied_coupon: {
/**
* The customer external unique identifier (provided by your own application)
* @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
*/
external_customer_id: string;
/**
* Unique code used to identify the coupon.
* @example "startup_deal"
*/
coupon_code: string;
/**
* The type of frequency for the coupon. It can have three possible values: `once`, `recurring` or `forever`.
*
* - If set to `once`, the coupon is applicable only for a single use.
* - If set to `recurring`, the coupon can be used multiple times for recurring billing periods.
* - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
* @example "recurring"
*/
frequency?: "once" | "recurring" | "forever" | null;
/**
* Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
* @example 3
*/
frequency_duration?: number | null;
/**
* The amount of the coupon in cents. This field is required only for coupon with `fixed_amount` type.
* @example 2000
*/
amount_cents?: number | null;
/**
* The currency of the coupon. This field is required only for coupon with `fixed_amount` type.
* @example "EUR"
*/
amount_currency?: Currency | null;
/**
* The percentage rate of the coupon. This field is required only for coupons with a `percentage` coupon type.
* @pattern ^[0-9]+.?[0-9]*$
* @example null
*/
percentage_rate?: string | null;
};
}
export interface AppliedCouponObject {
/**
* Unique identifier of the applied coupon, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* Unique identifier of the coupon, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_coupon_id: string;
/**
* Unique code used to identify the coupon.
* @example "startup_deal"
*/
coupon_code: string;
/**
* The name of the coupon.
* @example "Startup Deal"
*/
coupon_name: string;
/**
* Unique identifier of the customer, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_customer_id: string;
/**
* The customer external unique identifier (provided by your own application)
* @example "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"
*/
external_customer_id: string;
/**
* The status of the coupon. Can be either `active` or `terminated`.
* @example "active"
*/
status: "active" | "terminated";
/**
* The amount of the coupon in cents. This field is required only for coupon with `fixed_amount` type.
* @example 2000
*/
amount_cents?: number | null;
/**
* The remaining amount in cents for a `fixed_amount` coupon with a frequency set to `once`. This field indicates the remaining balance or value that can still be utilized from the coupon.
* @example 50
*/
amount_cents_remaining?: number | null;
/**
* The currency of the coupon. This field is required only for coupon with `fixed_amount` type.
* @example "EUR"
*/
amount_currency?: Currency | null;
/**
* The percentage rate of the coupon. This field is required only for coupons with a `percentage` coupon type.
* @pattern ^[0-9]+.?[0-9]*$
* @example null
*/
percentage_rate?: string | null;
/**
* The type of frequency for the coupon. It can have three possible values: `once`, `recurring` or `forever`.
*
* - If set to `once`, the coupon is applicable only for a single use.
* - If set to `recurring`, the coupon can be used multiple times for recurring billing periods.
* - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
* @example "recurring"
*/
frequency: "once" | "recurring" | "forever";
/**
* Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
* @example 3
*/
frequency_duration?: number | null;
/**
* The remaining number of billing periods to which the coupon is applicable. This field determines the remaining usage or availability of the coupon based on the remaining billing periods.
* @example 1
*/
frequency_duration_remaining?: number | null;
/**
* The date and time after which the coupon will stop applying to customer's invoices. Once the expiration date is reached, the coupon will no longer be applicable, and any further invoices generated for the customer will not include the coupon discount.
* @format date-time
* @example "2022-04-29T08:59:51Z"
*/
expiration_at?: string | null;
/**
* The date and time when the coupon was assigned to a customer. It is expressed in UTC format according to the ISO 8601 datetime standard.
* @format date-time
* @example "2022-04-29T08:59:51Z"
*/
created_at: string;
/**
* This field indicates the specific moment when the coupon amount is fully utilized or when the coupon is removed from the customer's coupon list. It is expressed in UTC format according to the ISO 8601 datetime standard.
* @format date-time
* @example "2022-04-29T08:59:51Z"
*/
terminated_at?: string | null;
}
export type AppliedCouponObjectExtended = AppliedCouponObject & {
credits: CreditObject[];
};
export interface AppliedCouponsPaginated {
applied_coupons: AppliedCouponObjectExtended[];
meta: PaginationMeta;
}
export interface AppliedUsageThresholdObject {
/**
* The amount of usage in cents that has been accumulated over the lifetime of the subscription.
* @example 2000
*/
lifetime_usage_amount_cents: number;
/**
* The date and time when the lifetime usage was computed. It is expressed in UTC format according to the ISO 8601 datetime standard.
* @format date-time
*/
created_at: string;
usage_threshold: UsageThresholdObject;
}
export interface BaseAppliedTax {
/**
* Unique identifier of the applied tax, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id?: string;
/**
* Unique identifier of the tax, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_tax_id?: string;
/**
* Name of the tax.
* @example "TVA"
*/
tax_name?: string;
/**
* Unique code used to identify the tax associated with the API request.
* @example "french_standard_vat"
*/
tax_code?: string;
/**
* The percentage rate of the tax
* @example 20
*/
tax_rate?: number;
/**
* Internal description of the taxe
* @example "French standard VAT"
*/
tax_description?: string;
/**
* Amount of the tax
* @example 2000
*/
amount_cents?: number;
/**
* Currency of the tax
* @example "USD"
*/
amount_currency?: Currency;
/**
* The date and time when the applied tax was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the applied tax was initially created.
* @format date-time
* @example "2022-09-14T16:35:31Z"
*/
created_at?: string;
}
export interface BillableMetric {
billable_metric: BillableMetricObject;
}
export interface BillableMetricObject {
/**
* Unique identifier of the billable metric created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* Name of the billable metric.
* @example "Storage"
*/
name: string;
/**
* Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
* @example "storage"
*/
code: string;
/**
* Internal description of the billable metric.
* @example "GB of storage used in my application"
*/
description?: string | null;
/**
* Defines if the billable metric is persisted billing period over billing period.
*
* - If set to `true`: the accumulated number of units calculated from the previous billing period is persisted to the next billing period.
* - If set to `false`: the accumulated number of units is reset to 0 at the end of the billing period.
* - If not defined in the request, default value is `false`.
* @example false
*/
recurring: boolean;
/**
* Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
* @example "round"
*/
rounding_function?: "ceil" | "floor" | "round" | null;
/**
* Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
* @example 2
*/
rounding_precision?: number | null;
/**
* Creation date of the billable metric.
* @format date-time
* @example "2022-09-14T16:35:31Z"
*/
created_at: string;
/**
* Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
* @example "round((ended_at - started_at) * units)"
*/
expression?: string;
/**
* Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
* @example "gb"
*/
field_name?: string | null;
/**
* Aggregation method used to compute usage for this billable metric.
* @example "sum_agg"
*/
aggregation_type: "count_agg" | "sum_agg" | "max_agg" | "unique_count_agg" | "weighted_sum_agg" | "latest_agg";
/**
* Parameter exclusively utilized in conjunction with the `weighted_sum` aggregation type. It serves to adjust the aggregation result by assigning weights and proration to the result based on time intervals. When this field is not provided, the default time interval is assumed to be in `seconds`.
* @example "seconds"
*/
weighted_interval?: "seconds" | null;
filters?: BillableMetricFilterObject[];
}
export interface BillableMetricBaseInput {
/**
* Name of the billable metric.
* @example "Storage"
*/
name?: string;
/**
* Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
* @example "storage"
*/
code?: string;
/**
* Internal description of the billable metric.
* @example "GB of storage used in my application"
*/
description?: string | null;
/**
* Defines if the billable metric is persisted billing period over billing period.
*
* - If set to `true`: the accumulated number of units calculated from the previous billing period is persisted to the next billing period.
* - If set to `false`: the accumulated number of units is reset to 0 at the end of the billing period.
* - If not defined in the request, default value is `false`.
* @example false
*/
recurring?: boolean;
/**
* Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
* Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
* Round is accepting an optional second parameter to specify the number of decimal.
* @example "round((ended_at - started_at) * units)"
*/
expression?: string | null;
/**
* Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are `round`, `ceil` and `floor`.
* @example "round"
*/
rounding_function?: "ceil" | "floor" | "round" | null;
/**
* Specifies the number of decimal places to which the `rounding_function` will be rounded. It can be a positive or negative value.
* @example 2
*/
rounding_precision?: number | null;
/**
* Property of the billable metric used for aggregating usage data. This field is not required for `count_agg`.
* @example "gb"
*/
field_name?: string | null;
/**
* Aggregation method used to compute usage for this billable metric.
* @example "sum_agg"
*/
aggregation_type?: "count_agg" | "sum_agg" | "max_agg" | "unique_count_agg" | "weighted_sum_agg" | "latest_agg";
/**
* Parameter exclusively utilized in conjunction with the `weighted_sum` aggregation type. It serves to adjust the aggregation result by assigning weights and proration to the result based on time intervals. When this field is not provided, the default time interval is assumed to be in `seconds`.
* @example "seconds"
*/
weighted_interval?: "seconds" | null;
filters?: BillableMetricFilterInput[];
}
export interface BillableMetricCreateInput {
billable_metric: BillableMetricBaseInput;
}
export interface BillableMetricEvaluateExpressionInput {
/**
* Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
* Accepted function are `ceil`, `concat` and `round` as well as `+`, `-`, `\` and `*` operations.
* Round is accepting an optional second parameter to specify the number of decimal.
* @example "round((ended_at - started_at) * units)"
*/
expression: string;
event: {
/**
* The code that identifies a targeted billable metric.
* @example "storage"
*/
code: string;
/**
* 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.
* @example "1651240791"
*/
timestamp?: number | string;
/**
* This field represents additional properties associated with the event. They can be used when evaluating the expression.
* @example {"gb":10}
*/
properties: Record<string, string | number>;
};
}
export interface BillableMetricEvaluateExpressionResult {
expression_result: {
/**
* Result of evaluating the expression
* @example 1
*/
value: string | number;
};
}
/** Values used to apply differentiated pricing based on additional event properties. */
export interface BillableMetricFilterInput {
/**
* Filter key to add to the event properties payload
* @example "region"
*/
key: string;
/** List of possible filter values */
values: string[];
}
/** Values used to apply differentiated pricing based on additional event properties. */
export interface BillableMetricFilterObject {
/**
* Filter key to add to the event properties payload
* @example "region"
*/
key: string;
/** List of possible filter values */
values: string[];
}
export interface BillableMetricUpdateInput {
billable_metric: BillableMetricBaseInput;
}
export interface BillableMetricsPaginated {
billable_metrics: BillableMetricObject[];
meta: PaginationMeta;
}
/** Values used to apply differentiated pricing based on additional event properties. */
export interface ChargeFilterInput {
/**
* Specifies the name that will be displayed on an invoice. If no value is set for this field, the values of the filter will be used as the default display name.
* @example "AWS"
*/
invoice_display_name?: string | null;
/** List of all thresholds utilized for calculating the charge. */
properties?: ChargeProperties;
/**
* List of possible filter values. The key and values must match one of the billable metric filters.
* @example {"region":["us-east-1"]}
*/
values?: Record<string, string[]>;
}
/** Values used to apply differentiated pricing based on additional event properties. */
export interface ChargeFilterObject {
/**
* Specifies the name that will be displayed on an invoice. If no value is set for this field, the values of the filter will be used as the default display name.
* @example "AWS"
*/
invoice_display_name: string | null;
/** List of all thresholds utilized for calculating the charge. */
properties: ChargeProperties;
/**
* List of possible filter values. The key and values must match one of the billable metric filters.
* @example {"region":["us-east-1"]}
*/
values: Record<string, string[]>;
}
export interface ChargeObject {
/**
* Unique identifier of charge, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* Unique identifier of the billable metric created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_billable_metric_id: string;
/**
* Unique code identifying a billable metric.
* @example "requests"
*/
billable_metric_code: string;
/**
* 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.
* @example "Setup"
*/
invoice_display_name?: string;
/**
* The date and time when the charge was created. It is expressed in UTC format according to the ISO 8601 datetime standard.
* @format date-time
* @example "2022-09-14T16:35:31Z"
*/
created_at: string;
/** Specifies the pricing model used for the calculation of the final fee. It can be `standard`, `graduated`, `graduated_percentage`, `package`, `percentage`, `volume` or `dynamic`. */
charge_model: "standard" | "graduated" | "graduated_percentage" | "package" | "percentage" | "volume" | "dynamic";
/**
* This field determines the billing timing for this specific usage-based charge. When set to `true`, the charge is due and invoiced immediately. Conversely, when set to `false`, the charge is due and invoiced at the end of each billing period.
* @example true
*/
pay_in_advance?: boolean;
/**
* This field specifies whether the charge should be included in a proper invoice. If set to `false`, no invoice will be issued for this charge. You can only set it to `false` when `pay_in_advance` is `true`.
* @example true
*/
invoiceable?: boolean;
/**
* This setting can only be configured if `pay_in_advance` is `true` and `invoiceable` is `false`.
* This field determines whether and when the charge fee should be included in
* the invoice. If `null`, no invoice will be issued for this charge fee.
* If `invoice`, an invoice will be generated at the end of the period,
* consolidating all charge fees with a succeeded payment status.
* @example "invoice"
*/
regroup_paid_fees?: "invoice" | null;
/**
* Specifies whether a charge is prorated based on the remaining number of days in the billing period or billed fully.
*
* - If set to `true`, the charge is prorated based on the remaining days in the current billing period.
* - If set to `false`, the charge is billed in full.
* - If not defined in the request, default value is `false`.
* @example false
*/
prorated?: boolean;
/**
* The minimum spending amount required for the charge, measured in cents and excluding any applicable taxes. It indicates the minimum amount that needs to be charged for each billing period.
* @example 1200
*/
min_amount_cents?: number;
/** List of all thresholds utilized for calculating the charge. */
properties?: ChargeProperties;
/** List of filters used to apply differentiated pricing based on additional event properties. */
filters?: ChargeFilterObject[];
/** All taxes applied to the charge. */
taxes?: TaxObject[];
}
export interface ChargeProperties {
/** Graduated ranges, sorted from bottom to top tiers, used for a `graduated` charge model. */
graduated_ranges?: {
/**
* Specifies the lower value of a tier for a `graduated` charge model. It must be either 0 or the previous range's `to_value + 1` to maintain the proper sequence of values.
* @example 0
*/
from_value: number;
/**
* Specifies the highest value of a tier for a `graduated` charge model.
* - This value must be higher than the from_value of the same tier.
* - This value must be null for the last tier.
* @example 10
*/
to_value: number | null;
/**
* The flat amount for a whole tier, excluding tax, for a `graduated` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "10"
*/
flat_amount: string;
/**
* The unit price, excluding tax, for a specific tier of a `graduated` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "0.5"
*/
per_unit_amount: string;
}[];
/** Graduated percentage ranges, sorted from bottom to top tiers, used for a `graduated_percentage` charge model. */
graduated_percentage_ranges?: {
/**
* Specifies the lower value of a tier for a `graduated_percentage` charge model. It must be either 0 or the previous range's `to_value + 1` to maintain the proper sequence of values.
* @example 0
*/
from_value: number;
/**
* Specifies the highest value of a tier for a `graduated_percentage` charge model.
* - This value must be higher than the from_value of the same tier.
* - This value must be null for the last tier.
* @example 10
*/
to_value: number | null;
/**
* The percentage rate that is applied to the amount of each transaction in the tier for a `graduated_percentage` charge model. It is expressed as a decimal value.
* @format ^[0-9]+.?[0-9]*$
* @example "1"
*/
rate: string;
/**
* The flat amount for a whole tier, excluding tax, for a `graduated_percentage` charge model. It is expressed as a decimal value.
* @format ^[0-9]+.?[0-9]*$
* @example "10"
*/
flat_amount: string;
}[];
/**
* - The unit price, excluding tax, for a `standard` charge model. It is expressed as a decimal value.
* - The amount, excluding tax, for a complete set of units in a `package` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "30"
*/
amount?: string;
/**
* The quantity of units that are provided free of charge for each billing period in a `package` charge model. This field specifies the number of units that customers can use without incurring any additional cost during each billing cycle.
* @example 100
*/
free_units?: number;
/**
* The quantity of units included in each pack or set for a `package` charge model. It indicates the number of units that are bundled together as a single package or set within the pricing structure.
* @example 1000
*/
package_size?: number;
/**
* The percentage rate that is applied to the amount of each transaction for a `percentage` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "1"
*/
rate?: string;
/**
* The fixed fee that is applied to each transaction for a `percentage` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "0.5"
*/
fixed_amount?: string;
/**
* The count of transactions that are not impacted by the `percentage` rate and fixed fee in a percentage charge model. This field indicates the number of transactions that are exempt from the calculation of charges based on the specified percentage rate and fixed fee.
* @example 5
*/
free_units_per_events?: number | null;
/**
* The transaction amount that is not impacted by the `percentage` rate and fixed fee in a percentage charge model. This field indicates the portion of the transaction amount that is exempt from the calculation of charges based on the specified percentage rate and fixed fee.
* @pattern ^[0-9]+.?[0-9]*$
* @example "500"
*/
free_units_per_total_aggregation?: string | null;
/**
* Specifies the maximum allowable spending for a single transaction. Working as a transaction cap.
* @format ^[0-9]+.?[0-9]*$
* @example "3.75"
*/
per_transaction_max_amount?: string | null;
/**
* Specifies the minimum allowable spending for a single transaction. Working as a transaction floor.
* @format ^[0-9]+.?[0-9]*$
* @example "1.75"
*/
per_transaction_min_amount?: string | null;
/**
* The list of event properties that are used to group the events on the invoice for a `standard` charge model.
* @example ["agent_name"]
*/
grouped_by?: string[];
/** Volume ranges, sorted from bottom to top tiers, used for a `volume` charge model. */
volume_ranges?: {
/**
* Specifies the lower value of a tier for a `volume` charge model. It must be either 0 or the previous range's `to_value + 1` to maintain the proper sequence of values.
* @example 0
*/
from_value: number;
/**
* Specifies the highest value of a tier for a `volume` charge model.
* - This value must be higher than the `from_value` of the same tier.
* - This value must be `null` for the last tier.
* @example 10
*/
to_value: number | null;
/**
* The unit price, excluding tax, for a specific tier of a `volume` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "10"
*/
flat_amount: string;
/**
* The flat amount for a whole tier, excluding tax, for a `volume` charge model. It is expressed as a decimal value.
* @pattern ^[0-9]+.?[0-9]*$
* @example "0.5"
*/
per_unit_amount: string;
}[];
}
/** @example "US" */
export type Country = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
export interface Coupon {
coupon: CouponObject;
}
export interface CouponBaseInput {
/**
* The name of the coupon.
* @example "Startup Deal"
*/
name?: string;
/**
* Unique code used to identify the coupon.
* @example "startup_deal"
*/
code?: string;
/**
* Description of the coupon.
* @example "I am a coupon description"
*/
description?: string | null;
/**
* The type of the coupon. It can have two possible values: `fixed_amount` or `percentage`.
*
* - If set to `fixed_amount`, the coupon represents a fixed amount discount.
* - If set to `percentage`, the coupon represents a percentage-based discount.
* @example "fixed_amount"
*/
coupon_type?: "fixed_amount" | "percentage";
/**
* The amount of the coupon in cents. This field is required only for coupon with `fixed_amount` type.
* @example 5000
*/
amount_cents?: number | null;
/**
* The currency of the coupon. This field is required only for coupon with `fixed_amount` type.
* @example "USD"
*/
amount_currency?: Currency | null;
/**
* Indicates whether the coupon can be reused or not. If set to `true`, the coupon is reusable, meaning it can be applied multiple times to the same customer. If set to `false`, the coupon can only be used once and is not reusable. If not specified, this field is set to `true` by default.
* @example false
*/
reusable?: boolean;
/**
* The percentage rate of the coupon. This field is required only for coupons with a `percentage` coupon type.
* @pattern ^[0-9]+.?[0-9]*$
* @example null
*/
percentage_rate?: string | null;
/**
* The type of frequency for the coupon. It can have three possible values: `once`, `recurring` or `forever`.
*
* - If set to `once`, the coupon is applicable only for a single use.
* - If set to `recurring`, the coupon can be used multiple times for recurring billing periods.
* - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
* @example "recurring"
*/
frequency?: "once" | "recurring" | "forever";
/**
* Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
* @example 6
*/
frequency_duration?: number | null;
/**
* Specifies the type of expiration for the coupon. It can have two possible values: `time_limit` or `no_expiration`.
*
* - If set to `time_limit`, the coupon has an expiration based on a specified time limit.
* - If set to `no_expiration`, the coupon does not have an expiration date and remains valid indefinitely.
* @example "time_limit"
*/
expiration?: "no_expiration" | "time_limit";
/**
* The expiration date and time of the coupon. This field is required only for coupons with `expiration` set to `time_limit`. The expiration date and time should be specified in UTC format according to the ISO 8601 datetime standard. It indicates the exact moment when the coupon will expire and is no longer valid.
* @format date-time
* @example "2022-08-08T23:59:59Z"
*/
expiration_at?: string | null;
/** Set coupon limitations to plans or specific metrics. */
applies_to?: {
/**
* An array of plan codes to which the coupon is applicable. By specifying the plan codes in this field, you can restrict the coupon's usage to specific plans only.
* @example ["startup_plan"]
*/
plan_codes?: string[] | null;
/**
* An array of billable metric codes to which the coupon is applicable. By specifying the billable metric codes in this field, you can restrict the coupon's usage to specific metrics only.
* @example []
*/
billable_metric_codes?: string[] | null;
};
}
export interface CouponCreateInput {
coupon: CouponBaseInput;
}
export interface CouponObject {
/**
* Unique identifier of the coupon, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* The name of the coupon.
* @example "Startup Deal"
*/
name: string;
/**
* Unique code used to identify the coupon.
* @example "startup_deal"
*/
code: string;
/**
* Description of the coupon.
* @example "I am a coupon description"
*/
description?: string | null;
/**
* The type of the coupon. It can have two possible values: `fixed_amount` or `percentage`.
*
* - If set to `fixed_amount`, the coupon represents a fixed amount discount.
* - If set to `percentage`, the coupon represents a percentage-based discount.
* @example "fixed_amount"
*/
coupon_type: "fixed_amount" | "percentage";
/**
* The amount of the coupon in cents. This field is required only for coupon with `fixed_amount` type.
* @example 5000
*/
amount_cents?: number | null;
/**
* The currency of the coupon. This field is required only for coupon with `fixed_amount` type.
* @example "USD"
*/
amount_currency?: Currency | null;
/**
* Indicates whether the coupon can be reused or not. If set to `true`, the coupon is reusable, meaning it can be applied multiple times to the same customer. If set to `false`, the coupon can only be used once and is not reusable. If not specified, this field is set to `true` by default.
* @example true
*/
reusable: boolean;
/**
* The coupon is limited to specific plans. The possible values can be `true` or `false`.
* @example true
*/
limited_plans: boolean;
/**
* An array of plan codes to which the coupon is applicable. By specifying the plan codes in this field, you can restrict the coupon's usage to specific plans only.
* @example ["startup_plan"]
*/
plan_codes?: string[];
/**
* The coupon is limited to specific billable metrics. The possible values can be `true` or `false`.
* @example false
*/
limited_billable_metrics: boolean;
/**
* An array of billable metric codes to which the coupon is applicable. By specifying the billable metric codes in this field, you can restrict the coupon's usage to specific metrics only.
* @example []
*/
billable_metric_codes?: string[];
/**
* The percentage rate of the coupon. This field is required only for coupons with a `percentage` coupon type.
* @pattern ^[0-9]+.?[0-9]*$
* @example null
*/
percentage_rate?: string | null;
/**
* The type of frequency for the coupon. It can have three possible values: `once`, `recurring`, or `forever`.
*
* - If set to `once`, the coupon is applicable only for a single use.
* - If set to `recurring`, the coupon can be used multiple times for recurring billing periods.
* - If set to `forever`, the coupon has unlimited usage and can be applied indefinitely.
* @example "recurring"
*/
frequency: "once" | "recurring" | "forever";
/**
* Specifies the number of billing periods to which the coupon applies. This field is required only for coupons with a `recurring` frequency type
* @example 6
*/
frequency_duration?: number | null;
/**
* Specifies the type of expiration for the coupon. It can have two possible values: `time_limit` or `no_expiration`.
*
* - If set to `time_limit`, the coupon has an expiration based on a specified time limit.
* - If set to `no_expiration`, the coupon does not have an expiration date and remains valid indefinitely.
* @example "time_limit"
*/
expiration: "no_expiration" | "time_limit";
/**
* The expiration date and time of the coupon. This field is required only for coupons with `expiration` set to `time_limit`. The expiration date and time should be specified in UTC format according to the ISO 8601 datetime standard. It indicates the exact moment when the coupon will expire and is no longer valid.
* @format date-time
* @example "2022-08-08T23:59:59Z"
*/
expiration_at?: string | null;
/**
* The date and time when the coupon was created. It is expressed in UTC format according to the ISO 8601 datetime standard. This field provides the timestamp for the exact moment when the coupon was initially created.
* @format date-time
* @example "2022-04-29T08:59:51Z"
*/
created_at: string;
/**
* This field indicates if the coupon has been terminated and is no longer usable. If it's not null, it won't be removed for existing customers using it, but it prevents the coupon from being applied in the future.
* @format date-time
* @example "2022-08-08T23:59:59Z"
*/
terminated_at?: string | null;
}
export interface CouponsPaginated {
coupons: CouponObject[];
meta: PaginationMeta;
}
export interface CouponUpdateInput {
coupon: CouponBaseInput;
}
export interface CreditNoteEstimateInput {
credit_note: {
/**
* The invoice unique identifier, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
invoice_id: string;
/**
* The list of credit note's items.
* @example [{"fee_id":"1a901a90-1a90-1a90-1a90-1a901a901a90","amount_cents":10},{"fee_id":"1a901a90-1a90-1a90-1a90-1a901a901a91","amount_cents":5}]
*/
items: {
/**
* The fee unique identifier, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
fee_id: string;
/**
* The amount of the credit note item, expressed in cents.
* @example 10
*/
amount_cents: number;
}[];
};
}
export interface CreditNoteEstimated {
estimated_credit_note: {
/**
* Unique identifier assigned to the invoice that the credit note belongs to
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_invoice_id: string;
/**
* The invoice unique number, related to the credit note.
* @example "LAG-1234"
*/
invoice_number: string;
/**
* The currency of the credit note.
* @example "EUR"
*/
currency: Currency;
/**
* The tax amount of the credit note, expressed in cents.
* @example 20
*/
taxes_amount_cents: number;
/**
* The tax rate associated with this specific credit note.
* @example 20
*/
taxes_rate: number;
/**
* The subtotal of the credit note excluding any applicable taxes, expressed in cents.
* @example 100
*/
sub_total_excluding_taxes_amount_cents: number;
/**
* The credited amount of the credit note, expressed in cents.
* @example 100
*/
max_creditable_amount_cents: number;
/**
* The refunded amount of the credit note, expressed in cents.
* @example 0
*/
max_refundable_amount_cents: number;
/**
* The pro-rated amount of the coupons applied to the source invoice.
* @example 20
*/
coupons_adjustment_amount_cents: number;
/** Array of credit note's items. */
items: {
/**
* The credit note's item amount, expressed in cents.
* @example 100
*/
amount_cents: number;
/**
* Unique identifier assigned to the fee within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the fee's record within the Lago system.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_fee_id: string | null;
}[];
applied_taxes?: {
/**
* Unique identifier of the tax, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_tax_id?: string;
/**
* Name of the tax.
* @example "TVA"
*/
tax_name?: string;
/**
* Unique code used to identify the tax associated with the API request.
* @example "french_standard_vat"
*/
tax_code?: string;
/**
* The percentage rate of the tax
* @example 20
*/
tax_rate?: number;
/**
* Internal description of the taxe
* @example "French standard VAT"
*/
tax_description?: string;
/** @example 100 */
base_amount_cents?: number;
/**
* Amount of the tax
* @example 2000
*/
amount_cents?: number;
/**
* Currency of the tax
* @example "USD"
*/
amount_currency?: Currency;
}[];
};
}
export interface CreditObject {
/**
* Unique identifier assigned to the credit within the Lago application. This ID is exclusively created by Lago and serves as a unique identifier for the credit's item record within the Lago system.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* The amount of credit associated with the invoice, expressed in cents.
* @example 1200
*/
amount_cents: number;
/**
* The currency of the credit.
* @example "EUR"
*/
amount_currency: Currency;
/**
* Indicates whether the credit is applied on the amount before taxes (coupons) or after taxes (credit notes). This flag helps determine the order in which credits are applied to the invoice calculation
* @example false
*/
before_taxes: boolean;
/** The item attached to the credit. */
item: {
/**
* Unique identifier assigned to the credit item within the Lago application.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_item_id: string;
/**
* The type of credit applied. Possible values are `coupon`, `credit_note` or `invoice` (for `progressive_billing` invoice).
* @example "coupon"
*/
type: "coupon" | "credit_note" | "invoice";
/**
* The code of the credit applied. It can be the code of the coupon attached to the credit, the credit note's number or the `progressive_billing` invoice number.
* @example "startup_deal"
*/
code: string;
/**
* The name of the credit applied. It can be the name of the coupon attached to the credit, the initial invoice's number linked to the credit note or the `progressive_billing` invoice number.
* @example "Startup Deal"
*/
name: string;
};
invoice: {
/**
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/** @example "succeeded" */
payment_status: "pending" | "succeeded" | "failed";
};
}
export interface CreditNote {
credit_note: CreditNoteObject;
}
export type CreditNoteAppliedTaxObject = BaseAppliedTax & {
/**
* Unique identifier of the credit note, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_credit_note_id?: string;
/** @example 100 */
base_amount_cents?: number;
};
export interface CreditNoteItemObject {
/**
* The credit note's item unique identifier, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* The credit note's item amount, expressed in cents.
* @example 100
*/
amount_cents: number;
/**
* The credit note's item currency.
* @example "EUR"
*/
amount_currency: Currency;
/** The fee object related to the credit note item. */
fee: FeeObject;
}
export interface CreditNoteObject {
/**
* The credit note unique identifier, created by Lago.
* @format uuid
* @example "1a901a90-1a90-1a90-1a90-1a901a901a90"
*/
lago_id: string;
/**
* The sequential identifier of the credit note, specifically scoped on the associated invoice. It pro