## Create Historical Invoices `v1.contracts.create_historical_invoices(**kwargs) -> ContractCreateHistoricalInvoicesResponse` **post** `/v1/contracts/createHistoricalInvoices` Creates historical usage invoices for a contract ### Parameters - **invoices:** `Array[{ contract_id, credit_type_id, customer_id, 7 more}]` - **contract\_id:** `String` - **credit\_type\_id:** `String` - **customer\_id:** `String` - **exclusive\_end\_date:** `Time` - **inclusive\_start\_date:** `Time` - **issue\_date:** `Time` - **usage\_line\_items:** `Array[{ exclusive_end_date, inclusive_start_date, product_id, 4 more}]` - **exclusive\_end\_date:** `Time` - **inclusive\_start\_date:** `Time` - **product\_id:** `String` - **presentation\_group\_values:** `Hash[Symbol, String]` - **pricing\_group\_values:** `Hash[Symbol, String]` - **quantity:** `Float` - **subtotals\_with\_quantity:** `Array[{ exclusive_end_date, inclusive_start_date, quantity}]` - **exclusive\_end\_date:** `Time` - **inclusive\_start\_date:** `Time` - **quantity:** `Float` - **billable\_status:** `:billable | :unbillable` This field's availability is dependent on your client's configuration. - `:billable` - `:unbillable` - **breakdown\_granularity:** `:HOUR | :DAY` - `:HOUR` - `:DAY` - **custom\_fields:** `Hash[Symbol, String]` - **preview:** `bool` ### Returns - `class ContractCreateHistoricalInvoicesResponse` - **data:** `Array[Invoice]` - **id:** `String` - **credit\_type:** `CreditTypeData` - **customer\_id:** `String` - **line\_items:** `Array[{ credit_type, name, total, 37 more}]` - **credit\_type:** `CreditTypeData` - **name:** `String` - **total:** `Float` - **applied\_commit\_or\_credit:** `{ id, type}` Details about the credit or commit that was applied to this line item. Only present on line items with product of `USAGE`, `SUBSCRIPTION` or `COMPOSITE` types. - **id:** `String` - **type:** `:PREPAID | :POSTPAID | :CREDIT` - `:PREPAID` - `:POSTPAID` - `:CREDIT` - **commit\_custom\_fields:** `Hash[Symbol, String]` - **commit\_id:** `String` For line items with product of `USAGE`, `SUBSCRIPTION`, or `COMPOSITE` types, the ID of the credit or commit that was applied to this line item. For line items with product type of `FIXED`, the ID of the prepaid or postpaid commit that is being paid for. - **commit\_netsuite\_item\_id:** `String` - **commit\_netsuite\_sales\_order\_id:** `String` - **commit\_segment\_id:** `String` - **commit\_type:** `String` `PrepaidCommit` (for commit types `PREPAID` and `CREDIT`) or `PostpaidCommit` (for commit type `POSTPAID`). - **custom\_fields:** `Hash[Symbol, String]` - **discount\_custom\_fields:** `Hash[Symbol, String]` - **discount\_id:** `String` ID of the discount applied to this line item. - **ending\_before:** `Time` The line item's end date (exclusive). - **group\_key:** `String` - **group\_value:** `String` - **is\_prorated:** `bool` Indicates whether the line item is prorated for `SUBSCRIPTION` type product. - **list\_price:** `Rate` Only present for contract invoices and when the `include_list_prices` query parameter is set to true. This will include the list rate for the charge if applicable. Only present for usage and subscription line items. - **metadata:** `String` - **netsuite\_invoice\_billing\_end:** `Time` The end date for the billing period on the invoice. - **netsuite\_invoice\_billing\_start:** `Time` The start date for the billing period on the invoice. - **netsuite\_item\_id:** `String` - **postpaid\_commit:** `{ id}` Only present for line items paying for a postpaid commit true-up. - **id:** `String` - **presentation\_group\_values:** `Hash[Symbol, String]` Includes the presentation group values associated with this line item if presentation group keys are used. - **pricing\_group\_values:** `Hash[Symbol, String]` Includes the pricing group values associated with this line item if dimensional pricing is used. - **product\_custom\_fields:** `Hash[Symbol, String]` - **product\_id:** `String` ID of the product associated with the line item. - **product\_tags:** `Array[String]` The current product tags associated with the line item's `product_id`. - **product\_type:** `String` The type of the line item's product. Possible values are `FixedProductListItem` (for `FIXED` type products), `UsageProductListItem` (for `USAGE` type products), `SubscriptionProductListItem` (for `SUBSCRIPTION` type products) or `CompositeProductListItem` (for `COMPOSITE` type products). For scheduled charges, commit and credit payments, the value is `FixedProductListItem`. - **professional\_service\_custom\_fields:** `Hash[Symbol, String]` - **professional\_service\_id:** `String` - **quantity:** `Float` The quantity associated with the line item. - **reseller\_type:** `:AWS | :AWS_PRO_SERVICE | :GCP | :GCP_PRO_SERVICE` - `:AWS` - `:AWS_PRO_SERVICE` - `:GCP` - `:GCP_PRO_SERVICE` - **scheduled\_charge\_custom\_fields:** `Hash[Symbol, String]` - **scheduled\_charge\_id:** `String` ID of scheduled charge. - **starting\_at:** `Time` The line item's start date (inclusive). - **sub\_line\_items:** `Array[{ custom_fields, name, quantity, 8 more}]` - **custom\_fields:** `Hash[Symbol, String]` - **name:** `String` - **quantity:** `Float` - **subtotal:** `Float` - **charge\_id:** `String` - **credit\_grant\_id:** `String` - **end\_date:** `Time` The end date for the charge (for seats charges only). - **price:** `Float` the unit price for this charge, present only if the charge is not tiered and the quantity is nonzero - **start\_date:** `Time` The start date for the charge (for seats charges only). - **tier\_period:** `{ starting_at, ending_before}` when the current tier started and ends (for tiered charges only) - **starting\_at:** `Time` - **ending\_before:** `Time` - **tiers:** `Array[{ price, quantity, starting_at, subtotal}]` - **price:** `Float` - **quantity:** `Float` - **starting\_at:** `Float` at what metric amount this tier begins - **subtotal:** `Float` - **subscription\_custom\_fields:** `Hash[Symbol, String]` - **tier:** `{ level, starting_at, size}` Populated if the line item has a tiered price. - **level:** `Float` - **starting\_at:** `String` - **size:** `String` - **unit\_price:** `Float` The unit price associated with the line item. - **status:** `String` - **total:** `Float` - **type:** `String` - **amendment\_id:** `String` - **billable\_status:** `:billable | :unbillable` This field's availability is dependent on your client's configuration. - `:billable` - `:unbillable` - **contract\_custom\_fields:** `Hash[Symbol, String]` - **contract\_id:** `String` - **correction\_record:** `{ corrected_invoice_id, memo, reason, corrected_external_invoice}` - **corrected\_invoice\_id:** `String` - **memo:** `String` - **reason:** `String` - **corrected\_external\_invoice:** `{ billing_provider_type, external_status, invoice_id, issued_at_timestamp}` - **billing\_provider\_type:** `:aws_marketplace | :stripe | :netsuite | 5 more` - `:aws_marketplace` - `:stripe` - `:netsuite` - `:custom` - `:azure_marketplace` - `:quickbooks_online` - `:workday` - `:gcp_marketplace` - **external\_status:** `:DRAFT | :FINALIZED | :PAID | 8 more` - `:DRAFT` - `:FINALIZED` - `:PAID` - `:UNCOLLECTIBLE` - `:VOID` - `:DELETED` - `:PAYMENT_FAILED` - `:INVALID_REQUEST_ERROR` - `:SKIPPED` - `:SENT` - `:QUEUED` - **invoice\_id:** `String` - **issued\_at\_timestamp:** `Time` - **created\_at:** `Time` When the invoice was created (UTC). This field is present for correction invoices only. - **custom\_fields:** `Hash[Symbol, untyped]` - **customer\_custom\_fields:** `Hash[Symbol, String]` - **end\_timestamp:** `Time` End of the usage period this invoice covers (UTC) - **external\_invoice:** `{ billing_provider_type, external_status, invoice_id, issued_at_timestamp}` - **billing\_provider\_type:** `:aws_marketplace | :stripe | :netsuite | 5 more` - `:aws_marketplace` - `:stripe` - `:netsuite` - `:custom` - `:azure_marketplace` - `:quickbooks_online` - `:workday` - `:gcp_marketplace` - **external\_status:** `:DRAFT | :FINALIZED | :PAID | 8 more` - `:DRAFT` - `:FINALIZED` - `:PAID` - `:UNCOLLECTIBLE` - `:VOID` - `:DELETED` - `:PAYMENT_FAILED` - `:INVALID_REQUEST_ERROR` - `:SKIPPED` - `:SENT` - `:QUEUED` - **invoice\_id:** `String` - **issued\_at\_timestamp:** `Time` - **invoice\_adjustments:** `Array[{ credit_type, name, total, 2 more}]` - **credit\_type:** `CreditTypeData` - **name:** `String` - **total:** `Float` - **credit\_grant\_custom\_fields:** `Hash[Symbol, String]` - **credit\_grant\_id:** `String` - **issued\_at:** `Time` When the invoice was issued (UTC) - **net\_payment\_terms\_days:** `Float` - **netsuite\_sales\_order\_id:** `String` This field's availability is dependent on your client's configuration. - **plan\_custom\_fields:** `Hash[Symbol, String]` - **plan\_id:** `String` - **plan\_name:** `String` - **reseller\_royalty:** `{ fraction, netsuite_reseller_id, reseller_type, 2 more}` Only present for contract invoices with reseller royalties. - **fraction:** `String` - **netsuite\_reseller\_id:** `String` - **reseller\_type:** `:AWS | :AWS_PRO_SERVICE | :GCP | :GCP_PRO_SERVICE` - `:AWS` - `:AWS_PRO_SERVICE` - `:GCP` - `:GCP_PRO_SERVICE` - **aws\_options:** `{ aws_account_number, aws_offer_id, aws_payer_reference_id}` - **aws\_account\_number:** `String` - **aws\_offer\_id:** `String` - **aws\_payer\_reference\_id:** `String` - **gcp\_options:** `{ gcp_account_id, gcp_offer_id}` - **gcp\_account\_id:** `String` - **gcp\_offer\_id:** `String` - **salesforce\_opportunity\_id:** `String` This field's availability is dependent on your client's configuration. - **start\_timestamp:** `Time` Beginning of the usage period this invoice covers (UTC) - **subtotal:** `Float` ### Example ```ruby require "metronome_sdk" metronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token") response = metronome.v1.contracts.create_historical_invoices( invoices: [ { contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", credit_type_id: "2714e483-4ff1-48e4-9e25-ac732e8f24f2", customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d", exclusive_end_date: "2020-02-01T00:00:00.000Z", inclusive_start_date: "2020-01-01T00:00:00.000Z", issue_date: "2020-02-01T00:00:00.000Z", usage_line_items: [ { exclusive_end_date: "2020-02-01T00:00:00.000Z", inclusive_start_date: "2020-01-01T00:00:00.000Z", product_id: "f14d6729-6a44-4b13-9908-9387f1918790" } ] } ], preview: false ) puts(response) ```