// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import MiniSearch from 'minisearch'; import * as fs from 'node:fs/promises'; import * as path from 'node:path'; import { getLogger } from './logger'; type PerLanguageData = { method?: string; example?: string; }; type MethodEntry = { name: string; endpoint: string; httpMethod: string; summary: string; description: string; stainlessPath: string; qualified: string; params?: string[]; response?: string; markdown?: string; perLanguage?: Record; }; type ProseChunk = { content: string; tag: string; sectionContext?: string; source?: string; }; type MiniSearchDocument = { id: string; kind: 'http_method' | 'prose'; name?: string; endpoint?: string; summary?: string; description?: string; qualified?: string; stainlessPath?: string; content?: string; sectionContext?: string; _original: Record; }; type SearchResult = { results: (string | Record)[]; }; const EMBEDDED_METHODS: MethodEntry[] = [ { name: 'retrieve', endpoint: '/v2/contracts/get', httpMethod: 'post', summary: 'Get a contract (v2)', description: "Gets the details for a specific contract, including contract term, rate card information, credits and commits, and more. \n\n### Use this endpoint to: \n- Check the duration of a customer's current contract\n- Get details on contract terms, including access schedule amounts for commitments and credits\n- Understand the state of a contract at a past time. As you can evolve the terms of a contract over time through editing, use the `as_of_date` parameter to view the full contract configuration as of that point in time. \n\n### Usage guidelines: \n- Optionally, use the `include_balance` and `include_ledger` fields to include balances and ledgers in the credit and commit responses. Using these fields will cause the query to be slower.\n", stainlessPath: '(resource) v2.contracts > (method) retrieve', qualified: 'client.v2.contracts.retrieve', params: [ 'contract_id: string;', 'customer_id: string;', 'as_of_date?: string;', 'include_balance?: boolean;', 'include_ledgers?: boolean;', ], response: '{ data: object; }', markdown: "## retrieve\n\n`client.v2.contracts.retrieve(contract_id: string, customer_id: string, as_of_date?: string, include_balance?: boolean, include_ledgers?: boolean): { data: contract_v2; }`\n\n**post** `/v2/contracts/get`\n\nGets the details for a specific contract, including contract term, rate card information, credits and commits, and more. \n\n### Use this endpoint to: \n- Check the duration of a customer's current contract\n- Get details on contract terms, including access schedule amounts for commitments and credits\n- Understand the state of a contract at a past time. As you can evolve the terms of a contract over time through editing, use the `as_of_date` parameter to view the full contract configuration as of that point in time. \n\n### Usage guidelines: \n- Optionally, use the `include_balance` and `include_ledger` fields to include balances and ledgers in the credit and commit responses. Using these fields will cause the query to be slower.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `as_of_date?: string`\n Optional RFC 3339 timestamp. Return the contract as of this date. Cannot be used with include_ledgers parameter.\n\n- `include_balance?: boolean`\n Include the balance of credits and commits in the response. Setting this flag may cause the query to be slower.\n\n- `include_ledgers?: boolean`\n Include commit/credit ledgers in the response. Setting this flag may cause the query to be slower. Cannot be used with as_of_date parameter.\n\n### Returns\n\n- `{ data: { id: string; commits: object[]; created_at: string; created_by: string; customer_id: string; overrides: object[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_filter: object[]; usage_statement_schedule: object; archived_at?: string; billing_provider_configuration_schedule?: object[]; credits?: object[]; custom_fields?: object; customer_billing_provider_configuration?: object; discounts?: discount[]; ending_before?: string; has_more?: object; hierarchy_configuration?: object | object; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration_v2; priority?: number; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; revenue_system_configuration_schedule?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration_v2; spend_trackers?: object[]; subscriptions?: object[]; total_contract_value?: number; uniqueness_key?: string; }; }`\n\n - `data: { id: string; commits: { id: string; created_at: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: object; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_contract?: { id: string; }; invoice_schedule?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_ROLLOVER'; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CREDITED'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_INITIAL_BALANCE'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_ROLLOVER'; } | { amount: number; invoice_id: string; timestamp: string; type: 'POSTPAID_COMMIT_TRUEUP'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'PREPAID_COMMIT_MANUAL'; } | { amount: number; reason: string; timestamp: string; type: 'POSTPAID_COMMIT_MANUAL'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_EXPIRATION'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: { commit_id: string; contract_id: string; }; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; subscription_config?: object; }[]; created_at: string; created_by: string; customer_id: string; overrides: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; override_tiers?: object[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; scheduled_charges: { id: string; product: object; schedule: schedule_point_in_time; archived_at?: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; starting_at: string; transitions: { from_contract_id: string; to_contract_id: string; type: 'RENEWAL'; }[]; usage_filter: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; usage_statement_schedule: { billing_anchor_date: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; }; archived_at?: string; billing_provider_configuration_schedule?: { billing_provider_configuration: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; effective_at: string; effective_until?: string; }[]; credits?: { id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: object; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; created_at?: string; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CREDITED'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'CREDIT_MANUAL'; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'CREDIT_ROLLOVER'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; recurring_credit_id?: string; rolled_over_from?: { contract_id: string; credit_id: string; }; salesforce_opportunity_id?: string; specifiers?: object[]; subscription_config?: object; }[]; custom_fields?: object; customer_billing_provider_configuration?: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; discounts?: { id: string; product: object; schedule: schedule_point_in_time; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; ending_before?: string; has_more?: { commits: boolean; credits: boolean; }; hierarchy_configuration?: { children: { contract_id: string; customer_id: string; }[]; parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }; } | { parent: { contract_id: string; customer_id: string; }; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; priority?: number; professional_services?: { id: string; max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]; rate_card_id?: string; recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; segments: { fraction: number; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; gcp_account_id?: string; gcp_offer_id?: string; reseller_contract_value?: number; }[]; }[]; revenue_system_configuration_schedule?: { effective_at: string; revenue_system_configuration: { id: string; configuration: object; customer_id: string; delivery_method_id: string; provider: 'netsuite'; archived_at?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration?: object; }; effective_until?: string; }[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; threshold_amount: number; discount_configuration?: object; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; accumulated_spend?: { amount: number; period_ending_before: string; period_starting_at: string; }; }[]; subscriptions?: { billing_periods: { current?: object; next?: object; previous?: object; }; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: object; }; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: { quantity: number; starting_at: string; ending_before?: string; }[]; starting_at: string; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: object; }; id?: string; billing_cycle_config?: { anchor_date: string; invoice_placement: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: { seat_group_key: string; }; }[]; total_contract_value?: number; uniqueness_key?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst contract = await client.v2.contracts.retrieve({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(contract);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst contract = await client.v2.contracts.retrieve({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(contract.data);", }, python: { method: 'v2.contracts.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncontract = client.v2.contracts.retrieve(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(contract.data)', }, java: { method: 'v2().contracts().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractRetrieveParams;\nimport com.metronome.api.models.v2.contracts.ContractRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractRetrieveParams params = ContractRetrieveParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractRetrieveResponse contract = client.v2().contracts().retrieve(params);\n }\n}', }, go: { method: 'client.V2.Contracts.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcontract, err := client.V2.Contracts.Get(context.TODO(), metronome.V2ContractGetParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", contract.Data)\n}\n', }, ruby: { method: 'v2.contracts.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncontract = metronome.v2.contracts.retrieve(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(contract)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'list', endpoint: '/v2/contracts/list', httpMethod: 'post', summary: 'List customer contracts (v2)', description: "For a given customer, lists all of their contracts in chronological order. \n\n### Use this endpoint to:\n- Check if a customer is provisioned with any contract, and at which tier\n- Check the duration and terms of a customer's current contract\n- Power a page in your end customer experience that shows the customer's history of tiers (e.g. this customer started out on the Pro Plan, then downgraded to the Starter plan).\n\n### Usage guidelines:\nUse the `starting_at`, `covering_date`, and `include_archived` parameters to filter the list of returned contracts. For example, to list only currently active contracts, pass `covering_date` equal to the current time.\n", stainlessPath: '(resource) v2.contracts > (method) list', qualified: 'client.v2.contracts.list', params: [ 'customer_id: string;', 'covering_date?: string;', 'include_archived?: boolean;', 'include_balance?: boolean;', 'include_ledgers?: boolean;', 'starting_at?: string;', ], response: '{ data: object[]; }', markdown: "## list\n\n`client.v2.contracts.list(customer_id: string, covering_date?: string, include_archived?: boolean, include_balance?: boolean, include_ledgers?: boolean, starting_at?: string): { data: contract_v2[]; }`\n\n**post** `/v2/contracts/list`\n\nFor a given customer, lists all of their contracts in chronological order. \n\n### Use this endpoint to:\n- Check if a customer is provisioned with any contract, and at which tier\n- Check the duration and terms of a customer's current contract\n- Power a page in your end customer experience that shows the customer's history of tiers (e.g. this customer started out on the Pro Plan, then downgraded to the Starter plan).\n\n### Usage guidelines:\nUse the `starting_at`, `covering_date`, and `include_archived` parameters to filter the list of returned contracts. For example, to list only currently active contracts, pass `covering_date` equal to the current time.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `covering_date?: string`\n Optional RFC 3339 timestamp. Only include contracts active on the provided date. This cannot be provided if starting_at filter is provided.\n\n- `include_archived?: boolean`\n Include archived contracts in the response.\n\n- `include_balance?: boolean`\n Include the balance of credits and commits in the response. Setting this flag may cause the response to be slower.\n\n- `include_ledgers?: boolean`\n Include commit/credit ledgers in the response. Setting this flag may cause the response to be slower.\n\n- `starting_at?: string`\n Optional RFC 3339 timestamp. Only include contracts that started on or after this date. This cannot be provided if covering_date filter is provided.\n\n### Returns\n\n- `{ data: { id: string; commits: object[]; created_at: string; created_by: string; customer_id: string; overrides: object[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_filter: object[]; usage_statement_schedule: object; archived_at?: string; billing_provider_configuration_schedule?: object[]; credits?: object[]; custom_fields?: object; customer_billing_provider_configuration?: object; discounts?: discount[]; ending_before?: string; has_more?: object; hierarchy_configuration?: object | object; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration_v2; priority?: number; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; revenue_system_configuration_schedule?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration_v2; spend_trackers?: object[]; subscriptions?: object[]; total_contract_value?: number; uniqueness_key?: string; }[]; }`\n\n - `data: { id: string; commits: { id: string; created_at: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: object; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_contract?: { id: string; }; invoice_schedule?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_ROLLOVER'; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CREDITED'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_INITIAL_BALANCE'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_ROLLOVER'; } | { amount: number; invoice_id: string; timestamp: string; type: 'POSTPAID_COMMIT_TRUEUP'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'PREPAID_COMMIT_MANUAL'; } | { amount: number; reason: string; timestamp: string; type: 'POSTPAID_COMMIT_MANUAL'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_EXPIRATION'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: { commit_id: string; contract_id: string; }; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; subscription_config?: object; }[]; created_at: string; created_by: string; customer_id: string; overrides: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; override_tiers?: object[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; scheduled_charges: { id: string; product: object; schedule: schedule_point_in_time; archived_at?: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; starting_at: string; transitions: { from_contract_id: string; to_contract_id: string; type: 'RENEWAL'; }[]; usage_filter: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; usage_statement_schedule: { billing_anchor_date: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; }; archived_at?: string; billing_provider_configuration_schedule?: { billing_provider_configuration: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; effective_at: string; effective_until?: string; }[]; credits?: { id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: object; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; created_at?: string; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CREDITED'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'CREDIT_MANUAL'; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'CREDIT_ROLLOVER'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; recurring_credit_id?: string; rolled_over_from?: { contract_id: string; credit_id: string; }; salesforce_opportunity_id?: string; specifiers?: object[]; subscription_config?: object; }[]; custom_fields?: object; customer_billing_provider_configuration?: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; discounts?: { id: string; product: object; schedule: schedule_point_in_time; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; ending_before?: string; has_more?: { commits: boolean; credits: boolean; }; hierarchy_configuration?: { children: { contract_id: string; customer_id: string; }[]; parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }; } | { parent: { contract_id: string; customer_id: string; }; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; priority?: number; professional_services?: { id: string; max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]; rate_card_id?: string; recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; segments: { fraction: number; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; gcp_account_id?: string; gcp_offer_id?: string; reseller_contract_value?: number; }[]; }[]; revenue_system_configuration_schedule?: { effective_at: string; revenue_system_configuration: { id: string; configuration: object; customer_id: string; delivery_method_id: string; provider: 'netsuite'; archived_at?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration?: object; }; effective_until?: string; }[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; threshold_amount: number; discount_configuration?: object; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; accumulated_spend?: { amount: number; period_ending_before: string; period_starting_at: string; }; }[]; subscriptions?: { billing_periods: { current?: object; next?: object; previous?: object; }; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: object; }; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: { quantity: number; starting_at: string; ending_before?: string; }[]; starting_at: string; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: object; }; id?: string; billing_cycle_config?: { anchor_date: string; invoice_placement: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: { seat_group_key: string; }; }[]; total_contract_value?: number; uniqueness_key?: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst contracts = await client.v2.contracts.list({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(contracts);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst contracts = await client.v2.contracts.list({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(contracts.data);", }, python: { method: 'v2.contracts.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncontracts = client.v2.contracts.list(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(contracts.data)', }, java: { method: 'v2().contracts().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractListParams;\nimport com.metronome.api.models.v2.contracts.ContractListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractListParams params = ContractListParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractListResponse contracts = client.v2().contracts().list(params);\n }\n}', }, go: { method: 'client.V2.Contracts.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcontracts, err := client.V2.Contracts.List(context.TODO(), metronome.V2ContractListParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", contracts.Data)\n}\n', }, ruby: { method: 'v2.contracts.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncontracts = metronome.v2.contracts.list(customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(contracts)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'edit', endpoint: '/v2/contracts/edit', httpMethod: 'post', summary: 'Edit a contract', description: 'The ability to edit a contract helps you react quickly to the needs of your customers and your business.\n\n### Use this endpoint to:\n- Encode mid-term commitment and discount changes\n- Fix configuration mistakes and easily roll back packaging changes\n\n### Key response fields:\n- The `id` of the edit\n- Complete edit details. For example, if you edited the contract to add new overrides and credits, you will receive the IDs of those overrides and credits in the response.\n\n### Usage guidelines:\n- When you edit a contract, any draft invoices update immediately to reflect that edit. Finalized invoices remain unchanged - you must void and regenerate them in the UI or API to reflect the edit.\n- Contract editing must be enabled to use this endpoint. Reach out to your Metronome representative to learn more.\n', stainlessPath: '(resource) v2.contracts > (method) edit', qualified: 'client.v2.contracts.edit', params: [ 'contract_id: string;', 'customer_id: string;', "add_billing_provider_configuration_update?: { billing_provider_configuration: { billing_provider?: string; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; };", "add_commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; on_session_payment?: boolean; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[];", "add_credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[];", "add_discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", "add_overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[];", "add_prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; };", 'add_professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[];', "add_recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[];", "add_recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[];", "add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[];", "add_revenue_system_configuration_update?: { revenue_system_configuration: { delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; };", "add_scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", "add_spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; };", "add_spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[];", "add_subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[];", 'allow_contract_ending_before_finalized_invoice?: boolean;', 'archive_commits?: { id: string; }[];', 'archive_credits?: { id: string; }[];', 'archive_scheduled_charges?: { id: string; }[];', 'archive_spend_trackers?: string[];', 'remove_overrides?: { id: string; }[];', 'uniqueness_key?: string;', "update_commits?: { commit_id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[];", 'update_contract_end_date?: string;', 'update_contract_name?: string;', "update_credits?: { credit_id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[];", 'update_net_payment_terms_days?: number;', "update_prepaid_balance_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; custom_credit_type_id?: string; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]; };", "update_recurring_commits?: { recurring_commit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; invoice_amount?: { quantity?: number; unit_price?: number; }; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[];", "update_recurring_credits?: { recurring_credit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[];", 'update_scheduled_charges?: { scheduled_charge_id: string; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; netsuite_sales_order_id?: string; }[];', "update_spend_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount?: number; };", "update_subscriptions?: { subscription_id: string; ending_before?: string; proration_rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; quantity_management_mode_update?: { quantity_management_mode: 'SEAT_BASED'; seat_config: { seat_group_key: string; }; }; quantity_updates?: { starting_at: string; quantity?: number; quantity_delta?: number; }[]; seat_updates?: { add_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; add_unassigned_seats?: { quantity: number; starting_at: string; }[]; remove_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; remove_unassigned_seats?: { quantity: number; starting_at: string; }[]; }; }[];", ], response: '{ data: { id: string; edit?: { id: string; add_commits?: object[]; add_credits?: object[]; add_discounts?: discount[]; add_overrides?: object[]; add_prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration_v2; add_pro_services?: pro_service[]; add_recurring_commits?: object[]; add_recurring_credits?: object[]; add_reseller_royalties?: object[]; add_scheduled_charges?: object[]; add_spend_threshold_configuration?: spend_threshold_configuration_v2; add_subscriptions?: object[]; add_usage_filters?: object[]; archive_commits?: object[]; archive_credits?: object[]; archive_scheduled_charges?: object[]; remove_overrides?: object[]; timestamp?: string; uniqueness_key?: string; update_commits?: object[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: object[]; update_discounts?: object[]; update_prepaid_balance_threshold_configuration?: object; update_recurring_commits?: object[]; update_recurring_credits?: object[]; update_refund_invoices?: object[]; update_scheduled_charges?: object[]; update_spend_threshold_configuration?: object; update_subscriptions?: object[]; }; }; }', markdown: "## edit\n\n`client.v2.contracts.edit(contract_id: string, customer_id: string, add_billing_provider_configuration_update?: { billing_provider_configuration: { billing_provider?: string; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; }, add_commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: object[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[], add_credits?: { access_schedule: { schedule_items: object[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; }[], add_discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], add_overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[], add_prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }, add_professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[], add_recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[], add_recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[], add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[], add_revenue_system_configuration_update?: { revenue_system_configuration: { delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; }, add_scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], add_spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; threshold_amount: number; discount_configuration?: object; }, add_spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[], add_subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: object; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[], allow_contract_ending_before_finalized_invoice?: boolean, archive_commits?: { id: string; }[], archive_credits?: { id: string; }[], archive_scheduled_charges?: { id: string; }[], archive_spend_trackers?: string[], remove_overrides?: { id: string; }[], uniqueness_key?: string, update_commits?: { commit_id: string; access_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; invoice_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[], update_contract_end_date?: string, update_contract_name?: string, update_credits?: { credit_id: string; access_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[], update_net_payment_terms_days?: number, update_prepaid_balance_threshold_configuration?: { commit?: object; custom_credit_type_id?: string; discount_configuration?: { cap?: object; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: object; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: { exclude: object[]; }[]; }, update_recurring_commits?: { recurring_commit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; invoice_amount?: { quantity?: number; unit_price?: number; }; proration_rounding?: { access?: object; invoice?: object; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[], update_recurring_credits?: { recurring_credit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; proration_rounding?: { access?: object; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[], update_scheduled_charges?: { scheduled_charge_id: string; invoice_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; netsuite_sales_order_id?: string; }[], update_spend_threshold_configuration?: { commit?: object; discount_configuration?: { cap?: object; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: object; threshold_amount?: number; }, update_subscriptions?: { subscription_id: string; ending_before?: string; proration_rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; quantity_management_mode_update?: { quantity_management_mode: 'SEAT_BASED'; seat_config: object; }; quantity_updates?: { starting_at: string; quantity?: number; quantity_delta?: number; }[]; seat_updates?: { add_seat_ids?: object[]; add_unassigned_seats?: object[]; remove_seat_ids?: object[]; remove_unassigned_seats?: object[]; }; }[]): { data: object; }`\n\n**post** `/v2/contracts/edit`\n\nThe ability to edit a contract helps you react quickly to the needs of your customers and your business.\n\n### Use this endpoint to:\n- Encode mid-term commitment and discount changes\n- Fix configuration mistakes and easily roll back packaging changes\n\n### Key response fields:\n- The `id` of the edit\n- Complete edit details. For example, if you edited the contract to add new overrides and credits, you will receive the IDs of those overrides and credits in the response.\n\n### Usage guidelines:\n- When you edit a contract, any draft invoices update immediately to reflect that edit. Finalized invoices remain unchanged - you must void and regenerate them in the UI or API to reflect the edit.\n- Contract editing must be enabled to use this endpoint. Reach out to your Metronome representative to learn more.\n\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract being edited\n\n- `customer_id: string`\n ID of the customer whose contract is being edited\n\n- `add_billing_provider_configuration_update?: { billing_provider_configuration: { billing_provider?: string; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; }`\n Update the billing provider configuration on the contract. Currently only supports adding a billing provider configuration to a contract that does not already have one.\n - `billing_provider_configuration: { billing_provider?: string; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }`\n - `schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }`\n Indicates when the billing provider will be active on the contract. Any charges accrued during the schedule will be billed to the indicated billing provider.\n\n- `add_commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; on_session_payment?: boolean; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[]`\n\n- `add_credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n\n- `add_discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n\n- `add_overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]`\n\n- `add_prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `recharge_to_amount: number`\n Specify the amount the balance should be recharged to.\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's balance lowers to this amount, a threshold charge will be initiated.\n - `custom_credit_type_id?: string`\n If provided, the threshold, recharge-to amount, and the resulting threshold commit amount will be in terms of this credit type instead of the fiat currency.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n - `threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Determines which balances are excluded from remaining balance calculation for threshold billing.\n\n- `add_professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `add_recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[]`\n\n- `add_recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'POOLED' | 'INDIVIDUAL'; }; temporary_id?: string; }[]`\n\n- `add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]`\n\n- `add_revenue_system_configuration_update?: { revenue_system_configuration: { delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }; schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }; }`\n Update the revenue system configuration on the contract. Currently only supports adding a revenue system configuration to a contract that does not already have one.\n - `revenue_system_configuration: { delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }`\n - `schedule: { effective_at: 'START_OF_CURRENT_PERIOD' | 'START_OF_NEXT_PERIOD'; }`\n\n- `add_scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n\n- `add_spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's usage hits this amount, a threshold charge will be initiated.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n\n- `add_spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]`\n Spend trackers to add to this contract. Aliases must be unique within a contract.\n\n- `add_subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[]`\n Optional list of [subscriptions](https://docs.metronome.com/manage-product-access/create-subscription/) to add to the contract.\n\n- `allow_contract_ending_before_finalized_invoice?: boolean`\n If true, allows setting the contract end date earlier than the end_timestamp of existing finalized invoices. Finalized invoices will be unchanged; if you want to incorporate the new end date, you can void and regenerate finalized usage invoices. Defaults to true.\n\n- `archive_commits?: { id: string; }[]`\n IDs of commits to archive\n\n- `archive_credits?: { id: string; }[]`\n IDs of credits to archive\n\n- `archive_scheduled_charges?: { id: string; }[]`\n IDs of scheduled charges to archive\n\n- `archive_spend_trackers?: string[]`\n Aliases of spend trackers to archive.\n\n- `remove_overrides?: { id: string; }[]`\n IDs of overrides to remove\n\n- `uniqueness_key?: string`\n Optional uniqueness key to prevent duplicate contract edits.\n\n- `update_commits?: { commit_id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[]`\n\n- `update_contract_end_date?: string`\n RFC 3339 timestamp indicating when the contract will end (exclusive).\n\n- `update_contract_name?: string`\n Value to update the contract name to. If not provided, the contract name will remain unchanged.\n\n- `update_credits?: { credit_id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; }[]`\n\n- `update_net_payment_terms_days?: number`\n Number of days after issuance of invoice after which the invoice is due (e.g. Net 30).\n\n- `update_prepaid_balance_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; custom_credit_type_id?: string; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]; }`\n - `commit?: { description?: string; name?: string; priority?: number; product_id?: string; }`\n - `custom_credit_type_id?: string`\n If provided, the threshold, recharge-to amount, and the resulting threshold commit amount will be in terms of this credit type instead of the fiat currency.\n - `discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }`\n - `is_enabled?: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `recharge_to_amount?: number`\n Specify the amount the balance should be recharged to.\n - `threshold_amount?: number`\n Specify the threshold amount for the contract. Each time the contract's balance lowers to this amount, a threshold charge will be initiated.\n - `threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Determines which balances are excluded from remaining balance calculation for threshold billing.\n\n- `update_recurring_commits?: { recurring_commit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; invoice_amount?: { quantity?: number; unit_price?: number; }; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]`\n Edits to these recurring commits will only affect commits whose access schedules has not started. Expired commits, and commits with an active access schedule will remain unchanged.\n\n- `update_recurring_credits?: { recurring_credit_id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]`\n Edits to these recurring credits will only affect credits whose access schedules has not started. Expired credits, and credits with an active access schedule will remain unchanged.\n\n- `update_scheduled_charges?: { scheduled_charge_id: string; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; netsuite_sales_order_id?: string; }[]`\n\n- `update_spend_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount?: number; }`\n - `commit?: { description?: string; name?: string; priority?: number; product_id?: string; }`\n - `discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }`\n - `is_enabled?: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `threshold_amount?: number`\n Specify the threshold amount for the contract. Each time the contract's usage hits this amount, a threshold charge will be initiated.\n\n- `update_subscriptions?: { subscription_id: string; ending_before?: string; proration_rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; quantity_management_mode_update?: { quantity_management_mode: 'SEAT_BASED'; seat_config: { seat_group_key: string; }; }; quantity_updates?: { starting_at: string; quantity?: number; quantity_delta?: number; }[]; seat_updates?: { add_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; add_unassigned_seats?: { quantity: number; starting_at: string; }[]; remove_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; remove_unassigned_seats?: { quantity: number; starting_at: string; }[]; }; }[]`\n Optional list of subscriptions to update.\n\n### Returns\n\n- `{ data: { id: string; edit?: { id: string; add_commits?: object[]; add_credits?: object[]; add_discounts?: discount[]; add_overrides?: object[]; add_prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration_v2; add_pro_services?: pro_service[]; add_recurring_commits?: object[]; add_recurring_credits?: object[]; add_reseller_royalties?: object[]; add_scheduled_charges?: object[]; add_spend_threshold_configuration?: spend_threshold_configuration_v2; add_subscriptions?: object[]; add_usage_filters?: object[]; archive_commits?: object[]; archive_credits?: object[]; archive_scheduled_charges?: object[]; remove_overrides?: object[]; timestamp?: string; uniqueness_key?: string; update_commits?: object[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: object[]; update_discounts?: object[]; update_prepaid_balance_threshold_configuration?: object; update_recurring_commits?: object[]; update_recurring_credits?: object[]; update_refund_invoices?: object[]; update_scheduled_charges?: object[]; update_spend_threshold_configuration?: object; update_subscriptions?: object[]; }; }; }`\n\n - `data: { id: string; edit?: { id: string; add_commits?: { id: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; invoice_schedule?: { credit_type?: credit_type_data; do_not_invoice?: boolean; schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: object[]; }[]; add_credits?: { id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: object[]; }[]; add_discounts?: { id: string; product: object; schedule: schedule_point_in_time; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; add_overrides?: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; override_tiers?: object[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; add_prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; add_pro_services?: { id: string; max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]; add_recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; add_recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; fraction?: number; gcp_account_id?: string; gcp_offer_id?: string; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]; add_scheduled_charges?: { id: string; product: { id: string; name: string; }; schedule: object; name?: string; netsuite_sales_order_id?: string; }[]; add_spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config_v2; threshold_amount: number; discount_configuration?: object; }; add_subscriptions?: { billing_periods: { current?: object; next?: object; previous?: object; }; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: object; }; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: { quantity: number; starting_at: string; ending_before?: string; }[]; starting_at: string; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: object; }; id?: string; billing_cycle_config?: { anchor_date: string; invoice_placement: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: { seat_group_key: string; }; }[]; add_usage_filters?: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; archive_commits?: { id: string; }[]; archive_credits?: { id: string; }[]; archive_scheduled_charges?: { id: string; }[]; remove_overrides?: { id: string; }[]; timestamp?: string; uniqueness_key?: string; update_commits?: { id: string; access_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; invoice_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; }[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: { id: string; access_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; specifiers?: object[]; }[]; update_discounts?: { id: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; }[]; update_prepaid_balance_threshold_configuration?: { commit?: object; custom_credit_type_id?: string; discount_configuration?: { cap?: object; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: object; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: { exclude: object[]; }[]; }; update_recurring_commits?: { id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; invoice_amount?: { quantity?: number; unit_price?: number; }; proration_rounding?: { access?: object; invoice?: object; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_recurring_credits?: { id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; proration_rounding?: { access?: object; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_refund_invoices?: { date: string; invoice_id: string; }[]; update_scheduled_charges?: { id: string; invoice_schedule?: { add_schedule_items?: object[]; remove_schedule_items?: object[]; update_schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; }[]; update_spend_threshold_configuration?: { commit?: object; discount_configuration?: { cap?: object; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: object; threshold_amount?: number; }; update_subscriptions?: { id: string; ending_before?: string; quantity_updates?: { starting_at: string; quantity?: number; quantity_delta?: number; }[]; seat_updates?: { add_seat_ids?: object[]; add_unassigned_seats?: object[]; remove_seat_ids?: object[]; remove_unassigned_seats?: object[]; }; }[]; }; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v2.contracts.edit({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.edit', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v2.contracts.edit({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n add_overrides: [\n {\n type: 'MULTIPLIER',\n starting_at: '2024-11-02T00:00:00Z',\n product_id: 'd4fc086c-d8e5-4091-a235-fbba5da4ec14',\n multiplier: 2,\n priority: 100,\n },\n ],\n add_scheduled_charges: [\n {\n product_id: '2e30f074-d04c-412e-a134-851ebfa5ceb2',\n schedule: {\n schedule_items: [\n {\n timestamp: '2020-02-15T00:00:00.000Z',\n unit_price: 1000000,\n quantity: 1,\n },\n ],\n },\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v2.contracts.edit', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v2.contracts.edit(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n add_overrides=[{\n "type": "MULTIPLIER",\n "starting_at": datetime.fromisoformat("2024-11-02T00:00:00"),\n "product_id": "d4fc086c-d8e5-4091-a235-fbba5da4ec14",\n "multiplier": 2,\n "priority": 100,\n }],\n add_scheduled_charges=[{\n "product_id": "2e30f074-d04c-412e-a134-851ebfa5ceb2",\n "schedule": {\n "schedule_items": [{\n "timestamp": datetime.fromisoformat("2020-02-15T00:00:00.000"),\n "unit_price": 1000000,\n "quantity": 1,\n }]\n },\n }],\n)\nprint(response.data)', }, java: { method: 'v2().contracts().edit', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractEditParams;\nimport com.metronome.api.models.v2.contracts.ContractEditResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractEditParams params = ContractEditParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractEditResponse response = client.v2().contracts().edit(params);\n }\n}', }, go: { method: 'client.V2.Contracts.Edit', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V2.Contracts.Edit(context.TODO(), metronome.V2ContractEditParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tAddOverrides: []metronome.V2ContractEditParamsAddOverride{{\n\t\t\tType: "MULTIPLIER",\n\t\t\tStartingAt: time.Now(),\n\t\t\tProductID: metronome.String("d4fc086c-d8e5-4091-a235-fbba5da4ec14"),\n\t\t\tMultiplier: metronome.Float(2),\n\t\t\tPriority: metronome.Float(100),\n\t\t}},\n\t\tAddScheduledCharges: []metronome.V2ContractEditParamsAddScheduledCharge{{\n\t\t\tProductID: "2e30f074-d04c-412e-a134-851ebfa5ceb2",\n\t\t\tSchedule: metronome.V2ContractEditParamsAddScheduledChargeSchedule{\n\t\t\t\tScheduleItems: []metronome.V2ContractEditParamsAddScheduledChargeScheduleScheduleItem{{\n\t\t\t\t\tTimestamp: time.Now(),\n\t\t\t\t\tUnitPrice: metronome.Float(1000000),\n\t\t\t\t\tQuantity: metronome.Float(1),\n\t\t\t\t}},\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v2.contracts.edit', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v2.contracts.edit(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/edit \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "add_overrides": [\n {\n "starting_at": "2024-11-02T00:00:00Z",\n "multiplier": 2,\n "priority": 100,\n "product_id": "d4fc086c-d8e5-4091-a235-fbba5da4ec14",\n "type": "MULTIPLIER"\n }\n ],\n "add_scheduled_charges": [\n {\n "product_id": "2e30f074-d04c-412e-a134-851ebfa5ceb2",\n "schedule": {\n "schedule_items": [\n {\n "timestamp": "2020-02-15T00:00:00.000Z",\n "quantity": 1,\n "unit_price": 1000000\n }\n ]\n }\n }\n ]\n }\'', }, }, }, { name: 'get_edit_history', endpoint: '/v2/contracts/getEditHistory', httpMethod: 'post', summary: 'Get contract edit history', description: "List all the edits made to a contract over time. In Metronome, you can edit a contract at any point after it's created to fix mistakes or reflect changes in terms. Metronome stores a full history of all edits that were ever made to a contract, whether through the UI, `editContract` endpoint, or other endpoints like `updateContractEndDate`. \n\n### Use this endpoint to: \n- Understand what changes were made to a contract, when, and by who\n\n### Key response fields: \n- An array of every edit ever made to the contract\n- Details on each individual edit - for example showing that in one edit, a user added two discounts and incremented a subscription quantity.\n", stainlessPath: '(resource) v2.contracts > (method) get_edit_history', qualified: 'client.v2.contracts.getEditHistory', params: ['contract_id: string;', 'customer_id: string;'], response: '{ data: { id: string; add_commits?: object[]; add_credits?: object[]; add_discounts?: discount[]; add_overrides?: object[]; add_prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration_v2; add_pro_services?: pro_service[]; add_recurring_commits?: object[]; add_recurring_credits?: object[]; add_reseller_royalties?: object[]; add_scheduled_charges?: object[]; add_spend_threshold_configuration?: spend_threshold_configuration_v2; add_subscriptions?: object[]; add_usage_filters?: object[]; archive_commits?: object[]; archive_credits?: object[]; archive_scheduled_charges?: object[]; remove_overrides?: object[]; timestamp?: string; uniqueness_key?: string; update_commits?: object[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: object[]; update_discounts?: object[]; update_prepaid_balance_threshold_configuration?: object; update_recurring_commits?: object[]; update_recurring_credits?: object[]; update_refund_invoices?: object[]; update_scheduled_charges?: object[]; update_spend_threshold_configuration?: object; update_subscriptions?: object[]; }[]; }', markdown: "## get_edit_history\n\n`client.v2.contracts.getEditHistory(contract_id: string, customer_id: string): { data: object[]; }`\n\n**post** `/v2/contracts/getEditHistory`\n\nList all the edits made to a contract over time. In Metronome, you can edit a contract at any point after it's created to fix mistakes or reflect changes in terms. Metronome stores a full history of all edits that were ever made to a contract, whether through the UI, `editContract` endpoint, or other endpoints like `updateContractEndDate`. \n\n### Use this endpoint to: \n- Understand what changes were made to a contract, when, and by who\n\n### Key response fields: \n- An array of every edit ever made to the contract\n- Details on each individual edit - for example showing that in one edit, a user added two discounts and incremented a subscription quantity.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n### Returns\n\n- `{ data: { id: string; add_commits?: { id: string; product: object; type: 'PREPAID' | 'POSTPAID'; access_schedule?: schedule_duration; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_schedule?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: commit_specifier_input[]; }[]; add_credits?: { id: string; product: object; type: 'CREDIT'; access_schedule?: schedule_duration; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: commit_specifier_input[]; }[]; add_discounts?: object[]; add_overrides?: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: object[]; override_tiers?: override_tier[]; overwrite_rate?: object; priority?: number; product?: object; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; add_prepaid_balance_threshold_configuration?: object; add_pro_services?: object[]; add_recurring_commits?: { id: string; access_amount: object; commit_duration: object; priority: number; product: object; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: object; description?: string; ending_before?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_amount?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: object; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: commit_specifier[]; subscription_config?: recurring_commit_subscription_config; }[]; add_recurring_credits?: { id: string; access_amount: object; commit_duration: object; priority: number; product: object; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: object; description?: string; ending_before?: string; hierarchy_configuration?: commit_hierarchy_configuration; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: object; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: commit_specifier[]; subscription_config?: recurring_commit_subscription_config; }[]; add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; fraction?: number; gcp_account_id?: string; gcp_offer_id?: string; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]; add_scheduled_charges?: { id: string; product: object; schedule: schedule_point_in_time; name?: string; netsuite_sales_order_id?: string; }[]; add_spend_threshold_configuration?: object; add_subscriptions?: { billing_periods: object; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: object; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: object[]; starting_at: string; subscription_rate: object; id?: string; billing_cycle_config?: object; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: object; }[]; add_usage_filters?: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; archive_commits?: { id: string; }[]; archive_credits?: { id: string; }[]; archive_scheduled_charges?: { id: string; }[]; remove_overrides?: { id: string; }[]; timestamp?: string; uniqueness_key?: string; update_commits?: { id: string; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_schedule?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: commit_specifier_input[]; }[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: { id: string; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; specifiers?: commit_specifier_input[]; }[]; update_discounts?: { id: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; schedule?: object; }[]; update_prepaid_balance_threshold_configuration?: { commit?: update_base_threshold_commit; custom_credit_type_id?: string; discount_configuration?: object; is_enabled?: boolean; payment_gate_config?: payment_gate_config_v2; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: object[]; }; update_recurring_commits?: { id: string; access_amount?: object; ending_before?: string; invoice_amount?: object; proration_rounding?: object; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_recurring_credits?: { id: string; access_amount?: object; ending_before?: string; proration_rounding?: object; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_refund_invoices?: { date: string; invoice_id: string; }[]; update_scheduled_charges?: { id: string; invoice_schedule?: object; name?: string; netsuite_sales_order_id?: string; }[]; update_spend_threshold_configuration?: { commit?: update_base_threshold_commit; discount_configuration?: object; is_enabled?: boolean; payment_gate_config?: payment_gate_config_v2; threshold_amount?: number; }; update_subscriptions?: { id: string; ending_before?: string; quantity_updates?: object[]; seat_updates?: object; }[]; }[]; }`\n\n - `data: { id: string; add_commits?: { id: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: object[]; credit_type?: credit_type_data; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; invoice_schedule?: { credit_type?: object; do_not_invoice?: boolean; schedule_items?: { id: string; timestamp: string; amount?: number; invoice_id?: string; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; add_credits?: { id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: { schedule_items: object[]; credit_type?: credit_type_data; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; add_discounts?: { id: string; product: { id: string; name: string; }; schedule: object; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; add_overrides?: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; override_tiers?: { multiplier: number; size?: number; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: object[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; add_prepaid_balance_threshold_configuration?: { commit: object; is_enabled: boolean; payment_gate_config: object; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: object; }; threshold_balance_specifiers?: { exclude: object[]; }[]; }; add_pro_services?: { id: string; max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]; add_recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: object | object | object; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: object; subscription_id: string; }; }[]; add_recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: object | object | object; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: object; subscription_id: string; }; }[]; add_reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; fraction?: number; gcp_account_id?: string; gcp_offer_id?: string; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]; add_scheduled_charges?: { id: string; product: { id: string; name: string; }; schedule: { credit_type?: credit_type_data; do_not_invoice?: boolean; schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; }[]; add_spend_threshold_configuration?: { commit: object; is_enabled: boolean; payment_gate_config: object; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: object; }; }; add_subscriptions?: { billing_periods: { current?: { ending_before: string; starting_at: string; }; next?: { ending_before: string; starting_at: string; }; previous?: { ending_before: string; starting_at: string; }; }; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: { quantity: number; starting_at: string; ending_before?: string; }[]; starting_at: string; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: { id: string; name: string; }; }; id?: string; billing_cycle_config?: { anchor_date: string; invoice_placement: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: { seat_group_key: string; }; }[]; add_usage_filters?: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; archive_commits?: { id: string; }[]; archive_credits?: { id: string; }[]; archive_scheduled_charges?: { id: string; }[]; remove_overrides?: { id: string; }[]; timestamp?: string; uniqueness_key?: string; update_commits?: { id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; update_contract_end_date?: string; update_contract_name?: string; update_credits?: { id: string; access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; name?: string; netsuite_sales_order_id?: string; priority?: number; product_id?: string; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; update_discounts?: { id: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL' | 'WEEKLY'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; }[]; update_prepaid_balance_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; custom_credit_type_id?: string; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount?: number; threshold_amount?: number; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; }; update_recurring_commits?: { id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; invoice_amount?: { quantity?: number; unit_price?: number; }; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_recurring_credits?: { id: string; access_amount?: { quantity?: number; unit_price?: number; }; ending_before?: string; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'LIST_RATE' | 'COMMIT_RATE'; }[]; update_refund_invoices?: { date: string; invoice_id: string; }[]; update_scheduled_charges?: { id: string; invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; }[]; update_spend_threshold_configuration?: { commit?: { description?: string; name?: string; priority?: number; product_id?: string; }; discount_configuration?: { cap?: { amount: number; spend_tracker_alias: string; }; payment_fraction?: number; }; is_enabled?: boolean; payment_gate_config?: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount?: number; }; update_subscriptions?: { id: string; ending_before?: string; quantity_updates?: { starting_at: string; quantity?: number; quantity_delta?: number; }[]; seat_updates?: { add_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; add_unassigned_seats?: { quantity: number; starting_at: string; }[]; remove_seat_ids?: { seat_ids: string[]; starting_at: string; }[]; remove_unassigned_seats?: { quantity: number; starting_at: string; }[]; }; }[]; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v2.contracts.getEditHistory({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.getEditHistory', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v2.contracts.getEditHistory({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(response.data);", }, python: { method: 'v2.contracts.get_edit_history', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v2.contracts.get_edit_history(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(response.data)', }, java: { method: 'v2().contracts().getEditHistory', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractGetEditHistoryParams;\nimport com.metronome.api.models.v2.contracts.ContractGetEditHistoryResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractGetEditHistoryParams params = ContractGetEditHistoryParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractGetEditHistoryResponse response = client.v2().contracts().getEditHistory(params);\n }\n}', }, go: { method: 'client.V2.Contracts.GetEditHistory', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V2.Contracts.GetEditHistory(context.TODO(), metronome.V2ContractGetEditHistoryParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v2.contracts.get_edit_history', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v2.contracts.get_edit_history(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/getEditHistory \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'edit_commit', endpoint: '/v2/contracts/commits/edit', httpMethod: 'post', summary: 'Edit a commit', description: "Edit specific details for a contract-level or customer-level commit. Use this endpoint to modify individual commit access schedules, invoice schedules, applicable products, invoicing contracts, or other fields. \n\n### Usage guidelines:\n- As with all edits in Metronome, draft invoices will reflect the edit immediately, while finalized invoices are untouched unless voided and regenerated.\n- If a commit's invoice schedule item is associated with a finalized invoice, you cannot remove or update the invoice schedule item.\n- If a commit's invoice schedule item is associated with a voided invoice, you cannot remove the invoice schedule item.\n- You cannot remove an commit access schedule segment that was applied to a finalized invoice. You can void the invoice beforehand and then remove the access schedule segment.\n", stainlessPath: '(resource) v2.contracts > (method) edit_commit', qualified: 'client.v2.contracts.editCommit', params: [ 'commit_id: string;', 'customer_id: string;', 'access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; };', 'applicable_contract_ids?: string[];', 'applicable_product_ids?: string[];', 'applicable_product_tags?: string[];', 'description?: string;', "hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; };", 'invoice_contract_id?: string;', 'invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; };', 'name?: string;', 'priority?: number;', 'product_id?: string;', "rate_type?: 'LIST_RATE' | 'COMMIT_RATE';", 'specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];', ], response: '{ data: { id: string; }; }', markdown: "## edit_commit\n\n`client.v2.contracts.editCommit(commit_id: string, customer_id: string, access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }, applicable_contract_ids?: string[], applicable_product_ids?: string[], applicable_product_tags?: string[], description?: string, hierarchy_configuration?: { child_access: object | object | object; }, invoice_contract_id?: string, invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }, name?: string, priority?: number, product_id?: string, rate_type?: 'LIST_RATE' | 'COMMIT_RATE', specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]): { data: id; }`\n\n**post** `/v2/contracts/commits/edit`\n\nEdit specific details for a contract-level or customer-level commit. Use this endpoint to modify individual commit access schedules, invoice schedules, applicable products, invoicing contracts, or other fields. \n\n### Usage guidelines:\n- As with all edits in Metronome, draft invoices will reflect the edit immediately, while finalized invoices are untouched unless voided and regenerated.\n- If a commit's invoice schedule item is associated with a finalized invoice, you cannot remove or update the invoice schedule item.\n- If a commit's invoice schedule item is associated with a voided invoice, you cannot remove the invoice schedule item.\n- You cannot remove an commit access schedule segment that was applied to a finalized invoice. You can void the invoice beforehand and then remove the access schedule segment.\n\n\n### Parameters\n\n- `commit_id: string`\n ID of the commit to edit\n\n- `customer_id: string`\n ID of the customer whose commit is being edited\n\n- `access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }`\n - `add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]`\n - `remove_schedule_items?: { id: string; }[]`\n - `update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]`\n\n- `applicable_contract_ids?: string[]`\n Which contracts the customer-level commit applies to. If set to null, the commit applies to all of the customer's contracts. This field cannot be edited for POSTPAID commits or contract-level commits.\n\n- `applicable_product_ids?: string[]`\n Which products the commit applies to. If applicable_product_ids, applicable_product_tags or specifiers are not provided, the commit applies to all products.\n\n- `applicable_product_tags?: string[]`\n Which tags the commit applies to. If applicable_product_ids, applicable_product_tags or specifiers are not provided, the commit applies to all products.\n\n- `description?: string`\n Updated description for the commit\n\n- `hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }`\n Optional configuration for commit hierarchy access control\n - `child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }`\n\n- `invoice_contract_id?: string`\n ID of contract to use for invoicing\n\n- `invoice_schedule?: { add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]; }`\n - `add_schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]`\n - `remove_schedule_items?: { id: string; }[]`\n - `update_schedule_items?: { id: string; amount?: number; quantity?: number; timestamp?: string; unit_price?: number; }[]`\n\n- `name?: string`\n Updated name for the commit\n\n- `priority?: number`\n If multiple commits are applicable, the one with the lower priority will apply first.\n\n- `product_id?: string`\n\n- `rate_type?: 'LIST_RATE' | 'COMMIT_RATE'`\n If provided, updates the commit to use the specified rate type for current and future invoices. Previously finalized invoices will need to be voided and regenerated to reflect the rate type change.\n\n- `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of filters that determine what kind of customer usage draws down a commit or credit. A customer's usage needs to meet the condition of at least one of the specifiers to contribute to a commit's or credit's drawdown. This field cannot be used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to target usage by product or product tag, pass those values in the body of `specifiers`.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v2.contracts.editCommit({ commit_id: '5e7e82cf-ccb7-428c-a96f-a8e4f67af822', customer_id: '4c91c473-fc12-445a-9c38-40421d47023f' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.editCommit', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v2.contracts.editCommit({\n commit_id: '5e7e82cf-ccb7-428c-a96f-a8e4f67af822',\n customer_id: '4c91c473-fc12-445a-9c38-40421d47023f',\n access_schedule: {\n update_schedule_items: [\n { id: 'd5edbd32-c744-48cb-9475-a9bca0e6fa39', ending_before: '2025-03-12T00:00:00Z' },\n ],\n },\n});\n\nconsole.log(response.data);", }, python: { method: 'v2.contracts.edit_commit', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v2.contracts.edit_commit(\n commit_id="5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n customer_id="4c91c473-fc12-445a-9c38-40421d47023f",\n access_schedule={\n "update_schedule_items": [{\n "id": "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n "ending_before": datetime.fromisoformat("2025-03-12T00:00:00"),\n }]\n },\n)\nprint(response.data)', }, java: { method: 'v2().contracts().editCommit', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractEditCommitParams;\nimport com.metronome.api.models.v2.contracts.ContractEditCommitResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractEditCommitParams params = ContractEditCommitParams.builder()\n .commitId("5e7e82cf-ccb7-428c-a96f-a8e4f67af822")\n .customerId("4c91c473-fc12-445a-9c38-40421d47023f")\n .build();\n ContractEditCommitResponse response = client.v2().contracts().editCommit(params);\n }\n}', }, go: { method: 'client.V2.Contracts.EditCommit', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V2.Contracts.EditCommit(context.TODO(), metronome.V2ContractEditCommitParams{\n\t\tCommitID: "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n\t\tCustomerID: "4c91c473-fc12-445a-9c38-40421d47023f",\n\t\tAccessSchedule: metronome.V2ContractEditCommitParamsAccessSchedule{\n\t\t\tUpdateScheduleItems: []metronome.V2ContractEditCommitParamsAccessScheduleUpdateScheduleItem{{\n\t\t\t\tID: "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n\t\t\t\tEndingBefore: metronome.Time(time.Now()),\n\t\t\t}},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v2.contracts.edit_commit', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v2.contracts.edit_commit(\n commit_id: "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n customer_id: "4c91c473-fc12-445a-9c38-40421d47023f"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/commits/edit \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "commit_id": "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n "customer_id": "4c91c473-fc12-445a-9c38-40421d47023f",\n "access_schedule": {\n "update_schedule_items": [\n {\n "id": "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n "ending_before": "2025-03-12T00:00:00Z"\n }\n ]\n }\n }\'', }, }, }, { name: 'edit_credit', endpoint: '/v2/contracts/credits/edit', httpMethod: 'post', summary: 'Edit a credit', description: 'Edit details for a contract-level or customer-level credit. \n\n### Use this endpoint to: \n- Extend the duration or the amount of an existing free credit like a trial \n- Modify individual credit access schedules, applicable products, priority, or other fields. \n\n### Usage guidelines:\n- As with all edits in Metronome, draft invoices will reflect the edit immediately, while finalized invoices are untouched unless voided and regenerated. \n- You cannot remove an access schedule segment that was applied to a finalized invoice. You can void the invoice beforehand and then remove the access schedule segment.\n', stainlessPath: '(resource) v2.contracts > (method) edit_credit', qualified: 'client.v2.contracts.editCredit', params: [ 'credit_id: string;', 'customer_id: string;', 'access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; };', 'applicable_contract_ids?: string[];', 'applicable_product_ids?: string[];', 'applicable_product_tags?: string[];', 'description?: string;', "hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; };", 'name?: string;', 'priority?: number;', 'product_id?: string;', "rate_type?: 'LIST_RATE' | 'COMMIT_RATE';", 'specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];', ], response: '{ data: { id: string; }; }', markdown: "## edit_credit\n\n`client.v2.contracts.editCredit(credit_id: string, customer_id: string, access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }, applicable_contract_ids?: string[], applicable_product_ids?: string[], applicable_product_tags?: string[], description?: string, hierarchy_configuration?: { child_access: object | object | object; }, name?: string, priority?: number, product_id?: string, rate_type?: 'LIST_RATE' | 'COMMIT_RATE', specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]): { data: id; }`\n\n**post** `/v2/contracts/credits/edit`\n\nEdit details for a contract-level or customer-level credit. \n\n### Use this endpoint to: \n- Extend the duration or the amount of an existing free credit like a trial \n- Modify individual credit access schedules, applicable products, priority, or other fields. \n\n### Usage guidelines:\n- As with all edits in Metronome, draft invoices will reflect the edit immediately, while finalized invoices are untouched unless voided and regenerated. \n- You cannot remove an access schedule segment that was applied to a finalized invoice. You can void the invoice beforehand and then remove the access schedule segment.\n\n\n### Parameters\n\n- `credit_id: string`\n ID of the credit to edit\n\n- `customer_id: string`\n ID of the customer whose credit is being edited\n\n- `access_schedule?: { add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]; remove_schedule_items?: { id: string; }[]; update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]; }`\n - `add_schedule_items?: { amount: number; ending_before: string; starting_at: string; }[]`\n - `remove_schedule_items?: { id: string; }[]`\n - `update_schedule_items?: { id: string; amount?: number; ending_before?: string; starting_at?: string; }[]`\n\n- `applicable_contract_ids?: string[]`\n Which contracts the customer-level credit applies to. If set to null, the credit applies to all of the customer's contracts. This field cannot be set on a contract-level credit.\n\n- `applicable_product_ids?: string[]`\n Which products the credit applies to. If both applicable_product_ids and applicable_product_tags are not provided, the credit applies to all products.\n\n- `applicable_product_tags?: string[]`\n Which tags the credit applies to. If both applicable_product_ids and applicable_product_tags are not provided, the credit applies to all products.\n\n- `description?: string`\n Updated description for the credit\n\n- `hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }`\n Optional configuration for credit hierarchy access control\n - `child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }`\n\n- `name?: string`\n Updated name for the credit\n\n- `priority?: number`\n If multiple commits are applicable, the one with the lower priority will apply first.\n\n- `product_id?: string`\n\n- `rate_type?: 'LIST_RATE' | 'COMMIT_RATE'`\n If provided, updates the credit to use the specified rate type for current and future invoices. Previously finalized invoices will need to be voided and regenerated to reflect the rate type change.\n\n- `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of filters that determine what kind of customer usage draws down a commit or credit. A customer's usage needs to meet the condition of at least one of the specifiers to contribute to a commit's or credit's drawdown. This field cannot be used together with `applicable_product_ids` or `applicable_product_tags`. Instead, to target usage by product or product tag, pass those values in the body of `specifiers`.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v2.contracts.editCredit({ credit_id: '5e7e82cf-ccb7-428c-a96f-a8e4f67af822', customer_id: '4c91c473-fc12-445a-9c38-40421d47023f' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v2.contracts.editCredit', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v2.contracts.editCredit({\n credit_id: '5e7e82cf-ccb7-428c-a96f-a8e4f67af822',\n customer_id: '4c91c473-fc12-445a-9c38-40421d47023f',\n access_schedule: {\n update_schedule_items: [\n { id: 'd5edbd32-c744-48cb-9475-a9bca0e6fa39', ending_before: '2025-03-12T00:00:00Z' },\n ],\n },\n});\n\nconsole.log(response.data);", }, python: { method: 'v2.contracts.edit_credit', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v2.contracts.edit_credit(\n credit_id="5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n customer_id="4c91c473-fc12-445a-9c38-40421d47023f",\n access_schedule={\n "update_schedule_items": [{\n "id": "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n "ending_before": datetime.fromisoformat("2025-03-12T00:00:00"),\n }]\n },\n)\nprint(response.data)', }, java: { method: 'v2().contracts().editCredit', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v2.contracts.ContractEditCreditParams;\nimport com.metronome.api.models.v2.contracts.ContractEditCreditResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractEditCreditParams params = ContractEditCreditParams.builder()\n .creditId("5e7e82cf-ccb7-428c-a96f-a8e4f67af822")\n .customerId("4c91c473-fc12-445a-9c38-40421d47023f")\n .build();\n ContractEditCreditResponse response = client.v2().contracts().editCredit(params);\n }\n}', }, go: { method: 'client.V2.Contracts.EditCredit', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V2.Contracts.EditCredit(context.TODO(), metronome.V2ContractEditCreditParams{\n\t\tCreditID: "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n\t\tCustomerID: "4c91c473-fc12-445a-9c38-40421d47023f",\n\t\tAccessSchedule: metronome.V2ContractEditCreditParamsAccessSchedule{\n\t\t\tUpdateScheduleItems: []metronome.V2ContractEditCreditParamsAccessScheduleUpdateScheduleItem{{\n\t\t\t\tID: "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n\t\t\t\tEndingBefore: metronome.Time(time.Now()),\n\t\t\t}},\n\t\t},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v2.contracts.edit_credit', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v2.contracts.edit_credit(\n credit_id: "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n customer_id: "4c91c473-fc12-445a-9c38-40421d47023f"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v2/contracts/credits/edit \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "credit_id": "5e7e82cf-ccb7-428c-a96f-a8e4f67af822",\n "customer_id": "4c91c473-fc12-445a-9c38-40421d47023f",\n "access_schedule": {\n "update_schedule_items": [\n {\n "id": "d5edbd32-c744-48cb-9475-a9bca0e6fa39",\n "ending_before": "2025-03-12T00:00:00Z"\n }\n ]\n }\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/alerts/archive', httpMethod: 'post', summary: 'Archive a threshold notification', description: "Permanently disable a threshold notification and remove it from active monitoring across all customers. Archived threshold notifications stop evaluating immediately and can optionally release their uniqueness key for reuse in future threshold notification configurations.\n\n### Use this endpoint to:\n- Decommission threshold notifications that are no longer needed\n- Clean up test or deprecated threshold notification configurations\n- Free up uniqueness keys for reuse with new threshold notifications\n- Stop threshold notification evaluations without losing historical configuration data\n- Disable outdated monitoring rules during pricing model transitions\n\n### Key response fields:\n- data: Object containing the archived threshold notification's ID\n\n### Usage guidelines:\n- Irreversible for evaluation: Archived threshold notifications cannot be re-enabled; create a new threshold notification to resume monitoring\n- Uniqueness key handling: Set `release_uniqueness_key` : `true` to reuse the key in future threshold notifications\n- Immediate effect: Threshold notification evaluation stops instantly across all customers\n- Historical preservation: Archive operation maintains threshold notification history and configuration for compliance and auditing\n", stainlessPath: '(resource) v1.alerts > (method) archive', qualified: 'client.v1.alerts.archive', params: ['id: string;', 'release_uniqueness_key?: boolean;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.alerts.archive(id: string, release_uniqueness_key?: boolean): { data: id; }`\n\n**post** `/v1/alerts/archive`\n\nPermanently disable a threshold notification and remove it from active monitoring across all customers. Archived threshold notifications stop evaluating immediately and can optionally release their uniqueness key for reuse in future threshold notification configurations.\n\n### Use this endpoint to:\n- Decommission threshold notifications that are no longer needed\n- Clean up test or deprecated threshold notification configurations\n- Free up uniqueness keys for reuse with new threshold notifications\n- Stop threshold notification evaluations without losing historical configuration data\n- Disable outdated monitoring rules during pricing model transitions\n\n### Key response fields:\n- data: Object containing the archived threshold notification's ID\n\n### Usage guidelines:\n- Irreversible for evaluation: Archived threshold notifications cannot be re-enabled; create a new threshold notification to resume monitoring\n- Uniqueness key handling: Set `release_uniqueness_key` : `true` to reuse the key in future threshold notifications\n- Immediate effect: Threshold notification evaluation stops instantly across all customers\n- Historical preservation: Archive operation maintains threshold notification history and configuration for compliance and auditing\n\n\n### Parameters\n\n- `id: string`\n The Metronome ID of the threshold notification\n\n- `release_uniqueness_key?: boolean`\n If true, resets the uniqueness key on this threshold notification so it can be re-used\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.alerts.archive({ id: '8deed800-1b7a-495d-a207-6c52bac54dc9' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.alerts.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.alerts.archive({ id: '8deed800-1b7a-495d-a207-6c52bac54dc9' });\n\nconsole.log(response.data);", }, python: { method: 'v1.alerts.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.alerts.archive(\n id="8deed800-1b7a-495d-a207-6c52bac54dc9",\n)\nprint(response.data)', }, java: { method: 'v1().alerts().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.alerts.AlertArchiveParams;\nimport com.metronome.api.models.v1.alerts.AlertArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AlertArchiveParams params = AlertArchiveParams.builder()\n .id("8deed800-1b7a-495d-a207-6c52bac54dc9")\n .build();\n AlertArchiveResponse response = client.v1().alerts().archive(params);\n }\n}', }, go: { method: 'client.V1.Alerts.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Alerts.Archive(context.TODO(), metronome.V1AlertArchiveParams{\n\t\tID: "8deed800-1b7a-495d-a207-6c52bac54dc9",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.alerts.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.alerts.archive(id: "8deed800-1b7a-495d-a207-6c52bac54dc9")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/alerts/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "8deed800-1b7a-495d-a207-6c52bac54dc9"\n }\'', }, }, }, { name: 'create', endpoint: '/v1/alerts/create', httpMethod: 'post', summary: 'Create a threshold notification', description: "Create a new threshold notification to monitor customer spending, balances, and billing metrics in real-time. Metronome's notification system provides industry-leading speed with immediate evaluation capabilities, enabling you to proactively manage customer accounts and prevent revenue leakage.\n\nThis endpoint creates configurable threshold notifications that continuously monitor various billing thresholds including spend limits, credit balances, commitment utilization, and invoice totals. Threshold notifications can be configured globally for all customers or targeted to specific customer accounts.\n\n### Use this endpoint to:\n- Proactively monitor customer spending patterns to prevent unexpected overages or credit exhaustion\n- Automate notifications when customers approach commitment limits or credit thresholds\n- Enable real-time intervention for accounts at risk of churn or payment issues\n- Scale billing operations by automating threshold-based workflows and notifications\n\n### Key response fields: \nA successful response returns a CustomerAlert object containing:\n\n- The threshold notification configuration with its unique ID and current status\n- The customer's evaluation status (ok, in_alarm, or evaluating)\n- Threshold notification metadata including type, threshold values, and update timestamps\n\n### Usage guidelines:\n- Immediate evaluation: Set `evaluate_on_create` : `true` (default) for instant evaluation against existing customers\n- Uniqueness constraints: Each threshold notification must have a unique `uniqueness_key` within your organization. Use `release_uniqueness_key` : `true` when archiving to reuse keys\n- Notification type requirements: Different threshold notification types require specific fields (e.g., `billable_metric_id` for usage notifications, `credit_type_id` for credit-based threshold notifications)\n- Webhook delivery: Threshold notifications trigger webhook notifications for real-time integration with your systems. Configure webhook endpoints before creating threshold notifications\n- Performance at scale: Metronome's event-driven architecture processes threshold notification evaluations in real-time as usage events stream in, unlike competitors who rely on periodic polling or batch evaluation cycles\n", stainlessPath: '(resource) v1.alerts > (method) create', qualified: 'client.v1.alerts.create', params: [ 'alert_type: string;', 'name: string;', 'threshold: number;', "alert_specifiers?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value?: string; }[]; exclude?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[];", 'billable_metric_id?: string;', 'credit_grant_type_filters?: string[];', 'credit_type_id?: string;', "custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[];", 'customer_id?: string;', 'evaluate_on_create?: boolean;', 'group_values?: { key: string; value?: string; }[];', 'invoice_types_filter?: string[];', 'plan_id?: string;', 'seat_filter?: { seat_group_key: string; seat_group_value?: string; };', 'uniqueness_key?: string;', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.alerts.create(alert_type: string, name: string, threshold: number, alert_specifiers?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value?: string; }[]; exclude?: { custom_field_filters?: object[]; }[]; }[], billable_metric_id?: string, credit_grant_type_filters?: string[], credit_type_id?: string, custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[], customer_id?: string, evaluate_on_create?: boolean, group_values?: { key: string; value?: string; }[], invoice_types_filter?: string[], plan_id?: string, seat_filter?: { seat_group_key: string; seat_group_value?: string; }, uniqueness_key?: string): { data: id; }`\n\n**post** `/v1/alerts/create`\n\nCreate a new threshold notification to monitor customer spending, balances, and billing metrics in real-time. Metronome's notification system provides industry-leading speed with immediate evaluation capabilities, enabling you to proactively manage customer accounts and prevent revenue leakage.\n\nThis endpoint creates configurable threshold notifications that continuously monitor various billing thresholds including spend limits, credit balances, commitment utilization, and invoice totals. Threshold notifications can be configured globally for all customers or targeted to specific customer accounts.\n\n### Use this endpoint to:\n- Proactively monitor customer spending patterns to prevent unexpected overages or credit exhaustion\n- Automate notifications when customers approach commitment limits or credit thresholds\n- Enable real-time intervention for accounts at risk of churn or payment issues\n- Scale billing operations by automating threshold-based workflows and notifications\n\n### Key response fields: \nA successful response returns a CustomerAlert object containing:\n\n- The threshold notification configuration with its unique ID and current status\n- The customer's evaluation status (ok, in_alarm, or evaluating)\n- Threshold notification metadata including type, threshold values, and update timestamps\n\n### Usage guidelines:\n- Immediate evaluation: Set `evaluate_on_create` : `true` (default) for instant evaluation against existing customers\n- Uniqueness constraints: Each threshold notification must have a unique `uniqueness_key` within your organization. Use `release_uniqueness_key` : `true` when archiving to reuse keys\n- Notification type requirements: Different threshold notification types require specific fields (e.g., `billable_metric_id` for usage notifications, `credit_type_id` for credit-based threshold notifications)\n- Webhook delivery: Threshold notifications trigger webhook notifications for real-time integration with your systems. Configure webhook endpoints before creating threshold notifications\n- Performance at scale: Metronome's event-driven architecture processes threshold notification evaluations in real-time as usage events stream in, unlike competitors who rely on periodic polling or batch evaluation cycles\n\n\n### Parameters\n\n- `alert_type: string`\n Type of the threshold notification\n\n- `name: string`\n Name of the threshold notification\n\n- `threshold: number`\n Threshold value of the notification policy. Depending upon the notification type, this number may represent a financial amount, the days remaining, or a percentage reached.\n\n- `alert_specifiers?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value?: string; }[]; exclude?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` notifications. Defines the balances that are considered when evaluating the alert.\n\n- `billable_metric_id?: string`\n For threshold notifications of type `usage_threshold_reached`, specifies which billable metric to track the usage for.\n\n- `credit_grant_type_filters?: string[]`\n An array of strings, representing a way to filter the credit grant this threshold notification applies to, by looking at the credit_grant_type field on the credit grant. This field is only defined for CreditPercentage and CreditBalance notifications\n\n- `credit_type_id?: string`\n ID of the credit's currency, defaults to USD. If the specific notification type requires a pricing unit/currency, find the ID in the [Metronome app](https://app.metronome.com/offering/pricing-units).\n\n- `custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]`\n A list of custom field filters for threshold notification types that support advanced filtering. Only present for contract invoices.\n\n- `customer_id?: string`\n If provided, will create this threshold notification for this specific customer. To create a notification for all customers, do not specify a `customer_id`.\n\n- `evaluate_on_create?: boolean`\n If true, the threshold notification will evaluate immediately on customers that already meet the notification threshold. If false, it will only evaluate on future customers that trigger the threshold. Defaults to true.\n\n- `group_values?: { key: string; value?: string; }[]`\n Only present for `spend_threshold_reached` notifications. Scope notification to a specific group key on individual line items.\n\n- `invoice_types_filter?: string[]`\n Only supported for invoice_total_reached threshold notifications. A list of invoice types to evaluate.\n\n- `plan_id?: string`\n If provided, will create this threshold notification for this specific plan. To create a notification for all customers, do not specify a `plan_id`.\n\n- `seat_filter?: { seat_group_key: string; seat_group_value?: string; }`\n Required for `low_remaining_seat_balance_reached` notifications. The alert is scoped to this seat group key-value pair.\n - `seat_group_key: string`\n The seat group key (e.g., \"seat_id\", \"user_id\")\n - `seat_group_value?: string`\n Optional seat identifier the alert is scoped to.\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst alert = await client.v1.alerts.create({\n alert_type: 'spend_threshold_reached',\n name: '$100 spend threshold reached',\n threshold: 10000,\n});\n\nconsole.log(alert);\n```", perLanguage: { typescript: { method: 'client.v1.alerts.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst alert = await client.v1.alerts.create({\n alert_type: 'spend_threshold_reached',\n name: '$100 spend threshold reached',\n threshold: 10000,\n credit_grant_type_filters: ['enterprise'],\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n});\n\nconsole.log(alert.data);", }, python: { method: 'v1.alerts.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nalert = client.v1.alerts.create(\n alert_type="spend_threshold_reached",\n name="$100 spend threshold reached",\n threshold=10000,\n credit_grant_type_filters=["enterprise"],\n credit_type_id="2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n customer_id="4db51251-61de-4bfe-b9ce-495e244f3491",\n)\nprint(alert.data)', }, java: { method: 'v1().alerts().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.alerts.AlertCreateParams;\nimport com.metronome.api.models.v1.alerts.AlertCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AlertCreateParams params = AlertCreateParams.builder()\n .alertType(AlertCreateParams.AlertType.SPEND_THRESHOLD_REACHED)\n .name("$100 spend threshold reached")\n .threshold(10000.0)\n .build();\n AlertCreateResponse alert = client.v1().alerts().create(params);\n }\n}', }, go: { method: 'client.V1.Alerts.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\talert, err := client.V1.Alerts.New(context.TODO(), metronome.V1AlertNewParams{\n\t\tAlertType: metronome.V1AlertNewParamsAlertTypeSpendThresholdReached,\n\t\tName: "$100 spend threshold reached",\n\t\tThreshold: 10000,\n\t\tCreditGrantTypeFilters: []string{"enterprise"},\n\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\tCustomerID: metronome.String("4db51251-61de-4bfe-b9ce-495e244f3491"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", alert.Data)\n}\n', }, ruby: { method: 'v1.alerts.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nalert = metronome.v1.alerts.create(\n alert_type: :spend_threshold_reached,\n name: "$100 spend threshold reached",\n threshold: 10000\n)\n\nputs(alert)', }, http: { example: 'curl https://api.metronome.com/v1/alerts/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "alert_type": "spend_threshold_reached",\n "name": "$100 spend threshold reached",\n "threshold": 10000,\n "credit_grant_type_filters": [\n "enterprise"\n ],\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/plans', httpMethod: 'get', summary: 'List plans', description: 'List all available plans. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.', stainlessPath: '(resource) v1.plans > (method) list', qualified: 'client.v1.plans.list', params: ['limit?: number;', 'next_page?: string;'], response: '{ id: string; description: string; name: string; custom_fields?: object; }', markdown: "## list\n\n`client.v1.plans.list(limit?: number, next_page?: string): { id: string; description: string; name: string; custom_fields?: object; }`\n\n**get** `/v1/plans`\n\nList all available plans. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n### Parameters\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ id: string; description: string; name: string; custom_fields?: object; }`\n\n - `id: string`\n - `description: string`\n - `name: string`\n - `custom_fields?: object`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const planListResponse of client.v1.plans.list()) {\n console.log(planListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.plans.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const planListResponse of client.v1.plans.list()) {\n console.log(planListResponse.id);\n}", }, python: { method: 'v1.plans.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.plans.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().plans().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.plans.PlanListPage;\nimport com.metronome.api.models.v1.plans.PlanListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanListPage page = client.v1().plans().list();\n }\n}', }, go: { method: 'client.V1.Plans.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Plans.List(context.TODO(), metronome.V1PlanListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.plans.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.plans.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/plans \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'get_details', endpoint: '/v1/planDetails/{plan_id}', httpMethod: 'get', summary: 'Get plan details', description: 'Fetch high level details of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.plans > (method) get_details', qualified: 'client.v1.plans.getDetails', params: ['plan_id: string;'], response: '{ data: { id: string; custom_fields: object; name: string; credit_grants?: object[]; description?: string; minimums?: object[]; overage_rates?: object[]; }; }', markdown: "## get_details\n\n`client.v1.plans.getDetails(plan_id: string): { data: plan_detail; }`\n\n**get** `/v1/planDetails/{plan_id}`\n\nFetch high level details of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `plan_id: string`\n\n### Returns\n\n- `{ data: { id: string; custom_fields: object; name: string; credit_grants?: object[]; description?: string; minimums?: object[]; overage_rates?: object[]; }; }`\n\n - `data: { id: string; custom_fields: object; name: string; credit_grants?: { amount_granted: number; amount_granted_credit_type: object; amount_paid: number; amount_paid_credit_type: object; effective_duration: number; name: string; priority: string; send_invoice: boolean; reason?: string; recurrence_duration?: number; recurrence_interval?: number; }[]; description?: string; minimums?: { credit_type: object; name: string; start_period: number; value: number; }[]; overage_rates?: { credit_type: object; fiat_credit_type: object; start_period: number; to_fiat_conversion_factor: number; }[]; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.plans.getDetails({ plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.plans.getDetails', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.plans.getDetails({\n plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.plans.get_details', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.plans.get_details(\n plan_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(response.data)', }, java: { method: 'v1().plans().getDetails', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.plans.PlanGetDetailsParams;\nimport com.metronome.api.models.v1.plans.PlanGetDetailsResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanGetDetailsParams params = PlanGetDetailsParams.builder()\n .planId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PlanGetDetailsResponse response = client.v1().plans().getDetails(params);\n }\n}', }, go: { method: 'client.V1.Plans.GetDetails', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Plans.GetDetails(context.TODO(), metronome.V1PlanGetDetailsParams{\n\t\tPlanID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.plans.get_details', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.plans.get_details(plan_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/planDetails/$PLAN_ID \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_customers', endpoint: '/v1/planDetails/{plan_id}/customers', httpMethod: 'get', summary: 'List customers on a plan', description: 'Fetches a list of customers on a specific plan (by default, only currently active plans are included). This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.plans > (method) list_customers', qualified: 'client.v1.plans.listCustomers', params: [ 'plan_id: string;', 'limit?: number;', 'next_page?: string;', "status?: 'all' | 'active' | 'ended' | 'upcoming';", ], response: '{ customer_details: { id: string; created_at: string; custom_fields: object; customer_config: object; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: object; }; plan_details: { id: string; custom_fields: object; customer_plan_id: string; name: string; starting_on: string; ending_before?: string; }; }', markdown: "## list_customers\n\n`client.v1.plans.listCustomers(plan_id: string, limit?: number, next_page?: string, status?: 'all' | 'active' | 'ended' | 'upcoming'): { customer_details: customer_detail; plan_details: object; }`\n\n**get** `/v1/planDetails/{plan_id}/customers`\n\nFetches a list of customers on a specific plan (by default, only currently active plans are included). This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `plan_id: string`\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `status?: 'all' | 'active' | 'ended' | 'upcoming'`\n Status of customers on a given plan. Defaults to `active`.\n\n* `all` - Return current, past, and upcoming customers of the plan.\n* `active` - Return current customers of the plan.\n* `ended` - Return past customers of the plan.\n* `upcoming` - Return upcoming customers of the plan.\n\nMultiple statuses can be OR'd together using commas, e.g. `active,ended`.\n**Note:** `ended,upcoming` combination is not yet supported.\n\n### Returns\n\n- `{ customer_details: { id: string; created_at: string; custom_fields: object; customer_config: object; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: object; }; plan_details: { id: string; custom_fields: object; customer_plan_id: string; name: string; starting_on: string; ending_before?: string; }; }`\n\n - `customer_details: { id: string; created_at: string; custom_fields: object; customer_config: { salesforce_account_id: string; }; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: { value: 'billable' | 'unbillable'; effective_at?: string; }; }`\n - `plan_details: { id: string; custom_fields: object; customer_plan_id: string; name: string; starting_on: string; ending_before?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const planListCustomersResponse of client.v1.plans.listCustomers({ plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })) {\n console.log(planListCustomersResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.plans.listCustomers', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const planListCustomersResponse of client.v1.plans.listCustomers({\n plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n})) {\n console.log(planListCustomersResponse.customer_details);\n}", }, python: { method: 'v1.plans.list_customers', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.plans.list_customers(\n plan_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\npage = page.data[0]\nprint(page.customer_details)', }, java: { method: 'v1().plans().listCustomers', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.plans.PlanListCustomersPage;\nimport com.metronome.api.models.v1.plans.PlanListCustomersParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanListCustomersParams params = PlanListCustomersParams.builder()\n .planId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PlanListCustomersPage page = client.v1().plans().listCustomers(params);\n }\n}', }, go: { method: 'client.V1.Plans.ListCustomers', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Plans.ListCustomers(context.TODO(), metronome.V1PlanListCustomersParams{\n\t\tPlanID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.plans.list_customers', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.plans.list_customers(plan_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/planDetails/$PLAN_ID/customers \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_charges', endpoint: '/v1/planDetails/{plan_id}/charges', httpMethod: 'get', summary: 'List plan charges', description: 'Fetches a list of charges of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.plans > (method) list_charges', qualified: 'client.v1.plans.listCharges', params: ['plan_id: string;', 'limit?: number;', 'next_page?: string;'], response: "{ id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; credit_type: { id: string; name: string; }; custom_fields: object; name: string; prices: { tier: number; value: number; collection_interval?: number; collection_schedule?: string; quantity?: number; }[]; product_id: string; product_name: string; quantity?: number; start_period?: number; tier_reset_frequency?: number; unit_conversion?: { division_factor: number; rounding_behavior?: 'floor' | 'ceiling'; }; }", markdown: "## list_charges\n\n`client.v1.plans.listCharges(plan_id: string, limit?: number, next_page?: string): { id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; credit_type: credit_type_data; custom_fields: object; name: string; prices: object[]; product_id: string; product_name: string; quantity?: number; start_period?: number; tier_reset_frequency?: number; unit_conversion?: object; }`\n\n**get** `/v1/planDetails/{plan_id}/charges`\n\nFetches a list of charges of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `plan_id: string`\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; credit_type: { id: string; name: string; }; custom_fields: object; name: string; prices: { tier: number; value: number; collection_interval?: number; collection_schedule?: string; quantity?: number; }[]; product_id: string; product_name: string; quantity?: number; start_period?: number; tier_reset_frequency?: number; unit_conversion?: { division_factor: number; rounding_behavior?: 'floor' | 'ceiling'; }; }`\n\n - `id: string`\n - `charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'`\n - `credit_type: { id: string; name: string; }`\n - `custom_fields: object`\n - `name: string`\n - `prices: { tier: number; value: number; collection_interval?: number; collection_schedule?: string; quantity?: number; }[]`\n - `product_id: string`\n - `product_name: string`\n - `quantity?: number`\n - `start_period?: number`\n - `tier_reset_frequency?: number`\n - `unit_conversion?: { division_factor: number; rounding_behavior?: 'floor' | 'ceiling'; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const planListChargesResponse of client.v1.plans.listCharges({ plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })) {\n console.log(planListChargesResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.plans.listCharges', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const planListChargesResponse of client.v1.plans.listCharges({\n plan_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n})) {\n console.log(planListChargesResponse.id);\n}", }, python: { method: 'v1.plans.list_charges', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.plans.list_charges(\n plan_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().plans().listCharges', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.plans.PlanListChargesPage;\nimport com.metronome.api.models.v1.plans.PlanListChargesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanListChargesParams params = PlanListChargesParams.builder()\n .planId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PlanListChargesPage page = client.v1().plans().listCharges(params);\n }\n}', }, go: { method: 'client.V1.Plans.ListCharges', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Plans.ListCharges(context.TODO(), metronome.V1PlanListChargesParams{\n\t\tPlanID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.plans.list_charges', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.plans.list_charges(plan_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/planDetails/$PLAN_ID/charges \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/credits/createGrant', httpMethod: 'post', summary: 'Create a credit grant', description: 'Create a new credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.credit_grants > (method) create', qualified: 'client.v1.creditGrants.create', params: [ 'customer_id: string;', 'expires_at: string;', 'grant_amount: { amount: number; credit_type_id: string; };', 'name: string;', 'paid_amount: { amount: number; credit_type_id: string; };', 'priority: number;', 'credit_grant_type?: string;', 'custom_fields?: object;', 'effective_at?: string;', 'invoice_date?: string;', 'product_ids?: string[];', 'reason?: string;', "rollover_settings?: { expires_at: string; priority: number; rollover_amount: { type: 'MAX_PERCENTAGE'; value: number; } | { type: 'MAX_AMOUNT'; value: number; }; };", 'uniqueness_key?: string;', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.creditGrants.create(customer_id: string, expires_at: string, grant_amount: { amount: number; credit_type_id: string; }, name: string, paid_amount: { amount: number; credit_type_id: string; }, priority: number, credit_grant_type?: string, custom_fields?: object, effective_at?: string, invoice_date?: string, product_ids?: string[], reason?: string, rollover_settings?: { expires_at: string; priority: number; rollover_amount: object | object; }, uniqueness_key?: string): { data: id; }`\n\n**post** `/v1/credits/createGrant`\n\nCreate a new credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n the Metronome ID of the customer\n\n- `expires_at: string`\n The credit grant will only apply to usage or charges dated before this timestamp\n\n- `grant_amount: { amount: number; credit_type_id: string; }`\n the amount of credits granted\n - `amount: number`\n - `credit_type_id: string`\n the ID of the pricing unit to be used. Defaults to USD (cents) if not passed.\n\n- `name: string`\n the name of the credit grant as it will appear on invoices\n\n- `paid_amount: { amount: number; credit_type_id: string; }`\n the amount paid for this credit grant\n - `amount: number`\n - `credit_type_id: string`\n the ID of the pricing unit to be used. Defaults to USD (cents) if not passed.\n\n- `priority: number`\n\n- `credit_grant_type?: string`\n\n- `custom_fields?: object`\n Custom fields to attach to the credit grant.\n\n- `effective_at?: string`\n The credit grant will only apply to usage or charges dated on or after this timestamp\n\n- `invoice_date?: string`\n The date to issue an invoice for the paid_amount.\n\n- `product_ids?: string[]`\n The product(s) which these credits will be applied to. (If unspecified, the credits will be applied to charges for all products.). The array ordering specified here will be used to determine the order in which credits will be applied to invoice line items\n\n- `reason?: string`\n\n- `rollover_settings?: { expires_at: string; priority: number; rollover_amount: { type: 'MAX_PERCENTAGE'; value: number; } | { type: 'MAX_AMOUNT'; value: number; }; }`\n Configure a rollover for this credit grant so if it expires it rolls over a configured amount to a new credit grant. This feature is currently opt-in only. Contact Metronome to be added to the beta.\n - `expires_at: string`\n The date to expire the rollover credits.\n - `priority: number`\n The priority to give the rollover credit grant that gets created when a rollover happens.\n - `rollover_amount: { type: 'MAX_PERCENTAGE'; value: number; } | { type: 'MAX_AMOUNT'; value: number; }`\n Specify how much to rollover to the rollover credit grant\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst creditGrant = await client.v1.creditGrants.create({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n expires_at: '2022-04-01T00:00:00Z',\n grant_amount: { amount: 1000, credit_type_id: '5ae401dc-a648-4b49-9ac3-391bb5bc4d7b' },\n name: 'Acme Corp Promotional Credit Grant',\n paid_amount: { amount: 5000, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2' },\n priority: 0.5,\n});\n\nconsole.log(creditGrant);\n```", perLanguage: { typescript: { method: 'client.v1.creditGrants.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst creditGrant = await client.v1.creditGrants.create({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n expires_at: '2022-04-01T00:00:00Z',\n grant_amount: { amount: 1000, credit_type_id: '5ae401dc-a648-4b49-9ac3-391bb5bc4d7b' },\n name: 'Acme Corp Promotional Credit Grant',\n paid_amount: { amount: 5000, credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2' },\n priority: 0.5,\n credit_grant_type: 'trial',\n effective_at: '2022-02-01T00:00:00Z',\n reason: 'Incentivize new customer',\n});\n\nconsole.log(creditGrant.data);", }, python: { method: 'v1.credit_grants.create', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncredit_grant = client.v1.credit_grants.create(\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n expires_at=datetime.fromisoformat("2022-04-01T00:00:00"),\n grant_amount={\n "amount": 1000,\n "credit_type_id": "5ae401dc-a648-4b49-9ac3-391bb5bc4d7b",\n },\n name="Acme Corp Promotional Credit Grant",\n paid_amount={\n "amount": 5000,\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n },\n priority=0.5,\n credit_grant_type="trial",\n effective_at=datetime.fromisoformat("2022-02-01T00:00:00"),\n reason="Incentivize new customer",\n)\nprint(credit_grant.data)', }, java: { method: 'v1().creditGrants().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantCreateParams;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantCreateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditGrantCreateParams params = CreditGrantCreateParams.builder()\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .expiresAt(OffsetDateTime.parse("2022-04-01T00:00:00Z"))\n .grantAmount(CreditGrantCreateParams.GrantAmount.builder()\n .amount(1000.0)\n .creditTypeId("5ae401dc-a648-4b49-9ac3-391bb5bc4d7b")\n .build())\n .name("Acme Corp Promotional Credit Grant")\n .paidAmount(CreditGrantCreateParams.PaidAmount.builder()\n .amount(5000.0)\n .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2")\n .build())\n .priority(0.5)\n .build();\n CreditGrantCreateResponse creditGrant = client.v1().creditGrants().create(params);\n }\n}', }, go: { method: 'client.V1.CreditGrants.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcreditGrant, err := client.V1.CreditGrants.New(context.TODO(), metronome.V1CreditGrantNewParams{\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tExpiresAt: time.Now(),\n\t\tGrantAmount: metronome.V1CreditGrantNewParamsGrantAmount{\n\t\t\tAmount: 1000,\n\t\t\tCreditTypeID: "5ae401dc-a648-4b49-9ac3-391bb5bc4d7b",\n\t\t},\n\t\tName: "Acme Corp Promotional Credit Grant",\n\t\tPaidAmount: metronome.V1CreditGrantNewParamsPaidAmount{\n\t\t\tAmount: 5000,\n\t\t\tCreditTypeID: "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n\t\t},\n\t\tPriority: 0.5,\n\t\tCreditGrantType: metronome.String("trial"),\n\t\tEffectiveAt: metronome.Time(time.Now()),\n\t\tReason: metronome.String("Incentivize new customer"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", creditGrant.Data)\n}\n', }, ruby: { method: 'v1.credit_grants.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncredit_grant = metronome.v1.credit_grants.create(\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n expires_at: "2022-04-01T00:00:00Z",\n grant_amount: {amount: 1000, credit_type_id: "5ae401dc-a648-4b49-9ac3-391bb5bc4d7b"},\n name: "Acme Corp Promotional Credit Grant",\n paid_amount: {amount: 5000, credit_type_id: "2714e483-4ff1-48e4-9e25-ac732e8f24f2"},\n priority: 0.5\n)\n\nputs(credit_grant)', }, http: { example: 'curl https://api.metronome.com/v1/credits/createGrant \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "expires_at": "2022-04-01T00:00:00Z",\n "grant_amount": {\n "amount": 1000,\n "credit_type_id": "5ae401dc-a648-4b49-9ac3-391bb5bc4d7b"\n },\n "name": "Acme Corp Promotional Credit Grant",\n "paid_amount": {\n "amount": 5000,\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2"\n },\n "priority": 0.5,\n "credit_grant_type": "trial",\n "effective_at": "2022-02-01T00:00:00Z",\n "reason": "Incentivize new customer"\n }\'', }, }, }, { name: 'edit', endpoint: '/v1/credits/editGrant', httpMethod: 'post', summary: 'Update a credit grant', description: 'Edit an existing credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.credit_grants > (method) edit', qualified: 'client.v1.creditGrants.edit', params: ['id: string;', 'credit_grant_type?: string;', 'expires_at?: string;', 'name?: string;'], response: '{ data: { id: string; }; }', markdown: "## edit\n\n`client.v1.creditGrants.edit(id: string, credit_grant_type?: string, expires_at?: string, name?: string): { data: id; }`\n\n**post** `/v1/credits/editGrant`\n\nEdit an existing credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `id: string`\n the ID of the credit grant\n\n- `credit_grant_type?: string`\n the updated credit grant type\n\n- `expires_at?: string`\n the updated expiration date for the credit grant\n\n- `name?: string`\n the updated name for the credit grant\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.creditGrants.edit({ id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.creditGrants.edit', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.creditGrants.edit({\n id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n expires_at: '2022-04-01T00:00:00Z',\n name: 'Acme Corp Promotional Credit Grant',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.credit_grants.edit', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.credit_grants.edit(\n id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n expires_at=datetime.fromisoformat("2022-04-01T00:00:00"),\n name="Acme Corp Promotional Credit Grant",\n)\nprint(response.data)', }, java: { method: 'v1().creditGrants().edit', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantEditParams;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantEditResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditGrantEditParams params = CreditGrantEditParams.builder()\n .id("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .build();\n CreditGrantEditResponse response = client.v1().creditGrants().edit(params);\n }\n}', }, go: { method: 'client.V1.CreditGrants.Edit', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.CreditGrants.Edit(context.TODO(), metronome.V1CreditGrantEditParams{\n\t\tID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tExpiresAt: metronome.Time(time.Now()),\n\t\tName: metronome.String("Acme Corp Promotional Credit Grant"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.credit_grants.edit', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.credit_grants.edit(id: "9b85c1c1-5238-4f2a-a409-61412905e1e1")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/credits/editGrant \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "expires_at": "2022-04-01T00:00:00Z",\n "name": "Acme Corp Promotional Credit Grant"\n }\'', }, }, }, { name: 'void', endpoint: '/v1/credits/voidGrant', httpMethod: 'post', summary: 'Void a credit grant', description: 'Void a credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.credit_grants > (method) void', qualified: 'client.v1.creditGrants.void', params: ['id: string;', 'release_uniqueness_key?: boolean;', 'void_credit_purchase_invoice?: boolean;'], response: '{ data: { id: string; }; }', markdown: "## void\n\n`client.v1.creditGrants.void(id: string, release_uniqueness_key?: boolean, void_credit_purchase_invoice?: boolean): { data: id; }`\n\n**post** `/v1/credits/voidGrant`\n\nVoid a credit grant. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `id: string`\n\n- `release_uniqueness_key?: boolean`\n If true, resets the uniqueness key on this grant so it can be re-used\n\n- `void_credit_purchase_invoice?: boolean`\n If true, void the purchase invoice associated with the grant\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.creditGrants.void({ id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.creditGrants.void', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.creditGrants.void({ id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' });\n\nconsole.log(response.data);", }, python: { method: 'v1.credit_grants.void', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.credit_grants.void(\n id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n)\nprint(response.data)', }, java: { method: 'v1().creditGrants().void_', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantVoidParams;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantVoidResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditGrantVoidParams params = CreditGrantVoidParams.builder()\n .id("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .build();\n CreditGrantVoidResponse response = client.v1().creditGrants().void_(params);\n }\n}', }, go: { method: 'client.V1.CreditGrants.Void', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.CreditGrants.Void(context.TODO(), metronome.V1CreditGrantVoidParams{\n\t\tID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.credit_grants.void', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.credit_grants.void(id: "9b85c1c1-5238-4f2a-a409-61412905e1e1")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/credits/voidGrant \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "9b85c1c1-5238-4f2a-a409-61412905e1e1"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/credits/listGrants', httpMethod: 'post', summary: 'List credit grants', description: 'List credit grants. This list does not included voided grants. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.credit_grants > (method) list', qualified: 'client.v1.creditGrants.list', params: [ 'limit?: number;', 'next_page?: string;', 'credit_grant_ids?: string[];', 'credit_type_ids?: string[];', 'customer_ids?: string[];', 'effective_before?: string;', 'not_expiring_before?: string;', ], response: '{ id: string; balance: { effective_at: string; excluding_pending: number; including_pending: number; }; custom_fields: object; customer_id: string; deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; effective_at: string; expires_at: string; grant_amount: { amount: number; credit_type: object; }; name: string; paid_amount: { amount: number; credit_type: object; }; pending_deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; priority: number; credit_grant_type?: string; invoice_id?: string; products?: { id: string; name: string; }[]; reason?: string; uniqueness_key?: string; }', markdown: "## list\n\n`client.v1.creditGrants.list(limit?: number, next_page?: string, credit_grant_ids?: string[], credit_type_ids?: string[], customer_ids?: string[], effective_before?: string, not_expiring_before?: string): { id: string; balance: object; custom_fields: object; customer_id: string; deductions: credit_ledger_entry[]; effective_at: string; expires_at: string; grant_amount: object; name: string; paid_amount: object; pending_deductions: credit_ledger_entry[]; priority: number; credit_grant_type?: string; invoice_id?: string; products?: object[]; reason?: string; uniqueness_key?: string; }`\n\n**post** `/v1/credits/listGrants`\n\nList credit grants. This list does not included voided grants. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `credit_grant_ids?: string[]`\n An array of credit grant IDs. If this is specified, neither credit_type_ids nor customer_ids may be specified.\n\n- `credit_type_ids?: string[]`\n An array of credit type IDs. This must not be specified if credit_grant_ids is specified.\n\n- `customer_ids?: string[]`\n An array of Metronome customer IDs. This must not be specified if credit_grant_ids is specified.\n\n- `effective_before?: string`\n Only return credit grants that are effective before this timestamp (exclusive).\n\n- `not_expiring_before?: string`\n Only return credit grants that expire at or after this timestamp.\n\n### Returns\n\n- `{ id: string; balance: { effective_at: string; excluding_pending: number; including_pending: number; }; custom_fields: object; customer_id: string; deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; effective_at: string; expires_at: string; grant_amount: { amount: number; credit_type: object; }; name: string; paid_amount: { amount: number; credit_type: object; }; pending_deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; priority: number; credit_grant_type?: string; invoice_id?: string; products?: { id: string; name: string; }[]; reason?: string; uniqueness_key?: string; }`\n\n - `id: string`\n - `balance: { effective_at: string; excluding_pending: number; including_pending: number; }`\n - `custom_fields: object`\n - `customer_id: string`\n - `deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]`\n - `effective_at: string`\n - `expires_at: string`\n - `grant_amount: { amount: number; credit_type: { id: string; name: string; }; }`\n - `name: string`\n - `paid_amount: { amount: number; credit_type: { id: string; name: string; }; }`\n - `pending_deductions: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]`\n - `priority: number`\n - `credit_grant_type?: string`\n - `invoice_id?: string`\n - `products?: { id: string; name: string; }[]`\n - `reason?: string`\n - `uniqueness_key?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const creditGrantListResponse of client.v1.creditGrants.list()) {\n console.log(creditGrantListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.creditGrants.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const creditGrantListResponse of client.v1.creditGrants.list({\n credit_type_ids: ['2714e483-4ff1-48e4-9e25-ac732e8f24f2'],\n customer_ids: ['d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', '0e5b8609-d901-4992-b394-c3c2e3f37b1c'],\n effective_before: '2022-02-01T00:00:00Z',\n not_expiring_before: '2022-02-01T00:00:00Z',\n})) {\n console.log(creditGrantListResponse.id);\n}", }, python: { method: 'v1.credit_grants.list', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.credit_grants.list(\n credit_type_ids=["2714e483-4ff1-48e4-9e25-ac732e8f24f2"],\n customer_ids=["d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", "0e5b8609-d901-4992-b394-c3c2e3f37b1c"],\n effective_before=datetime.fromisoformat("2022-02-01T00:00:00"),\n not_expiring_before=datetime.fromisoformat("2022-02-01T00:00:00"),\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().creditGrants().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantListPage;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditGrantListPage page = client.v1().creditGrants().list();\n }\n}', }, go: { method: 'client.V1.CreditGrants.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.CreditGrants.List(context.TODO(), metronome.V1CreditGrantListParams{\n\t\tCreditTypeIDs: []string{"2714e483-4ff1-48e4-9e25-ac732e8f24f2"},\n\t\tCustomerIDs: []string{"d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc", "0e5b8609-d901-4992-b394-c3c2e3f37b1c"},\n\t\tEffectiveBefore: metronome.Time(time.Now()),\n\t\tNotExpiringBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.credit_grants.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.credit_grants.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/credits/listGrants \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_entries', endpoint: '/v1/credits/listEntries', httpMethod: 'post', summary: 'List credit ledger entries', description: 'Fetches a list of credit ledger entries. Returns lists of ledgers per customer. Ledger entries are returned in chronological order. Ledger entries associated with voided credit grants are not included. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.credit_grants > (method) list_entries', qualified: 'client.v1.creditGrants.listEntries', params: [ 'next_page?: string;', "sort?: 'asc' | 'desc';", 'credit_type_ids?: string[];', 'customer_ids?: string[];', 'ending_before?: string;', 'starting_on?: string;', ], response: '{ customer_id: string; ledgers: { credit_type: object; ending_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; entries: object[]; pending_entries: object[]; starting_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; }[]; }', markdown: "## list_entries\n\n`client.v1.creditGrants.listEntries(next_page?: string, sort?: 'asc' | 'desc', credit_type_ids?: string[], customer_ids?: string[], ending_before?: string, starting_on?: string): { customer_id: string; ledgers: object[]; }`\n\n**post** `/v1/credits/listEntries`\n\nFetches a list of credit ledger entries. Returns lists of ledgers per customer. Ledger entries are returned in chronological order. Ledger entries associated with voided credit grants are not included. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `sort?: 'asc' | 'desc'`\n Ledgers sort order by date, asc or desc. Defaults to asc.\n\n- `credit_type_ids?: string[]`\n A list of Metronome credit type IDs to fetch ledger entries for. If absent, ledger entries for all credit types will be returned.\n\n- `customer_ids?: string[]`\n A list of Metronome customer IDs to fetch ledger entries for. If absent, ledger entries for all customers will be returned.\n\n- `ending_before?: string`\n If supplied, ledger entries will only be returned with an effective_at before this time. This timestamp must not be in the future. If no timestamp is supplied, all entries up to the start of the customer's next billing period will be returned.\n\n- `starting_on?: string`\n If supplied, only ledger entries effective at or after this time will be returned.\n\n### Returns\n\n- `{ customer_id: string; ledgers: { credit_type: object; ending_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; entries: object[]; pending_entries: object[]; starting_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; }[]; }`\n\n - `customer_id: string`\n - `ledgers: { credit_type: { id: string; name: string; }; ending_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; entries: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; pending_entries: { amount: number; created_by: string; credit_grant_id: string; effective_at: string; reason: string; running_balance: number; invoice_id?: string; }[]; starting_balance: { effective_at: string; excluding_pending: number; including_pending: number; }; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const creditGrantListEntriesResponse of client.v1.creditGrants.listEntries()) {\n console.log(creditGrantListEntriesResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.creditGrants.listEntries', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const creditGrantListEntriesResponse of client.v1.creditGrants.listEntries({\n credit_type_ids: ['2714e483-4ff1-48e4-9e25-ac732e8f24f2'],\n customer_ids: ['6a37bb88-8538-48c5-b37b-a41c836328bd'],\n ending_before: '2021-02-01T00:00:00Z',\n starting_on: '2021-01-01T00:00:00Z',\n})) {\n console.log(creditGrantListEntriesResponse.customer_id);\n}", }, python: { method: 'v1.credit_grants.list_entries', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.credit_grants.list_entries(\n credit_type_ids=["2714e483-4ff1-48e4-9e25-ac732e8f24f2"],\n customer_ids=["6a37bb88-8538-48c5-b37b-a41c836328bd"],\n ending_before=datetime.fromisoformat("2021-02-01T00:00:00"),\n starting_on=datetime.fromisoformat("2021-01-01T00:00:00"),\n)\npage = page.data[0]\nprint(page.customer_id)', }, java: { method: 'v1().creditGrants().listEntries', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantListEntriesPage;\nimport com.metronome.api.models.v1.creditgrants.CreditGrantListEntriesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditGrantListEntriesPage page = client.v1().creditGrants().listEntries();\n }\n}', }, go: { method: 'client.V1.CreditGrants.ListEntries', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.CreditGrants.ListEntries(context.TODO(), metronome.V1CreditGrantListEntriesParams{\n\t\tCreditTypeIDs: []string{"2714e483-4ff1-48e4-9e25-ac732e8f24f2"},\n\t\tCustomerIDs: []string{"6a37bb88-8538-48c5-b37b-a41c836328bd"},\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t\tStartingOn: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.credit_grants.list_entries', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.credit_grants.list_entries\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/credits/listEntries \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/credit-types/list', httpMethod: 'get', summary: 'List pricing units', description: 'List all pricing units. All fiat currency types (for example, USD or GBP) will be included, as well as any custom pricing units that were configured. Custom pricing units can be used to charge for usage in a non-fiat pricing unit, for example AI credits.\n\nNote: The USD (cents) pricing unit is 2714e483-4ff1-48e4-9e25-ac732e8f24f2.\n', stainlessPath: '(resource) v1.pricing_units > (method) list', qualified: 'client.v1.pricingUnits.list', params: ['limit?: number;', 'next_page?: string;'], response: '{ id?: string; is_currency?: boolean; name?: string; }', markdown: "## list\n\n`client.v1.pricingUnits.list(limit?: number, next_page?: string): { id?: string; is_currency?: boolean; name?: string; }`\n\n**get** `/v1/credit-types/list`\n\nList all pricing units. All fiat currency types (for example, USD or GBP) will be included, as well as any custom pricing units that were configured. Custom pricing units can be used to charge for usage in a non-fiat pricing unit, for example AI credits.\n\nNote: The USD (cents) pricing unit is 2714e483-4ff1-48e4-9e25-ac732e8f24f2.\n\n\n### Parameters\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ id?: string; is_currency?: boolean; name?: string; }`\n\n - `id?: string`\n - `is_currency?: boolean`\n - `name?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const pricingUnitListResponse of client.v1.pricingUnits.list()) {\n console.log(pricingUnitListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.pricingUnits.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const pricingUnitListResponse of client.v1.pricingUnits.list()) {\n console.log(pricingUnitListResponse.id);\n}", }, python: { method: 'v1.pricing_units.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.pricing_units.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().pricingUnits().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.pricingunits.PricingUnitListPage;\nimport com.metronome.api.models.v1.pricingunits.PricingUnitListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PricingUnitListPage page = client.v1().pricingUnits().list();\n }\n}', }, go: { method: 'client.V1.PricingUnits.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.PricingUnits.List(context.TODO(), metronome.V1PricingUnitListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.pricing_units.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.pricing_units.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/credit-types/list \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'retrieve', endpoint: '/v1/customers/{customer_id}', httpMethod: 'get', summary: 'Get a customer', description: 'Get detailed information for a specific customer by their Metronome ID. Returns customer profile data including name, creation date, ingest aliases, configuration settings, and custom fields. Use this endpoint to fetch complete customer details for billing operations or account management.\n\nNote: If searching for a customer billing configuration, use the `/getCustomerBillingConfigurations` endpoint.\n', stainlessPath: '(resource) v1.customers > (method) retrieve', qualified: 'client.v1.customers.retrieve', params: ['customer_id: string;'], response: '{ data: { id: string; created_at: string; custom_fields: object; customer_config: object; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: object; }; }', markdown: "## retrieve\n\n`client.v1.customers.retrieve(customer_id: string): { data: customer_detail; }`\n\n**get** `/v1/customers/{customer_id}`\n\nGet detailed information for a specific customer by their Metronome ID. Returns customer profile data including name, creation date, ingest aliases, configuration settings, and custom fields. Use this endpoint to fetch complete customer details for billing operations or account management.\n\nNote: If searching for a customer billing configuration, use the `/getCustomerBillingConfigurations` endpoint.\n\n\n### Parameters\n\n- `customer_id: string`\n\n### Returns\n\n- `{ data: { id: string; created_at: string; custom_fields: object; customer_config: object; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: object; }; }`\n\n - `data: { id: string; created_at: string; custom_fields: object; customer_config: { salesforce_account_id: string; }; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: { value: 'billable' | 'unbillable'; effective_at?: string; }; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst customer = await client.v1.customers.retrieve({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(customer);\n```", perLanguage: { typescript: { method: 'client.v1.customers.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst customer = await client.v1.customers.retrieve({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(customer.data);", }, python: { method: 'v1.customers.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncustomer = client.v1.customers.retrieve(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(customer.data)', }, java: { method: 'v1().customers().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerRetrieveParams;\nimport com.metronome.api.models.v1.customers.CustomerRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerRetrieveParams params = CustomerRetrieveParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n CustomerRetrieveResponse customer = client.v1().customers().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Customers.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcustomer, err := client.V1.Customers.Get(context.TODO(), metronome.V1CustomerGetParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customer.Data)\n}\n', }, ruby: { method: 'v1.customers.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncustomer = metronome.v1.customers.retrieve(customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(customer)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/customers', httpMethod: 'get', summary: 'List customers', description: 'Gets a paginated list of all customers in your Metronome account. Use this endpoint to browse your customer base, implement customer search functionality, or sync customer data with external systems. Returns customer details including IDs, names, and configuration settings. Supports filtering and pagination parameters for efficient data retrieval.\n', stainlessPath: '(resource) v1.customers > (method) list', qualified: 'client.v1.customers.list', params: [ 'customer_ids?: string[];', 'ingest_alias?: string;', 'limit?: number;', 'next_page?: string;', 'only_archived?: boolean;', 'salesforce_account_ids?: string[];', ], response: "{ id: string; created_at: string; custom_fields: object; customer_config: { salesforce_account_id: string; }; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: { value: 'billable' | 'unbillable'; effective_at?: string; }; }", markdown: "## list\n\n`client.v1.customers.list(customer_ids?: string[], ingest_alias?: string, limit?: number, next_page?: string, only_archived?: boolean, salesforce_account_ids?: string[]): { id: string; created_at: string; custom_fields: object; customer_config: object; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: object; }`\n\n**get** `/v1/customers`\n\nGets a paginated list of all customers in your Metronome account. Use this endpoint to browse your customer base, implement customer search functionality, or sync customer data with external systems. Returns customer details including IDs, names, and configuration settings. Supports filtering and pagination parameters for efficient data retrieval.\n\n\n### Parameters\n\n- `customer_ids?: string[]`\n Filter the customer list by customer_id. Up to 100 ids can be provided.\n\n- `ingest_alias?: string`\n Filter the customer list by ingest_alias\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `only_archived?: boolean`\n Filter the customer list to only return archived customers. By default, only active customers are returned.\n\n- `salesforce_account_ids?: string[]`\n Filter the customer list by salesforce_account_id. Up to 100 ids can be provided.\n\n### Returns\n\n- `{ id: string; created_at: string; custom_fields: object; customer_config: { salesforce_account_id: string; }; external_id: string; ingest_aliases: string[]; name: string; updated_at: string; archived_at?: string; current_billable_status?: { value: 'billable' | 'unbillable'; effective_at?: string; }; }`\n\n - `id: string`\n - `created_at: string`\n - `custom_fields: object`\n - `customer_config: { salesforce_account_id: string; }`\n - `external_id: string`\n - `ingest_aliases: string[]`\n - `name: string`\n - `updated_at: string`\n - `archived_at?: string`\n - `current_billable_status?: { value: 'billable' | 'unbillable'; effective_at?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const customerDetail of client.v1.customers.list()) {\n console.log(customerDetail);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const customerDetail of client.v1.customers.list()) {\n console.log(customerDetail.id);\n}", }, python: { method: 'v1.customers.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerListPage;\nimport com.metronome.api.models.v1.customers.CustomerListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerListPage page = client.v1().customers().list();\n }\n}', }, go: { method: 'client.V1.Customers.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.List(context.TODO(), metronome.V1CustomerListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/customers', httpMethod: 'post', summary: 'Create a customer', description: 'Create a new customer in Metronome and optionally the billing configuration (recommended) which dictates where invoices for the customer will be sent or where payment will be collected. \n\n### Use this endpoint to:\nExecute your customer provisioning workflows for either PLG motions, where customers originate in your platform, or SLG motions, where customers originate in your sales system.\n\n### Key response fields: \nThis end-point returns the `customer_id` created by the request. This id can be used to fetch relevant billing configurations and create contracts.\n\n### Example workflow:\n- Generally, Metronome recommends first creating the customer in the downstream payment / ERP system when payment method is collected and then creating the customer in Metronome using the response (i.e. `customer_id`) from the downstream system. If you do not create a billing configuration on customer creation, you can add it later. \n- Once a customer is created, you can then create a contract for the customer. In the contract creation process, you will need to add the customer billing configuration to the contract to ensure Metronome invoices the customer correctly. This is because a customer can have multiple configurations.\n- As part of the customer creation process, set the ingest alias for the customer which will ensure usage is accurately mapped to the customer. Ingest aliases can be added or changed after the creation process as well.\n\n### Usage guidelines:\nFor details on different billing configurations for different systems, review the `/setCustomerBillingConfiguration` end-point.\n', stainlessPath: '(resource) v1.customers > (method) create', qualified: 'client.v1.customers.create', params: [ 'name: string;', 'billing_config?: { billing_provider_customer_id: string; billing_provider_type: string; aws_customer_account_id?: string; aws_customer_id?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; stripe_collection_method?: string; };', 'custom_fields?: object;', "customer_billing_provider_configurations?: { billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[];", "customer_revenue_system_configurations?: { provider: 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider'; delivery_method_id?: string; }[];", 'external_id?: string;', 'ingest_aliases?: string[];', ], response: '{ data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }; }', markdown: "## create\n\n`client.v1.customers.create(name: string, billing_config?: { billing_provider_customer_id: string; billing_provider_type: string; aws_customer_account_id?: string; aws_customer_id?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; stripe_collection_method?: string; }, custom_fields?: object, customer_billing_provider_configurations?: { billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[], customer_revenue_system_configurations?: { provider: 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider'; delivery_method_id?: string; }[], external_id?: string, ingest_aliases?: string[]): { data: customer; }`\n\n**post** `/v1/customers`\n\nCreate a new customer in Metronome and optionally the billing configuration (recommended) which dictates where invoices for the customer will be sent or where payment will be collected. \n\n### Use this endpoint to:\nExecute your customer provisioning workflows for either PLG motions, where customers originate in your platform, or SLG motions, where customers originate in your sales system.\n\n### Key response fields: \nThis end-point returns the `customer_id` created by the request. This id can be used to fetch relevant billing configurations and create contracts.\n\n### Example workflow:\n- Generally, Metronome recommends first creating the customer in the downstream payment / ERP system when payment method is collected and then creating the customer in Metronome using the response (i.e. `customer_id`) from the downstream system. If you do not create a billing configuration on customer creation, you can add it later. \n- Once a customer is created, you can then create a contract for the customer. In the contract creation process, you will need to add the customer billing configuration to the contract to ensure Metronome invoices the customer correctly. This is because a customer can have multiple configurations.\n- As part of the customer creation process, set the ingest alias for the customer which will ensure usage is accurately mapped to the customer. Ingest aliases can be added or changed after the creation process as well.\n\n### Usage guidelines:\nFor details on different billing configurations for different systems, review the `/setCustomerBillingConfiguration` end-point.\n\n\n### Parameters\n\n- `name: string`\n This will be truncated to 160 characters if the provided name is longer.\n\n- `billing_config?: { billing_provider_customer_id: string; billing_provider_type: string; aws_customer_account_id?: string; aws_customer_id?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; stripe_collection_method?: string; }`\n - `billing_provider_customer_id: string`\n - `billing_provider_type: string`\n - `aws_customer_account_id?: string`\n - `aws_customer_id?: string`\n - `aws_is_subscription_product?: boolean`\n True if the aws_product_code is a SAAS subscription product, false otherwise.\n - `aws_product_code?: string`\n - `aws_region?: string`\n - `stripe_collection_method?: string`\n The collection method for the customer's invoices.\nNOTE: `auto_charge_payment_intent` and `manually_charge_payment_intent` are in beta.\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `customer_billing_provider_configurations?: { billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]`\n\n- `customer_revenue_system_configurations?: { provider: 'netsuite'; configuration?: object; delivery_method?: 'direct_to_billing_provider'; delivery_method_id?: string; }[]`\n\n- `external_id?: string`\n (deprecated, use ingest_aliases instead) an alias that can be used to refer to this customer in usage events\n\n- `ingest_aliases?: string[]`\n Aliases that can be used to refer to this customer in usage events\n\n### Returns\n\n- `{ data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }; }`\n\n - `data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst customer = await client.v1.customers.create({ name: 'Example, Inc.' });\n\nconsole.log(customer);\n```", perLanguage: { typescript: { method: 'client.v1.customers.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst customer = await client.v1.customers.create({\n name: 'Example, Inc.',\n customer_billing_provider_configurations: [\n {\n billing_provider: 'stripe',\n delivery_method: 'direct_to_billing_provider',\n configuration: {\n stripe_customer_id: 'cus_123',\n stripe_collection_method: 'charge_automatically',\n },\n },\n ],\n ingest_aliases: ['team@example.com'],\n});\n\nconsole.log(customer.data);", }, python: { method: 'v1.customers.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncustomer = client.v1.customers.create(\n name="Example, Inc.",\n customer_billing_provider_configurations=[{\n "billing_provider": "stripe",\n "delivery_method": "direct_to_billing_provider",\n "configuration": {\n "stripe_customer_id": "cus_123",\n "stripe_collection_method": "charge_automatically",\n },\n }],\n ingest_aliases=["team@example.com"],\n)\nprint(customer.data)', }, java: { method: 'v1().customers().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerCreateParams;\nimport com.metronome.api.models.v1.customers.CustomerCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerCreateParams params = CustomerCreateParams.builder()\n .name("Example, Inc.")\n .build();\n CustomerCreateResponse customer = client.v1().customers().create(params);\n }\n}', }, go: { method: 'client.V1.Customers.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcustomer, err := client.V1.Customers.New(context.TODO(), metronome.V1CustomerNewParams{\n\t\tName: "Example, Inc.",\n\t\tCustomerBillingProviderConfigurations: []metronome.V1CustomerNewParamsCustomerBillingProviderConfiguration{{\n\t\t\tBillingProvider: "stripe",\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"stripe_customer_id": "cus_123",\n\t\t\t\t"stripe_collection_method": "charge_automatically",\n\t\t\t},\n\t\t}},\n\t\tIngestAliases: []string{"team@example.com"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", customer.Data)\n}\n', }, ruby: { method: 'v1.customers.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncustomer = metronome.v1.customers.create(name: "Example, Inc.")\n\nputs(customer)', }, http: { example: 'curl https://api.metronome.com/v1/customers \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "Example, Inc.",\n "customer_billing_provider_configurations": [\n {\n "billing_provider": "stripe",\n "configuration": {\n "stripe_customer_id": "bar",\n "stripe_collection_method": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n }\n ],\n "ingest_aliases": [\n "team@example.com"\n ]\n }\'', }, }, }, { name: 'set_ingest_aliases', endpoint: '/v1/customers/{customer_id}/setIngestAliases', httpMethod: 'post', summary: 'Create or update customer ingest aliases', description: 'Sets the ingest aliases for a customer. Use this endpoint to associate a Metronome customer with an internal ID for easier tracking between systems. Ingest aliases can be used in the `customer_id` field when sending usage events to Metronome. \n\n### Usage guidelines:\n- This call is idempotent and fully replaces the set of ingest aliases for the given customer.\n- Switching an ingest alias from one customer to another will associate all corresponding usage to the new customer.\n- Use multiple ingest aliases to model child organizations within a single Metronome customer.\n', stainlessPath: '(resource) v1.customers > (method) set_ingest_aliases', qualified: 'client.v1.customers.setIngestAliases', params: ['customer_id: string;', 'ingest_aliases: string[];'], markdown: "## set_ingest_aliases\n\n`client.v1.customers.setIngestAliases(customer_id: string, ingest_aliases: string[]): void`\n\n**post** `/v1/customers/{customer_id}/setIngestAliases`\n\nSets the ingest aliases for a customer. Use this endpoint to associate a Metronome customer with an internal ID for easier tracking between systems. Ingest aliases can be used in the `customer_id` field when sending usage events to Metronome. \n\n### Usage guidelines:\n- This call is idempotent and fully replaces the set of ingest aliases for the given customer.\n- Switching an ingest alias from one customer to another will associate all corresponding usage to the new customer.\n- Use multiple ingest aliases to model child organizations within a single Metronome customer.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `ingest_aliases: string[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.setIngestAliases({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', ingest_aliases: ['team@example.com'] })\n```", perLanguage: { typescript: { method: 'client.v1.customers.setIngestAliases', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.setIngestAliases({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n ingest_aliases: ['team@example.com'],\n});", }, python: { method: 'v1.customers.set_ingest_aliases', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.set_ingest_aliases(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ingest_aliases=["team@example.com"],\n)', }, java: { method: 'v1().customers().setIngestAliases', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerSetIngestAliasesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerSetIngestAliasesParams params = CustomerSetIngestAliasesParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .addIngestAlias("team@example.com")\n .build();\n client.v1().customers().setIngestAliases(params);\n }\n}', }, go: { method: 'client.V1.Customers.SetIngestAliases', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.SetIngestAliases(context.TODO(), metronome.V1CustomerSetIngestAliasesParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tIngestAliases: []string{"team@example.com"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.set_ingest_aliases', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.set_ingest_aliases(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ingest_aliases: ["team@example.com"]\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/setIngestAliases \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "ingest_aliases": [\n "team@example.com"\n ]\n }\'', }, }, }, { name: 'set_name', endpoint: '/v1/customers/{customer_id}/setName', httpMethod: 'post', summary: 'Update a customer name', description: 'Updates the display name for a customer record. Use this to correct customer names, update business names after rebranding, or maintain accurate customer information for invoicing and reporting. Returns the updated customer object with the new name applied immediately across all billing documents and interfaces.\n', stainlessPath: '(resource) v1.customers > (method) set_name', qualified: 'client.v1.customers.setName', params: ['customer_id: string;', 'name: string;'], response: '{ data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }; }', markdown: "## set_name\n\n`client.v1.customers.setName(customer_id: string, name: string): { data: customer; }`\n\n**post** `/v1/customers/{customer_id}/setName`\n\nUpdates the display name for a customer record. Use this to correct customer names, update business names after rebranding, or maintain accurate customer information for invoicing and reporting. Returns the updated customer object with the new name applied immediately across all billing documents and interfaces.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `name: string`\n The new name for the customer. This will be truncated to 160 characters if the provided name is longer.\n\n### Returns\n\n- `{ data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }; }`\n\n - `data: { id: string; external_id: string; ingest_aliases: string[]; name: string; custom_fields?: object; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.setName({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', name: 'Example, Inc.' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.setName', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.setName({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n name: 'Example, Inc.',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.set_name', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.set_name(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n name="Example, Inc.",\n)\nprint(response.data)', }, java: { method: 'v1().customers().setName', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerSetNameParams;\nimport com.metronome.api.models.v1.customers.CustomerSetNameResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerSetNameParams params = CustomerSetNameParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .name("Example, Inc.")\n .build();\n CustomerSetNameResponse response = client.v1().customers().setName(params);\n }\n}', }, go: { method: 'client.V1.Customers.SetName', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.SetName(context.TODO(), metronome.V1CustomerSetNameParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tName: "Example, Inc.",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.set_name', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.set_name(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n name: "Example, Inc."\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/setName \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "Example, Inc."\n }\'', }, }, }, { name: 'update_config', endpoint: '/v1/customers/{customer_id}/updateConfig', httpMethod: 'post', summary: 'Update a customer configuration', description: 'Update configuration settings for a specific customer, such as external system integrations (e.g., Salesforce account ID) and other customer-specific billing parameters. Use this endpoint to modify customer configurations without affecting core customer data like name or ingest aliases.\n', stainlessPath: '(resource) v1.customers > (method) update_config', qualified: 'client.v1.customers.updateConfig', params: [ 'customer_id: string;', 'leave_stripe_invoices_in_draft?: boolean;', 'salesforce_account_id?: string;', ], markdown: "## update_config\n\n`client.v1.customers.updateConfig(customer_id: string, leave_stripe_invoices_in_draft?: boolean, salesforce_account_id?: string): void`\n\n**post** `/v1/customers/{customer_id}/updateConfig`\n\nUpdate configuration settings for a specific customer, such as external system integrations (e.g., Salesforce account ID) and other customer-specific billing parameters. Use this endpoint to modify customer configurations without affecting core customer data like name or ingest aliases.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `leave_stripe_invoices_in_draft?: boolean`\n Leave in draft or set to auto-advance on invoices sent to Stripe. Falls back to the client-level config if unset, which defaults to true if unset.\n\n- `salesforce_account_id?: string`\n The Salesforce account ID for the customer\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.updateConfig({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })\n```", perLanguage: { typescript: { method: 'client.v1.customers.updateConfig', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.updateConfig({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n salesforce_account_id: '0015500001WO1ZiABL',\n});", }, python: { method: 'v1.customers.update_config', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.update_config(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n salesforce_account_id="0015500001WO1ZiABL",\n)', }, java: { method: 'v1().customers().updateConfig', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerUpdateConfigParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerUpdateConfigParams params = CustomerUpdateConfigParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n client.v1().customers().updateConfig(params);\n }\n}', }, go: { method: 'client.V1.Customers.UpdateConfig', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.UpdateConfig(context.TODO(), metronome.V1CustomerUpdateConfigParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tSalesforceAccountID: metronome.String("0015500001WO1ZiABL"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.update_config', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.update_config(customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/updateConfig \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_costs', endpoint: '/v1/customers/{customer_id}/costs', httpMethod: 'get', summary: 'Get customer costs', description: 'Fetch daily pending costs for the specified customer, broken down by credit type and line items. Note: this is not supported for customers whose plan includes a UNIQUE-type billable metric. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers > (method) list_costs', qualified: 'client.v1.customers.listCosts', params: [ 'customer_id: string;', 'ending_before: string;', 'starting_on: string;', 'limit?: number;', 'next_page?: string;', ], response: '{ credit_types: object; end_timestamp: string; start_timestamp: string; }', markdown: "## list_costs\n\n`client.v1.customers.listCosts(customer_id: string, ending_before: string, starting_on: string, limit?: number, next_page?: string): { credit_types: object; end_timestamp: string; start_timestamp: string; }`\n\n**get** `/v1/customers/{customer_id}/costs`\n\nFetch daily pending costs for the specified customer, broken down by credit type and line items. Note: this is not supported for customers whose plan includes a UNIQUE-type billable metric. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `ending_before: string`\n RFC 3339 timestamp (exclusive)\n\n- `starting_on: string`\n RFC 3339 timestamp (inclusive)\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ credit_types: object; end_timestamp: string; start_timestamp: string; }`\n\n - `credit_types: object`\n - `end_timestamp: string`\n - `start_timestamp: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const customerListCostsResponse of client.v1.customers.listCosts({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n ending_before: '2019-12-27T18:11:19.117Z',\n starting_on: '2019-12-27T18:11:19.117Z',\n})) {\n console.log(customerListCostsResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.listCosts', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const customerListCostsResponse of client.v1.customers.listCosts({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n ending_before: '2019-12-27T18:11:19.117Z',\n starting_on: '2019-12-27T18:11:19.117Z',\n})) {\n console.log(customerListCostsResponse.credit_types);\n}", }, python: { method: 'v1.customers.list_costs', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.list_costs(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ending_before=datetime.fromisoformat("2019-12-27T18:11:19.117"),\n starting_on=datetime.fromisoformat("2019-12-27T18:11:19.117"),\n)\npage = page.data[0]\nprint(page.credit_types)', }, java: { method: 'v1().customers().listCosts', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerListCostsPage;\nimport com.metronome.api.models.v1.customers.CustomerListCostsParams;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerListCostsParams params = CustomerListCostsParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))\n .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))\n .build();\n CustomerListCostsPage page = client.v1().customers().listCosts(params);\n }\n}', }, go: { method: 'client.V1.Customers.ListCosts', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.ListCosts(context.TODO(), metronome.V1CustomerListCostsParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tEndingBefore: time.Now(),\n\t\tStartingOn: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.list_costs', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.list_costs(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ending_before: "2019-12-27T18:11:19.117Z",\n starting_on: "2019-12-27T18:11:19.117Z"\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/costs \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'archive', endpoint: '/v1/customers/archive', httpMethod: 'post', summary: 'Archive a customer', description: 'Use this endpoint to archive a customer while preserving auditability. Archiving a customer will automatically archive all contracts as of the current date and void all corresponding invoices. Use this endpoint if a customer is onboarded by mistake.\n\n### Usage guidelines:\n- Once a customer is archived, it cannot be unarchived.\n- Archived customers can still be viewed through the API or the UI for audit purposes. \n- Ingest aliases remain idempotent for archived customers. In order to reuse an ingest alias, first remove the ingest alias from the customer prior to archiving.\n- Any notifications associated with the customer will no longer be triggered.\n', stainlessPath: '(resource) v1.customers > (method) archive', qualified: 'client.v1.customers.archive', params: ['id: string;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.customers.archive(id: string): { data: id; }`\n\n**post** `/v1/customers/archive`\n\nUse this endpoint to archive a customer while preserving auditability. Archiving a customer will automatically archive all contracts as of the current date and void all corresponding invoices. Use this endpoint if a customer is onboarded by mistake.\n\n### Usage guidelines:\n- Once a customer is archived, it cannot be unarchived.\n- Archived customers can still be viewed through the API or the UI for audit purposes. \n- Ingest aliases remain idempotent for archived customers. In order to reuse an ingest alias, first remove the ingest alias from the customer prior to archiving.\n- Any notifications associated with the customer will no longer be triggered.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.archive({ id: '8deed800-1b7a-495d-a207-6c52bac54dc9' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.archive({ id: '8deed800-1b7a-495d-a207-6c52bac54dc9' });\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.archive(\n id="8deed800-1b7a-495d-a207-6c52bac54dc9",\n)\nprint(response.data)', }, java: { method: 'v1().customers().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.Id;\nimport com.metronome.api.models.v1.customers.CustomerArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n Id params = Id.builder()\n .id("8deed800-1b7a-495d-a207-6c52bac54dc9")\n .build();\n CustomerArchiveResponse response = client.v1().customers().archive(params);\n }\n}', }, go: { method: 'client.V1.Customers.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Archive(context.TODO(), metronome.V1CustomerArchiveParams{\n\t\tID: shared.IDParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.archive(id: "8deed800-1b7a-495d-a207-6c52bac54dc9")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "8deed800-1b7a-495d-a207-6c52bac54dc9"\n }\'', }, }, }, { name: 'list_billable_metrics', endpoint: '/v1/customers/{customer_id}/billable-metrics', httpMethod: 'get', summary: 'Get billable metrics for a customer', description: 'Get all billable metrics available for a specific customer. Supports pagination and filtering by current plan status or archived metrics. Use this endpoint to see which metrics are being tracked for billing calculations for a given customer.\n', stainlessPath: '(resource) v1.customers > (method) list_billable_metrics', qualified: 'client.v1.customers.listBillableMetrics', params: [ 'customer_id: string;', 'include_archived?: boolean;', 'limit?: number;', 'next_page?: string;', 'on_current_plan?: boolean;', ], response: "{ id: string; name: string; aggregate?: string; aggregate_keys?: string[]; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }; filter?: object; group_by?: string[]; group_keys?: string[][]; property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]; sql?: string; }", markdown: "## list_billable_metrics\n\n`client.v1.customers.listBillableMetrics(customer_id: string, include_archived?: boolean, limit?: number, next_page?: string, on_current_plan?: boolean): { id: string; name: string; aggregate?: string; aggregate_keys?: string[]; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: event_type_filter; filter?: object; group_by?: string[]; group_keys?: string[][]; property_filters?: property_filter[]; sql?: string; }`\n\n**get** `/v1/customers/{customer_id}/billable-metrics`\n\nGet all billable metrics available for a specific customer. Supports pagination and filtering by current plan status or archived metrics. Use this endpoint to see which metrics are being tracked for billing calculations for a given customer.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `include_archived?: boolean`\n If true, the list of returned metrics will include archived metrics\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `on_current_plan?: boolean`\n If true, the list of metrics will be filtered to just ones that are on the customer's current plan\n\n### Returns\n\n- `{ id: string; name: string; aggregate?: string; aggregate_keys?: string[]; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }; filter?: object; group_by?: string[]; group_keys?: string[][]; property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]; sql?: string; }`\n\n - `id: string`\n - `name: string`\n - `aggregate?: string`\n - `aggregate_keys?: string[]`\n - `aggregation_key?: string`\n - `aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'`\n - `archived_at?: string`\n - `custom_fields?: object`\n - `event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }`\n - `filter?: object`\n - `group_by?: string[]`\n - `group_keys?: string[][]`\n - `property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]`\n - `sql?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const customerListBillableMetricsResponse of client.v1.customers.listBillableMetrics({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })) {\n console.log(customerListBillableMetricsResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.listBillableMetrics', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const customerListBillableMetricsResponse of client.v1.customers.listBillableMetrics({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n})) {\n console.log(customerListBillableMetricsResponse.id);\n}", }, python: { method: 'v1.customers.list_billable_metrics', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.list_billable_metrics(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().listBillableMetrics', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerListBillableMetricsPage;\nimport com.metronome.api.models.v1.customers.CustomerListBillableMetricsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerListBillableMetricsParams params = CustomerListBillableMetricsParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n CustomerListBillableMetricsPage page = client.v1().customers().listBillableMetrics(params);\n }\n}', }, go: { method: 'client.V1.Customers.ListBillableMetrics', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.ListBillableMetrics(context.TODO(), metronome.V1CustomerListBillableMetricsParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.list_billable_metrics', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.list_billable_metrics(customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/billable-metrics \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'preview_events', endpoint: '/v1/customers/{customer_id}/previewEvents', httpMethod: 'post', summary: 'Preview events', description: "Preview how a set of events will affect a customer's invoices. Generates draft invoices for a customer using their current contract configuration and the provided events. This is useful for testing how new events will affect the customer's invoices before they are actually processed. Customers on contracts with SQL billable metrics are not supported.\n", stainlessPath: '(resource) v1.customers > (method) preview_events', qualified: 'client.v1.customers.previewEvents', params: [ 'customer_id: string;', 'events: { event_type: string; properties?: object; timestamp?: string; transaction_id?: string; }[];', "mode?: 'replace' | 'merge';", 'skip_zero_qty_line_items?: boolean;', ], response: '{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }', markdown: "## preview_events\n\n`client.v1.customers.previewEvents(customer_id: string, events: { event_type: string; properties?: object; timestamp?: string; transaction_id?: string; }[], mode?: 'replace' | 'merge', skip_zero_qty_line_items?: boolean): { data: invoice[]; }`\n\n**post** `/v1/customers/{customer_id}/previewEvents`\n\nPreview how a set of events will affect a customer's invoices. Generates draft invoices for a customer using their current contract configuration and the provided events. This is useful for testing how new events will affect the customer's invoices before they are actually processed. Customers on contracts with SQL billable metrics are not supported.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `events: { event_type: string; properties?: object; timestamp?: string; transaction_id?: string; }[]`\n Array of usage events to include in the preview calculation. Must contain at least one event in `merge` mode.\n\n\n- `mode?: 'replace' | 'merge'`\n Controls how the provided events are combined with existing usage data. Use `replace` to calculate the preview as if these are the only events for the customer, ignoring all historical usage. Use `merge` to combine these events with the customer's existing usage. Defaults to `replace`.\n\n- `skip_zero_qty_line_items?: boolean`\n When `true`, line items with zero quantity are excluded from the response.\n\n### Returns\n\n- `{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }`\n\n - `data: { id: string; credit_type: { id: string; name: string; }; customer_id: string; line_items: { credit_type: object; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: object; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: object; tiers?: object[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; invoice_adjustments?: { credit_type: object; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.previewEvents({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', events: [{ event_type: 'heartbeat' }] });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.previewEvents', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.previewEvents({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n events: [\n {\n event_type: 'heartbeat',\n timestamp: '2021-01-01T00:00:00Z',\n properties: { cpu_hours: 100, memory_gb_hours: 200 },\n },\n ],\n mode: 'replace',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.preview_events', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.preview_events(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n events=[{\n "event_type": "heartbeat",\n "timestamp": "2021-01-01T00:00:00Z",\n "properties": {\n "cpu_hours": 100,\n "memory_gb_hours": 200,\n },\n }],\n mode="replace",\n)\nprint(response.data)', }, java: { method: 'v1().customers().previewEvents', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerPreviewEventsParams;\nimport com.metronome.api.models.v1.customers.CustomerPreviewEventsResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerPreviewEventsParams params = CustomerPreviewEventsParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .addEvent(CustomerPreviewEventsParams.Event.builder()\n .eventType("heartbeat")\n .build())\n .build();\n CustomerPreviewEventsResponse response = client.v1().customers().previewEvents(params);\n }\n}', }, go: { method: 'client.V1.Customers.PreviewEvents', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.PreviewEvents(context.TODO(), metronome.V1CustomerPreviewEventsParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tEvents: []metronome.V1CustomerPreviewEventsParamsEvent{{\n\t\t\tEventType: "heartbeat",\n\t\t\tTimestamp: metronome.String("2021-01-01T00:00:00Z"),\n\t\t\tProperties: map[string]any{\n\t\t\t\t"cpu_hours": 100,\n\t\t\t\t"memory_gb_hours": 200,\n\t\t\t},\n\t\t}},\n\t\tMode: metronome.V1CustomerPreviewEventsParamsModeReplace,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.preview_events', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.preview_events(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n events: [{event_type: "heartbeat"}]\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/previewEvents \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "events": [\n {\n "event_type": "heartbeat",\n "properties": {\n "cpu_hours": "bar",\n "memory_gb_hours": "bar"\n },\n "timestamp": "2021-01-01T00:00:00Z"\n }\n ],\n "mode": "replace"\n }\'', }, }, }, { name: 'set_billing_configurations', endpoint: '/v1/setCustomerBillingProviderConfigurations', httpMethod: 'post', summary: 'Set billing provider configurations for a customer', description: "Create a billing configuration for a customer. Once created, these configurations are available to associate to a contract and dictates which downstream system to collect payment in or send the invoice to. You can create multiple configurations per customer. The configuration formats are distinct for each downstream provider.\n\n### Use this endpoint to:\n- Add the initial configuration to an existing customer. Once created, the billing configuration can then be associated to the customer's contract.\n- Add a new configuration to an existing customer. This might be used as part of an upgrade or downgrade workflow where the customer was previously billed through system A (e.g. Stripe) but will now be billed through system B (e.g. AWS). Once created, the new configuration can then be associated to the customer's contract.\n- Multiple configurations can be added per destination. For example, you can create two Stripe billing configurations for a Metronome customer that each have a distinct `collection_method`.\n\n### Delivery method options:\n- `direct_to_billing_provider`: Use when Metronome should send invoices directly to the billing provider's API (e.g., Stripe, NetSuite). This is the most common method for automated billing workflows.\n- `tackle`: Use specifically for AWS Marketplace transactions that require Tackle's co-selling platform for partner attribution and commission tracking.\n- `aws_sqs`: Use when you want invoice data delivered to an AWS SQS queue for custom processing before sending to your billing system.\n- `aws_sns`: Use when you want invoice notifications published to an AWS SNS topic for event-driven billing workflows.\n\n### Key response fields: \nThe id for the customer billing configuration. This id can be used to associate the billing configuration to a contract.\n\n### Usage guidelines:\nMust use the `delivery_method_id` if you have multiple Stripe accounts connected to Metronome.\n", stainlessPath: '(resource) v1.customers > (method) set_billing_configurations', qualified: 'client.v1.customers.setBillingConfigurations', params: [ "data: { billing_provider: string; customer_id: string; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[];", ], response: "{ data: { id?: string; billing_provider?: string; configuration?: object; customer_id?: string; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]; }", markdown: "## set_billing_configurations\n\n`client.v1.customers.setBillingConfigurations(data: { billing_provider: string; customer_id: string; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]): { data: object[]; }`\n\n**post** `/v1/setCustomerBillingProviderConfigurations`\n\nCreate a billing configuration for a customer. Once created, these configurations are available to associate to a contract and dictates which downstream system to collect payment in or send the invoice to. You can create multiple configurations per customer. The configuration formats are distinct for each downstream provider.\n\n### Use this endpoint to:\n- Add the initial configuration to an existing customer. Once created, the billing configuration can then be associated to the customer's contract.\n- Add a new configuration to an existing customer. This might be used as part of an upgrade or downgrade workflow where the customer was previously billed through system A (e.g. Stripe) but will now be billed through system B (e.g. AWS). Once created, the new configuration can then be associated to the customer's contract.\n- Multiple configurations can be added per destination. For example, you can create two Stripe billing configurations for a Metronome customer that each have a distinct `collection_method`.\n\n### Delivery method options:\n- `direct_to_billing_provider`: Use when Metronome should send invoices directly to the billing provider's API (e.g., Stripe, NetSuite). This is the most common method for automated billing workflows.\n- `tackle`: Use specifically for AWS Marketplace transactions that require Tackle's co-selling platform for partner attribution and commission tracking.\n- `aws_sqs`: Use when you want invoice data delivered to an AWS SQS queue for custom processing before sending to your billing system.\n- `aws_sns`: Use when you want invoice notifications published to an AWS SNS topic for event-driven billing workflows.\n\n### Key response fields: \nThe id for the customer billing configuration. This id can be used to associate the billing configuration to a contract.\n\n### Usage guidelines:\nMust use the `delivery_method_id` if you have multiple Stripe accounts connected to Metronome.\n\n\n### Parameters\n\n- `data: { billing_provider: string; customer_id: string; configuration?: object; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]`\n\n### Returns\n\n- `{ data: { id?: string; billing_provider?: string; configuration?: object; customer_id?: string; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]; }`\n\n - `data: { id?: string; billing_provider?: string; configuration?: object; customer_id?: string; delivery_method_id?: string; tax_provider?: 'anrok' | 'avalara' | 'stripe'; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.setBillingConfigurations({ data: [{ billing_provider: 'stripe', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }, { billing_provider: 'aws_marketplace', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }, { billing_provider: 'azure_marketplace', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }, { billing_provider: 'aws_marketplace', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }, { billing_provider: 'gcp_marketplace', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }, { billing_provider: 'netsuite', customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491' }] });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.setBillingConfigurations', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.setBillingConfigurations({\n data: [\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'stripe',\n configuration: {\n stripe_customer_id: 'cus_1234',\n stripe_collection_method: 'charge_automatically',\n leave_stripe_invoices_in_draft: true,\n },\n delivery_method: 'direct_to_billing_provider',\n },\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'aws_marketplace',\n configuration: {\n aws_customer_id: 'ABC123ABC12',\n aws_product_code: 'my_product',\n aws_region: 'us-west-1',\n },\n delivery_method: 'direct_to_billing_provider',\n },\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'azure_marketplace',\n configuration: { azure_subscription_id: 'my_subscription' },\n delivery_method_id: '5b9e3072-415b-4842-94f0-0b6700c8b6be',\n },\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'aws_marketplace',\n configuration: {\n aws_customer_id: 'ABC123ABC12',\n aws_product_code: 'my_product',\n aws_region: 'us-west-1',\n aws_is_subscription_product: true,\n },\n delivery_method: 'direct_to_billing_provider',\n },\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'gcp_marketplace',\n configuration: {\n gcp_entitlement_id: 'my_entitlement',\n gcp_service_name: 'my.service.endpoint.goog',\n },\n delivery_method: 'direct_to_billing_provider',\n },\n {\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n billing_provider: 'netsuite',\n configuration: { netsuite_customer_id: '12345' },\n delivery_method: 'direct_to_billing_provider',\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.set_billing_configurations', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.set_billing_configurations(\n data=[{\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "stripe",\n "configuration": {\n "stripe_customer_id": "cus_1234",\n "stripe_collection_method": "charge_automatically",\n "leave_stripe_invoices_in_draft": True,\n },\n "delivery_method": "direct_to_billing_provider",\n }, {\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "aws_marketplace",\n "configuration": {\n "aws_customer_id": "ABC123ABC12",\n "aws_product_code": "my_product",\n "aws_region": "us-west-1",\n },\n "delivery_method": "direct_to_billing_provider",\n }, {\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "azure_marketplace",\n "configuration": {\n "azure_subscription_id": "my_subscription"\n },\n "delivery_method_id": "5b9e3072-415b-4842-94f0-0b6700c8b6be",\n }, {\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "aws_marketplace",\n "configuration": {\n "aws_customer_id": "ABC123ABC12",\n "aws_product_code": "my_product",\n "aws_region": "us-west-1",\n "aws_is_subscription_product": True,\n },\n "delivery_method": "direct_to_billing_provider",\n }, {\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "gcp_marketplace",\n "configuration": {\n "gcp_entitlement_id": "my_entitlement",\n "gcp_service_name": "my.service.endpoint.goog",\n },\n "delivery_method": "direct_to_billing_provider",\n }, {\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "billing_provider": "netsuite",\n "configuration": {\n "netsuite_customer_id": "12345"\n },\n "delivery_method": "direct_to_billing_provider",\n }],\n)\nprint(response.data)', }, java: { method: 'v1().customers().setBillingConfigurations', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerSetBillingConfigurationsParams;\nimport com.metronome.api.models.v1.customers.CustomerSetBillingConfigurationsResponse;\nimport java.util.List;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerSetBillingConfigurationsParams params = CustomerSetBillingConfigurationsParams.builder()\n .data(List.of(\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.STRIPE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build(),\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.AWS_MARKETPLACE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build(),\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.AZURE_MARKETPLACE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build(),\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.AWS_MARKETPLACE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build(),\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.GCP_MARKETPLACE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build(),\n CustomerSetBillingConfigurationsParams.Data.builder()\n .billingProvider(CustomerSetBillingConfigurationsParams.Data.BillingProvider.NETSUITE)\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .build()\n ))\n .build();\n CustomerSetBillingConfigurationsResponse response = client.v1().customers().setBillingConfigurations(params);\n }\n}', }, go: { method: 'client.V1.Customers.SetBillingConfigurations', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.SetBillingConfigurations(context.TODO(), metronome.V1CustomerSetBillingConfigurationsParams{\n\t\tData: []metronome.V1CustomerSetBillingConfigurationsParamsData{{\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "stripe",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"stripe_customer_id": "cus_1234",\n\t\t\t\t"stripe_collection_method": "charge_automatically",\n\t\t\t\t"leave_stripe_invoices_in_draft": true,\n\t\t\t},\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t}, {\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "aws_marketplace",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"aws_customer_id": "ABC123ABC12",\n\t\t\t\t"aws_product_code": "my_product",\n\t\t\t\t"aws_region": "us-west-1",\n\t\t\t},\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t}, {\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "azure_marketplace",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"azure_subscription_id": "my_subscription",\n\t\t\t},\n\t\t\tDeliveryMethodID: metronome.String("5b9e3072-415b-4842-94f0-0b6700c8b6be"),\n\t\t}, {\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "aws_marketplace",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"aws_customer_id": "ABC123ABC12",\n\t\t\t\t"aws_product_code": "my_product",\n\t\t\t\t"aws_region": "us-west-1",\n\t\t\t\t"aws_is_subscription_product": true,\n\t\t\t},\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t}, {\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "gcp_marketplace",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"gcp_entitlement_id": "my_entitlement",\n\t\t\t\t"gcp_service_name": "my.service.endpoint.goog",\n\t\t\t},\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t}, {\n\t\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\t\tBillingProvider: "netsuite",\n\t\t\tConfiguration: map[string]any{\n\t\t\t\t"netsuite_customer_id": "12345",\n\t\t\t},\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.set_billing_configurations', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.set_billing_configurations(\n data: [\n {billing_provider: :stripe, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"},\n {billing_provider: :aws_marketplace, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"},\n {billing_provider: :azure_marketplace, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"},\n {billing_provider: :aws_marketplace, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"},\n {billing_provider: :gcp_marketplace, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"},\n {billing_provider: :netsuite, customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491"}\n ]\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/setCustomerBillingProviderConfigurations \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "data": [\n {\n "billing_provider": "stripe",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "stripe_customer_id": "bar",\n "stripe_collection_method": "bar",\n "leave_stripe_invoices_in_draft": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n },\n {\n "billing_provider": "aws_marketplace",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "aws_customer_id": "bar",\n "aws_product_code": "bar",\n "aws_region": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n },\n {\n "billing_provider": "azure_marketplace",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "azure_subscription_id": "bar"\n },\n "delivery_method_id": "5b9e3072-415b-4842-94f0-0b6700c8b6be"\n },\n {\n "billing_provider": "aws_marketplace",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "aws_customer_id": "bar",\n "aws_product_code": "bar",\n "aws_region": "bar",\n "aws_is_subscription_product": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n },\n {\n "billing_provider": "gcp_marketplace",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "gcp_entitlement_id": "bar",\n "gcp_service_name": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n },\n {\n "billing_provider": "netsuite",\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "configuration": {\n "netsuite_customer_id": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n }\n ]\n }\'', }, }, }, { name: 'retrieve_billing_configurations', endpoint: '/v1/getCustomerBillingProviderConfigurations', httpMethod: 'post', summary: 'Fetch billing provider configurations for a customer', description: 'Returns all billing configurations previously set for the customer. Use during the contract provisioning process to fetch the `billing_provider_configuration_id` needed to set the contract billing configuration.\n', stainlessPath: '(resource) v1.customers > (method) retrieve_billing_configurations', qualified: 'client.v1.customers.retrieveBillingConfigurations', params: ['customer_id: string;', 'include_archived?: boolean;'], response: "{ data: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]; }", markdown: "## retrieve_billing_configurations\n\n`client.v1.customers.retrieveBillingConfigurations(customer_id: string, include_archived?: boolean): { data: object[]; }`\n\n**post** `/v1/getCustomerBillingProviderConfigurations`\n\nReturns all billing configurations previously set for the customer. Use during the contract provisioning process to fetch the `billing_provider_configuration_id` needed to set the contract billing configuration.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `include_archived?: boolean`\n\n### Returns\n\n- `{ data: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]; }`\n\n - `data: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.retrieveBillingConfigurations({ customer_id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.retrieveBillingConfigurations', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.retrieveBillingConfigurations({\n customer_id: '6a37bb88-8538-48c5-b37b-a41c836328bd',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.retrieve_billing_configurations', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.retrieve_billing_configurations(\n customer_id="6a37bb88-8538-48c5-b37b-a41c836328bd",\n)\nprint(response.data)', }, java: { method: 'v1().customers().retrieveBillingConfigurations', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerRetrieveBillingConfigurationsParams;\nimport com.metronome.api.models.v1.customers.CustomerRetrieveBillingConfigurationsResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerRetrieveBillingConfigurationsParams params = CustomerRetrieveBillingConfigurationsParams.builder()\n .customerId("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\n CustomerRetrieveBillingConfigurationsResponse response = client.v1().customers().retrieveBillingConfigurations(params);\n }\n}', }, go: { method: 'client.V1.Customers.GetBillingConfigurations', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.GetBillingConfigurations(context.TODO(), metronome.V1CustomerGetBillingConfigurationsParams{\n\t\tCustomerID: "6a37bb88-8538-48c5-b37b-a41c836328bd",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.retrieve_billing_configurations', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.retrieve_billing_configurations(\n customer_id: "6a37bb88-8538-48c5-b37b-a41c836328bd"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/getCustomerBillingProviderConfigurations \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "6a37bb88-8538-48c5-b37b-a41c836328bd"\n }\'', }, }, }, { name: 'archive_billing_configurations', endpoint: '/v1/archiveCustomerBillingProviderConfigurations', httpMethod: 'post', summary: 'Archive billing provider configurations for a customer', description: 'Deprecate an existing billing configuration for a customer to handle churn or billing and collection preference changes. Archiving a billing configuration takes effect immediately. If there are active contracts using the configuration, Metronome will archive the configuration on the contract and immediately stop metering to downstream systems.\n\n### Use this endpoint to:\n- Remove billing provider customer data and configurations when no longer needed\n- Clean up test or deprecated billing provider configurations\n- Free up uniqueness keys for reuse with new billing provider configurations\n- Disable threshold recharge configurations associated with archived billing providers\n\n### Key response fields:\nA successful response returns:\n- `success`: Boolean indicating the operation completed successfully\n- `error`: Null on success, error message on failure\n\n### Usage guidelines:\n- Archiving a contract configuration during a grace period will result in the invoice not being sent to the customer\n- Automatically disables both spend-based and credit-based threshold recharge configurations for contracts using the archived billing provider \n- You can archive multiple configurations for a single customer in a single request, but any validation failures for an individual configuration will prevent the entire operation from succeeding\n', stainlessPath: '(resource) v1.customers > (method) archive_billing_configurations', qualified: 'client.v1.customers.archiveBillingConfigurations', params: ['customer_billing_provider_configuration_ids: string[];', 'customer_id: string;'], response: '{ data: { customer_billing_provider_configuration_ids: string[]; customer_id: string; }; }', markdown: "## archive_billing_configurations\n\n`client.v1.customers.archiveBillingConfigurations(customer_billing_provider_configuration_ids: string[], customer_id: string): { data: object; }`\n\n**post** `/v1/archiveCustomerBillingProviderConfigurations`\n\nDeprecate an existing billing configuration for a customer to handle churn or billing and collection preference changes. Archiving a billing configuration takes effect immediately. If there are active contracts using the configuration, Metronome will archive the configuration on the contract and immediately stop metering to downstream systems.\n\n### Use this endpoint to:\n- Remove billing provider customer data and configurations when no longer needed\n- Clean up test or deprecated billing provider configurations\n- Free up uniqueness keys for reuse with new billing provider configurations\n- Disable threshold recharge configurations associated with archived billing providers\n\n### Key response fields:\nA successful response returns:\n- `success`: Boolean indicating the operation completed successfully\n- `error`: Null on success, error message on failure\n\n### Usage guidelines:\n- Archiving a contract configuration during a grace period will result in the invoice not being sent to the customer\n- Automatically disables both spend-based and credit-based threshold recharge configurations for contracts using the archived billing provider \n- You can archive multiple configurations for a single customer in a single request, but any validation failures for an individual configuration will prevent the entire operation from succeeding\n\n\n### Parameters\n\n- `customer_billing_provider_configuration_ids: string[]`\n Array of billing provider configuration IDs to archive\n\n- `customer_id: string`\n The customer ID the billing provider configurations belong to\n\n### Returns\n\n- `{ data: { customer_billing_provider_configuration_ids: string[]; customer_id: string; }; }`\n\n - `data: { customer_billing_provider_configuration_ids: string[]; customer_id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.archiveBillingConfigurations({ customer_billing_provider_configuration_ids: ['4db51251-61de-4bfe-b9ce-495e244f3491', '4db51251-61de-4bfe-b9ce-495e244f3491'], customer_id: '20a060d1-aa80-41d4-8bb2-4f3091b93903' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.archiveBillingConfigurations', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.archiveBillingConfigurations({\n customer_billing_provider_configuration_ids: [\n '4db51251-61de-4bfe-b9ce-495e244f3491',\n '4db51251-61de-4bfe-b9ce-495e244f3491',\n ],\n customer_id: '20a060d1-aa80-41d4-8bb2-4f3091b93903',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.archive_billing_configurations', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.archive_billing_configurations(\n customer_billing_provider_configuration_ids=["4db51251-61de-4bfe-b9ce-495e244f3491", "4db51251-61de-4bfe-b9ce-495e244f3491"],\n customer_id="20a060d1-aa80-41d4-8bb2-4f3091b93903",\n)\nprint(response.data)', }, java: { method: 'v1().customers().archiveBillingConfigurations', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.CustomerArchiveBillingConfigurationsParams;\nimport com.metronome.api.models.v1.customers.CustomerArchiveBillingConfigurationsResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomerArchiveBillingConfigurationsParams params = CustomerArchiveBillingConfigurationsParams.builder()\n .addCustomerBillingProviderConfigurationId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .addCustomerBillingProviderConfigurationId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .customerId("20a060d1-aa80-41d4-8bb2-4f3091b93903")\n .build();\n CustomerArchiveBillingConfigurationsResponse response = client.v1().customers().archiveBillingConfigurations(params);\n }\n}', }, go: { method: 'client.V1.Customers.ArchiveBillingConfigurations', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.ArchiveBillingConfigurations(context.TODO(), metronome.V1CustomerArchiveBillingConfigurationsParams{\n\t\tCustomerBillingProviderConfigurationIDs: []string{"4db51251-61de-4bfe-b9ce-495e244f3491", "4db51251-61de-4bfe-b9ce-495e244f3491"},\n\t\tCustomerID: "20a060d1-aa80-41d4-8bb2-4f3091b93903",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.archive_billing_configurations', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.archive_billing_configurations(\n customer_billing_provider_configuration_ids: ["4db51251-61de-4bfe-b9ce-495e244f3491", "4db51251-61de-4bfe-b9ce-495e244f3491"],\n customer_id: "20a060d1-aa80-41d4-8bb2-4f3091b93903"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/archiveCustomerBillingProviderConfigurations \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_billing_provider_configuration_ids": [\n "4db51251-61de-4bfe-b9ce-495e244f3491",\n "4db51251-61de-4bfe-b9ce-495e244f3491"\n ],\n "customer_id": "20a060d1-aa80-41d4-8bb2-4f3091b93903"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/customer-alerts/get', httpMethod: 'post', summary: 'Get a threshold notification', description: "Retrieve the real-time evaluation status for a specific threshold notification-customer pair. This endpoint provides instant visibility into whether a customer has triggered a threshold notification condition, enabling you to monitor account health and take proactive action based on current threshold notification states.\n\n### Use this endpoint to:\n- Check if a specific customer is currently violating an threshold notification (`in_alarm` status)\n- Verify threshold notification configuration details and threshold values for a customer\n- Monitor the evaluation state of newly created or recently modified threshold notification\n- Build dashboards or automated workflows that respond to specific threshold notification conditions\n- Validate threshold notification behavior before deploying to production customers\n- Integrate threshold notification status checks into customer support tools or admin interfaces\n\n### Key response fields: \nA CustomerAlert object containing:\n\n- `customer_status`: The current evaluation state\n\n- `ok` - Customer is within acceptable thresholds\n- `in_alarm` - Customer has breached the threshold for the notification\n- `evaluating` - Notification is currently being evaluated (typically during initial setup)\n- `null` - Notification has been archived\n- `triggered_by`: Additional context about what caused the notification to trigger (when applicable)\n- `updated_at`: Timestamp of when the `customer_status` was last updated\n- alert: Complete threshold notification configuration including:\n - Notification ID, name, and type\n - Current threshold values and credit type information\n - Notification status (enabled, disabled, or archived)\n - Any applied filters (credit grant types, custom fields, group values)\n\n### Usage guidelines:\n- Customer status: Returns the current evaluation state, not historical data. For threshold notification history, use webhook notifications or event logs\n- Required parameters: Both customer_id and alert_id must be valid UUIDs that exist in your organization\n- Archived notifications: Returns null for customer_status if the notification has been archived, but still includes the notification configuration details\n- Performance considerations: This endpoint queries live evaluation state, making it ideal for real-time monitoring but not for bulk status checks\n- Integration patterns: Best used for on-demand status checks in response to user actions or as part of targeted monitoring workflows\n- Error handling: Returns 404 if either the customer or alert_id doesn't exist or isn't accessible to your organization\n", stainlessPath: '(resource) v1.customers.alerts > (method) retrieve', qualified: 'client.v1.customers.alerts.retrieve', params: [ 'alert_id: string;', 'customer_id: string;', "alert_specifiers?: { custom_field_filters: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; exclude?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[];", 'group_values?: { key: string; value: string; }[];', "plans_or_contracts?: 'PLANS' | 'CONTRACTS';", 'seat_filter?: { seat_group_key: string; seat_group_value: string; };', ], response: "{ data: { alert: object; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }; }", markdown: "## retrieve\n\n`client.v1.customers.alerts.retrieve(alert_id: string, customer_id: string, alert_specifiers?: { custom_field_filters: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; exclude?: { custom_field_filters?: object[]; }[]; }[], group_values?: { key: string; value: string; }[], plans_or_contracts?: 'PLANS' | 'CONTRACTS', seat_filter?: { seat_group_key: string; seat_group_value: string; }): { data: customer_alert; }`\n\n**post** `/v1/customer-alerts/get`\n\nRetrieve the real-time evaluation status for a specific threshold notification-customer pair. This endpoint provides instant visibility into whether a customer has triggered a threshold notification condition, enabling you to monitor account health and take proactive action based on current threshold notification states.\n\n### Use this endpoint to:\n- Check if a specific customer is currently violating an threshold notification (`in_alarm` status)\n- Verify threshold notification configuration details and threshold values for a customer\n- Monitor the evaluation state of newly created or recently modified threshold notification\n- Build dashboards or automated workflows that respond to specific threshold notification conditions\n- Validate threshold notification behavior before deploying to production customers\n- Integrate threshold notification status checks into customer support tools or admin interfaces\n\n### Key response fields: \nA CustomerAlert object containing:\n\n- `customer_status`: The current evaluation state\n\n- `ok` - Customer is within acceptable thresholds\n- `in_alarm` - Customer has breached the threshold for the notification\n- `evaluating` - Notification is currently being evaluated (typically during initial setup)\n- `null` - Notification has been archived\n- `triggered_by`: Additional context about what caused the notification to trigger (when applicable)\n- `updated_at`: Timestamp of when the `customer_status` was last updated\n- alert: Complete threshold notification configuration including:\n - Notification ID, name, and type\n - Current threshold values and credit type information\n - Notification status (enabled, disabled, or archived)\n - Any applied filters (credit grant types, custom fields, group values)\n\n### Usage guidelines:\n- Customer status: Returns the current evaluation state, not historical data. For threshold notification history, use webhook notifications or event logs\n- Required parameters: Both customer_id and alert_id must be valid UUIDs that exist in your organization\n- Archived notifications: Returns null for customer_status if the notification has been archived, but still includes the notification configuration details\n- Performance considerations: This endpoint queries live evaluation state, making it ideal for real-time monitoring but not for bulk status checks\n- Integration patterns: Best used for on-demand status checks in response to user actions or as part of targeted monitoring workflows\n- Error handling: Returns 404 if either the customer or alert_id doesn't exist or isn't accessible to your organization\n\n\n### Parameters\n\n- `alert_id: string`\n The Metronome ID of the threshold notification\n\n- `customer_id: string`\n The Metronome ID of the customer\n\n- `alert_specifiers?: { custom_field_filters: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; exclude?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Can be used with only `low_remaining_contract_credit_and_commit_balance_reached` notifications. Used to filter the alert by the custom field key-value pair.\n\n- `group_values?: { key: string; value: string; }[]`\n Only present for `spend_threshold_reached` notifications. Retrieve the notification for a specific group key-value pair.\n\n- `plans_or_contracts?: 'PLANS' | 'CONTRACTS'`\n When parallel threshold notifications are enabled during migration, this flag denotes whether to fetch notifications for plans or contracts.\n\n- `seat_filter?: { seat_group_key: string; seat_group_value: string; }`\n Only allowed for `low_remaining_seat_balance_reached` notifications. This filters alerts by the seat group key-value pair.\n - `seat_group_key: string`\n The seat group key (e.g., \"seat_id\", \"user_id\")\n - `seat_group_value: string`\n The specific seat identifier to filter by\n\n### Returns\n\n- `{ data: { alert: object; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }; }`\n\n - `data: { alert: { id: string; name: string; status: 'enabled' | 'archived' | 'disabled'; threshold: number; type: string; updated_at: string; alert_specifiers?: { custom_field_filters?: object[]; exclude?: object[]; }[]; credit_grant_type_filters?: string[]; credit_type?: object; custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; group_key_filter?: { key: string; value: string; }; group_values?: { key: string; value?: string; }[]; invoice_types_filter?: string[]; seat_filter?: { seat_group_key: string; seat_group_value?: string; }; uniqueness_key?: string; }; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst alert = await client.v1.customers.alerts.retrieve({ alert_id: '8deed800-1b7a-495d-a207-6c52bac54dc9', customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' });\n\nconsole.log(alert);\n```", perLanguage: { typescript: { method: 'client.v1.customers.alerts.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst alert = await client.v1.customers.alerts.retrieve({\n alert_id: '8deed800-1b7a-495d-a207-6c52bac54dc9',\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n});\n\nconsole.log(alert.data);", }, python: { method: 'v1.customers.alerts.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nalert = client.v1.customers.alerts.retrieve(\n alert_id="8deed800-1b7a-495d-a207-6c52bac54dc9",\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n)\nprint(alert.data)', }, java: { method: 'v1().customers().alerts().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.alerts.AlertRetrieveParams;\nimport com.metronome.api.models.v1.customers.alerts.AlertRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AlertRetrieveParams params = AlertRetrieveParams.builder()\n .alertId("8deed800-1b7a-495d-a207-6c52bac54dc9")\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .build();\n AlertRetrieveResponse alert = client.v1().customers().alerts().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Customers.Alerts.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\talert, err := client.V1.Customers.Alerts.Get(context.TODO(), metronome.V1CustomerAlertGetParams{\n\t\tAlertID: "8deed800-1b7a-495d-a207-6c52bac54dc9",\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", alert.Data)\n}\n', }, ruby: { method: 'v1.customers.alerts.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nalert = metronome.v1.customers.alerts.retrieve(\n alert_id: "8deed800-1b7a-495d-a207-6c52bac54dc9",\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1"\n)\n\nputs(alert)', }, http: { example: 'curl https://api.metronome.com/v1/customer-alerts/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "alert_id": "8deed800-1b7a-495d-a207-6c52bac54dc9",\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/customer-alerts/list', httpMethod: 'post', summary: 'Get all threshold notifications', description: 'Retrieve all threshold notification configurations and their current statuses for a specific customer in a single API call. This endpoint provides a comprehensive view of all threshold notification monitoring a customer account.\n\n### Use this endpoint to:\n- Display all active threshold notifications for a customer in dashboards or admin panels\n- Quickly identify which threshold notifications a customer is currently triggering\n- Audit threshold notification coverage for specific accounts\n- Filter threshold notifications by status (enabled, disabled, or archived)\n\n### Key response fields:\n- data: Array of CustomerAlert objects, each containing:\n - Current evaluation status (`ok`, `in_alarm`, `evaluating`, or `null`)\n - Complete threshold notification configuration and threshold details\n - Threshold notification metadata including type, name, and last update time\n- next_page: Pagination cursor for retrieving additional results\n\n### Usage guidelines:\n- Default behavior: Returns only enabled threshold notifications unless `alert_statuses` filter is specified\n- Pagination: Use the `next_page` cursor to retrieve all results for customers with many notifications\n- Performance: Efficiently retrieves multiple threshold notification statuses in a single request instead of making individual calls\n- Filtering: Pass the `alert_statuses` array to include disabled or archived threshold notifications in results\n', stainlessPath: '(resource) v1.customers.alerts > (method) list', qualified: 'client.v1.customers.alerts.list', params: [ 'customer_id: string;', 'next_page?: string;', "alert_statuses?: 'ENABLED' | 'DISABLED' | 'ARCHIVED'[];", ], response: "{ alert: { id: string; name: string; status: 'enabled' | 'archived' | 'disabled'; threshold: number; type: string; updated_at: string; alert_specifiers?: { custom_field_filters?: object[]; exclude?: object[]; }[]; credit_grant_type_filters?: string[]; credit_type?: object; custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; group_key_filter?: { key: string; value: string; }; group_values?: { key: string; value?: string; }[]; invoice_types_filter?: string[]; seat_filter?: { seat_group_key: string; seat_group_value?: string; }; uniqueness_key?: string; }; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }", markdown: "## list\n\n`client.v1.customers.alerts.list(customer_id: string, next_page?: string, alert_statuses?: 'ENABLED' | 'DISABLED' | 'ARCHIVED'[]): { alert: object; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }`\n\n**post** `/v1/customer-alerts/list`\n\nRetrieve all threshold notification configurations and their current statuses for a specific customer in a single API call. This endpoint provides a comprehensive view of all threshold notification monitoring a customer account.\n\n### Use this endpoint to:\n- Display all active threshold notifications for a customer in dashboards or admin panels\n- Quickly identify which threshold notifications a customer is currently triggering\n- Audit threshold notification coverage for specific accounts\n- Filter threshold notifications by status (enabled, disabled, or archived)\n\n### Key response fields:\n- data: Array of CustomerAlert objects, each containing:\n - Current evaluation status (`ok`, `in_alarm`, `evaluating`, or `null`)\n - Complete threshold notification configuration and threshold details\n - Threshold notification metadata including type, name, and last update time\n- next_page: Pagination cursor for retrieving additional results\n\n### Usage guidelines:\n- Default behavior: Returns only enabled threshold notifications unless `alert_statuses` filter is specified\n- Pagination: Use the `next_page` cursor to retrieve all results for customers with many notifications\n- Performance: Efficiently retrieves multiple threshold notification statuses in a single request instead of making individual calls\n- Filtering: Pass the `alert_statuses` array to include disabled or archived threshold notifications in results\n\n\n### Parameters\n\n- `customer_id: string`\n The Metronome ID of the customer\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `alert_statuses?: 'ENABLED' | 'DISABLED' | 'ARCHIVED'[]`\n Optionally filter by threshold notification status. If absent, only enabled notifications will be returned.\n\n### Returns\n\n- `{ alert: { id: string; name: string; status: 'enabled' | 'archived' | 'disabled'; threshold: number; type: string; updated_at: string; alert_specifiers?: { custom_field_filters?: object[]; exclude?: object[]; }[]; credit_grant_type_filters?: string[]; credit_type?: object; custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; group_key_filter?: { key: string; value: string; }; group_values?: { key: string; value?: string; }[]; invoice_types_filter?: string[]; seat_filter?: { seat_group_key: string; seat_group_value?: string; }; uniqueness_key?: string; }; customer_status: 'ok' | 'in_alarm' | 'evaluating'; triggered_by?: string; }`\n\n - `alert: { id: string; name: string; status: 'enabled' | 'archived' | 'disabled'; threshold: number; type: string; updated_at: string; alert_specifiers?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value?: string; }[]; exclude?: { custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]; credit_grant_type_filters?: string[]; credit_type?: { id: string; name: string; }; custom_field_filters?: { entity: 'Contract' | 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; group_key_filter?: { key: string; value: string; }; group_values?: { key: string; value?: string; }[]; invoice_types_filter?: string[]; seat_filter?: { seat_group_key: string; seat_group_value?: string; }; uniqueness_key?: string; }`\n - `customer_status: 'ok' | 'in_alarm' | 'evaluating'`\n - `triggered_by?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const customerAlert of client.v1.customers.alerts.list({ customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' })) {\n console.log(customerAlert);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.alerts.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const customerAlert of client.v1.customers.alerts.list({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n})) {\n console.log(customerAlert.alert);\n}", }, python: { method: 'v1.customers.alerts.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.alerts.list(\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n)\npage = page.data[0]\nprint(page.alert)', }, java: { method: 'v1().customers().alerts().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.alerts.AlertListPage;\nimport com.metronome.api.models.v1.customers.alerts.AlertListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AlertListParams params = AlertListParams.builder()\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .build();\n AlertListPage page = client.v1().customers().alerts().list(params);\n }\n}', }, go: { method: 'client.V1.Customers.Alerts.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Alerts.List(context.TODO(), metronome.V1CustomerAlertListParams{\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.alerts.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.alerts.list(customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customer-alerts/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1"\n }\'', }, }, }, { name: 'reset', endpoint: '/v1/customer-alerts/reset', httpMethod: 'post', summary: 'Reset a threshold notification', description: 'Force an immediate re-evaluation of a specific threshold notification for a customer, clearing any previous state and triggering a fresh assessment against current thresholds. This endpoint ensures threshold notification accuracy after configuration changes or data corrections.\n\n### Use this endpoint to:\n- Clear false positive threshold notifications after fixing data issues\n- Re-evaluate threshold notifications after adjusting customer balances or credits\n- Test threshold notification behavior during development and debugging\n- Resolve stuck threshold notification that may be in an incorrect state\n- Trigger immediate evaluation after threshold modifications\n\n### Key response fields: \n- 200 Success: Confirmation that the threshold notification has been reset and re-evaluation initiated\n- No response body is returned - the operation completes asynchronously\n\n### Usage guidelines:\n- Immediate effect: Triggers re-evaluation instantly, which may result in new webhook notifications if thresholds are breached\n- State clearing: Removes any cached evaluation state, ensuring a fresh assessment\n- Use sparingly: Intended for exceptional cases, not routine operations\n- Asynchronous processing: The reset completes immediately, but re-evaluation happens in the background\n', stainlessPath: '(resource) v1.customers.alerts > (method) reset', qualified: 'client.v1.customers.alerts.reset', params: ['alert_id: string;', 'customer_id: string;'], markdown: "## reset\n\n`client.v1.customers.alerts.reset(alert_id: string, customer_id: string): void`\n\n**post** `/v1/customer-alerts/reset`\n\nForce an immediate re-evaluation of a specific threshold notification for a customer, clearing any previous state and triggering a fresh assessment against current thresholds. This endpoint ensures threshold notification accuracy after configuration changes or data corrections.\n\n### Use this endpoint to:\n- Clear false positive threshold notifications after fixing data issues\n- Re-evaluate threshold notifications after adjusting customer balances or credits\n- Test threshold notification behavior during development and debugging\n- Resolve stuck threshold notification that may be in an incorrect state\n- Trigger immediate evaluation after threshold modifications\n\n### Key response fields: \n- 200 Success: Confirmation that the threshold notification has been reset and re-evaluation initiated\n- No response body is returned - the operation completes asynchronously\n\n### Usage guidelines:\n- Immediate effect: Triggers re-evaluation instantly, which may result in new webhook notifications if thresholds are breached\n- State clearing: Removes any cached evaluation state, ensuring a fresh assessment\n- Use sparingly: Intended for exceptional cases, not routine operations\n- Asynchronous processing: The reset completes immediately, but re-evaluation happens in the background\n\n\n### Parameters\n\n- `alert_id: string`\n The Metronome ID of the threshold notification\n\n- `customer_id: string`\n The Metronome ID of the customer\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.alerts.reset({ alert_id: '5e8691bf-b22a-4672-922d-f80eee940f01', customer_id: '4c83caf3-8af4-44e2-9aeb-e290531726d9' })\n```", perLanguage: { typescript: { method: 'client.v1.customers.alerts.reset', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.alerts.reset({\n alert_id: '5e8691bf-b22a-4672-922d-f80eee940f01',\n customer_id: '4c83caf3-8af4-44e2-9aeb-e290531726d9',\n});", }, python: { method: 'v1.customers.alerts.reset', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.alerts.reset(\n alert_id="5e8691bf-b22a-4672-922d-f80eee940f01",\n customer_id="4c83caf3-8af4-44e2-9aeb-e290531726d9",\n)', }, java: { method: 'v1().customers().alerts().reset', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.alerts.AlertResetParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AlertResetParams params = AlertResetParams.builder()\n .alertId("5e8691bf-b22a-4672-922d-f80eee940f01")\n .customerId("4c83caf3-8af4-44e2-9aeb-e290531726d9")\n .build();\n client.v1().customers().alerts().reset(params);\n }\n}', }, go: { method: 'client.V1.Customers.Alerts.Reset', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.Alerts.Reset(context.TODO(), metronome.V1CustomerAlertResetParams{\n\t\tAlertID: "5e8691bf-b22a-4672-922d-f80eee940f01",\n\t\tCustomerID: "4c83caf3-8af4-44e2-9aeb-e290531726d9",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.alerts.reset', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.alerts.reset(\n alert_id: "5e8691bf-b22a-4672-922d-f80eee940f01",\n customer_id: "4c83caf3-8af4-44e2-9aeb-e290531726d9"\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customer-alerts/reset \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "alert_id": "5e8691bf-b22a-4672-922d-f80eee940f01",\n "customer_id": "4c83caf3-8af4-44e2-9aeb-e290531726d9"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/customers/{customer_id}/plans', httpMethod: 'get', summary: 'List customer plans', description: "List the given customer's plans in reverse-chronological order. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n", stainlessPath: '(resource) v1.customers.plans > (method) list', qualified: 'client.v1.customers.plans.list', params: ['customer_id: string;', 'limit?: number;', 'next_page?: string;'], response: '{ id: string; custom_fields: object; plan_description: string; plan_id: string; plan_name: string; starting_on: string; ending_before?: string; net_payment_terms_days?: number; trial_info?: { ending_before: string; spending_caps: { amount: number; amount_remaining: number; credit_type: credit_type_data; }[]; }; }', markdown: "## list\n\n`client.v1.customers.plans.list(customer_id: string, limit?: number, next_page?: string): { id: string; custom_fields: object; plan_description: string; plan_id: string; plan_name: string; starting_on: string; ending_before?: string; net_payment_terms_days?: number; trial_info?: object; }`\n\n**get** `/v1/customers/{customer_id}/plans`\n\nList the given customer's plans in reverse-chronological order. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ id: string; custom_fields: object; plan_description: string; plan_id: string; plan_name: string; starting_on: string; ending_before?: string; net_payment_terms_days?: number; trial_info?: { ending_before: string; spending_caps: { amount: number; amount_remaining: number; credit_type: credit_type_data; }[]; }; }`\n\n - `id: string`\n - `custom_fields: object`\n - `plan_description: string`\n - `plan_id: string`\n - `plan_name: string`\n - `starting_on: string`\n - `ending_before?: string`\n - `net_payment_terms_days?: number`\n - `trial_info?: { ending_before: string; spending_caps: { amount: number; amount_remaining: number; credit_type: { id: string; name: string; }; }[]; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const planListResponse of client.v1.customers.plans.list({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })) {\n console.log(planListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.plans.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const planListResponse of client.v1.customers.plans.list({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n})) {\n console.log(planListResponse.id);\n}", }, python: { method: 'v1.customers.plans.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.plans.list(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().plans().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.plans.PlanListPage;\nimport com.metronome.api.models.v1.customers.plans.PlanListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanListParams params = PlanListParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PlanListPage page = client.v1().customers().plans().list(params);\n }\n}', }, go: { method: 'client.V1.Customers.Plans.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Plans.List(context.TODO(), metronome.V1CustomerPlanListParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.plans.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.plans.list(customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/plans \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'add', endpoint: '/v1/customers/{customer_id}/plans/add', httpMethod: 'post', summary: 'Add a plan to a customer', description: 'Associate an existing customer with a plan for a specified date range. See the [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details on the price adjustments. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.plans > (method) add', qualified: 'client.v1.customers.plans.add', params: [ 'customer_id: string;', 'plan_id: string;', 'starting_on: string;', 'ending_before?: string;', 'net_payment_terms_days?: number;', 'overage_rate_adjustments?: { custom_credit_type_id: string; fiat_currency_credit_type_id: string; to_fiat_conversion_factor: number; }[];', "price_adjustments?: { adjustment_type: 'percentage' | 'fixed' | 'override' | 'quantity'; charge_id: string; start_period: number; quantity?: number; tier?: number; value?: number; }[];", 'trial_spec?: { length_in_days: number; spending_cap?: { amount: number; credit_type_id: string; }; };', ], response: '{ data: { id: string; }; }', markdown: "## add\n\n`client.v1.customers.plans.add(customer_id: string, plan_id: string, starting_on: string, ending_before?: string, net_payment_terms_days?: number, overage_rate_adjustments?: { custom_credit_type_id: string; fiat_currency_credit_type_id: string; to_fiat_conversion_factor: number; }[], price_adjustments?: { adjustment_type: 'percentage' | 'fixed' | 'override' | 'quantity'; charge_id: string; start_period: number; quantity?: number; tier?: number; value?: number; }[], trial_spec?: { length_in_days: number; spending_cap?: { amount: number; credit_type_id: string; }; }): { data: id; }`\n\n**post** `/v1/customers/{customer_id}/plans/add`\n\nAssociate an existing customer with a plan for a specified date range. See the [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details on the price adjustments. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `plan_id: string`\n\n- `starting_on: string`\n RFC 3339 timestamp for when the plan becomes active for this customer. Must be at 0:00 UTC (midnight).\n\n- `ending_before?: string`\n RFC 3339 timestamp for when the plan ends (exclusive) for this customer. Must be at 0:00 UTC (midnight).\n\n- `net_payment_terms_days?: number`\n Number of days after issuance of invoice after which the invoice is due (e.g. Net 30).\n\n- `overage_rate_adjustments?: { custom_credit_type_id: string; fiat_currency_credit_type_id: string; to_fiat_conversion_factor: number; }[]`\n An optional list of overage rates that override the rates of the original plan configuration. These new rates will apply to all pricing ramps.\n\n- `price_adjustments?: { adjustment_type: 'percentage' | 'fixed' | 'override' | 'quantity'; charge_id: string; start_period: number; quantity?: number; tier?: number; value?: number; }[]`\n A list of price adjustments can be applied on top of the pricing in the plans. See the [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details.\n\n- `trial_spec?: { length_in_days: number; spending_cap?: { amount: number; credit_type_id: string; }; }`\n A custom trial can be set for the customer's plan. See the [trial configuration documentation](https://docs.metronome.com/provisioning/configure-trials/) for details.\n - `length_in_days: number`\n Length of the trial period in days.\n - `spending_cap?: { amount: number; credit_type_id: string; }`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.plans.add({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n plan_id: 'd2c06dae-9549-4d7d-bc04-b78dd3d241b8',\n starting_on: '2021-02-01T00:00:00Z',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.plans.add', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.plans.add({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n plan_id: 'd2c06dae-9549-4d7d-bc04-b78dd3d241b8',\n starting_on: '2021-02-01T00:00:00Z',\n ending_before: '2022-02-01T00:00:00Z',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.plans.add', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.plans.add(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n plan_id="d2c06dae-9549-4d7d-bc04-b78dd3d241b8",\n starting_on=datetime.fromisoformat("2021-02-01T00:00:00"),\n ending_before=datetime.fromisoformat("2022-02-01T00:00:00"),\n)\nprint(response.data)', }, java: { method: 'v1().customers().plans().add', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.plans.PlanAddParams;\nimport com.metronome.api.models.v1.customers.plans.PlanAddResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanAddParams params = PlanAddParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .planId("d2c06dae-9549-4d7d-bc04-b78dd3d241b8")\n .startingOn(OffsetDateTime.parse("2021-02-01T00:00:00Z"))\n .build();\n PlanAddResponse response = client.v1().customers().plans().add(params);\n }\n}', }, go: { method: 'client.V1.Customers.Plans.Add', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Plans.Add(context.TODO(), metronome.V1CustomerPlanAddParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tPlanID: "d2c06dae-9549-4d7d-bc04-b78dd3d241b8",\n\t\tStartingOn: time.Now(),\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.plans.add', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.plans.add(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n plan_id: "d2c06dae-9549-4d7d-bc04-b78dd3d241b8",\n starting_on: "2021-02-01T00:00:00Z"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/plans/add \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "plan_id": "d2c06dae-9549-4d7d-bc04-b78dd3d241b8",\n "starting_on": "2021-02-01T00:00:00Z",\n "ending_before": "2022-02-01T00:00:00Z"\n }\'', }, }, }, { name: 'end', endpoint: '/v1/customers/{customer_id}/plans/{customer_plan_id}/end', httpMethod: 'post', summary: 'End a customer plan', description: "Change the end date of a customer's plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n", stainlessPath: '(resource) v1.customers.plans > (method) end', qualified: 'client.v1.customers.plans.end', params: [ 'customer_id: string;', 'customer_plan_id: string;', 'ending_before?: string;', 'void_invoices?: boolean;', 'void_stripe_invoices?: boolean;', ], response: '{ }', markdown: "## end\n\n`client.v1.customers.plans.end(customer_id: string, customer_plan_id: string, ending_before?: string, void_invoices?: boolean, void_stripe_invoices?: boolean): { }`\n\n**post** `/v1/customers/{customer_id}/plans/{customer_plan_id}/end`\n\nChange the end date of a customer's plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `customer_plan_id: string`\n\n- `ending_before?: string`\n RFC 3339 timestamp for when the plan ends (exclusive) for this customer. Must be at 0:00 UTC (midnight). If not provided, the plan end date will be cleared.\n\n- `void_invoices?: boolean`\n If true, plan end date can be before the last finalized invoice date. Any invoices generated after the plan end date will be voided.\n\n- `void_stripe_invoices?: boolean`\n Only applicable when void_invoices is set to true. If true, for every invoice that is voided we will also attempt to void/delete the stripe invoice (if any). Stripe invoices will be voided if finalized or deleted if still in draft state.\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.plans.end({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_plan_id: '7aa11640-0703-4600-8eb9-293f535a6b74' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.plans.end', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.plans.end({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_plan_id: '7aa11640-0703-4600-8eb9-293f535a6b74',\n ending_before: '2021-02-01T00:00:00Z',\n});\n\nconsole.log(response);", }, python: { method: 'v1.customers.plans.end', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.plans.end(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_plan_id="7aa11640-0703-4600-8eb9-293f535a6b74",\n ending_before=datetime.fromisoformat("2021-02-01T00:00:00"),\n)\nprint(response)', }, java: { method: 'v1().customers().plans().end', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.plans.PlanEndParams;\nimport com.metronome.api.models.v1.customers.plans.PlanEndResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanEndParams params = PlanEndParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerPlanId("7aa11640-0703-4600-8eb9-293f535a6b74")\n .build();\n PlanEndResponse response = client.v1().customers().plans().end(params);\n }\n}', }, go: { method: 'client.V1.Customers.Plans.End', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Plans.End(context.TODO(), metronome.V1CustomerPlanEndParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerPlanID: "7aa11640-0703-4600-8eb9-293f535a6b74",\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'v1.customers.plans.end_', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.plans.end_(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_plan_id: "7aa11640-0703-4600-8eb9-293f535a6b74"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/plans/$CUSTOMER_PLAN_ID/end \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_price_adjustments', endpoint: '/v1/customers/{customer_id}/plans/{customer_plan_id}/priceAdjustments', httpMethod: 'get', summary: 'Get the plan adjustments for a customer', description: 'Lists a customer plans adjustments. See the [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.plans > (method) list_price_adjustments', qualified: 'client.v1.customers.plans.listPriceAdjustments', params: ['customer_id: string;', 'customer_plan_id: string;', 'limit?: number;', 'next_page?: string;'], response: "{ charge_id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; prices: { adjustment_type: 'fixed' | 'quantity' | 'percentage' | 'override'; quantity?: number; tier?: number; value?: number; }[]; start_period: number; quantity?: number; }", markdown: "## list_price_adjustments\n\n`client.v1.customers.plans.listPriceAdjustments(customer_id: string, customer_plan_id: string, limit?: number, next_page?: string): { charge_id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; prices: object[]; start_period: number; quantity?: number; }`\n\n**get** `/v1/customers/{customer_id}/plans/{customer_plan_id}/priceAdjustments`\n\nLists a customer plans adjustments. See the [price adjustments documentation](https://plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `customer_plan_id: string`\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ charge_id: string; charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'; prices: { adjustment_type: 'fixed' | 'quantity' | 'percentage' | 'override'; quantity?: number; tier?: number; value?: number; }[]; start_period: number; quantity?: number; }`\n\n - `charge_id: string`\n - `charge_type: 'usage' | 'fixed' | 'composite' | 'minimum' | 'seat'`\n - `prices: { adjustment_type: 'fixed' | 'quantity' | 'percentage' | 'override'; quantity?: number; tier?: number; value?: number; }[]`\n - `start_period: number`\n - `quantity?: number`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const planListPriceAdjustmentsResponse of client.v1.customers.plans.listPriceAdjustments({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_plan_id: '7aa11640-0703-4600-8eb9-293f535a6b74' })) {\n console.log(planListPriceAdjustmentsResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.plans.listPriceAdjustments', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const planListPriceAdjustmentsResponse of client.v1.customers.plans.listPriceAdjustments(\n {\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_plan_id: '7aa11640-0703-4600-8eb9-293f535a6b74',\n },\n)) {\n console.log(planListPriceAdjustmentsResponse.charge_id);\n}", }, python: { method: 'v1.customers.plans.list_price_adjustments', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.plans.list_price_adjustments(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_plan_id="7aa11640-0703-4600-8eb9-293f535a6b74",\n)\npage = page.data[0]\nprint(page.charge_id)', }, java: { method: 'v1().customers().plans().listPriceAdjustments', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.plans.PlanListPriceAdjustmentsPage;\nimport com.metronome.api.models.v1.customers.plans.PlanListPriceAdjustmentsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PlanListPriceAdjustmentsParams params = PlanListPriceAdjustmentsParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerPlanId("7aa11640-0703-4600-8eb9-293f535a6b74")\n .build();\n PlanListPriceAdjustmentsPage page = client.v1().customers().plans().listPriceAdjustments(params);\n }\n}', }, go: { method: 'client.V1.Customers.Plans.ListPriceAdjustments', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Plans.ListPriceAdjustments(context.TODO(), metronome.V1CustomerPlanListPriceAdjustmentsParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerPlanID: "7aa11640-0703-4600-8eb9-293f535a6b74",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.plans.list_price_adjustments', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.plans.list_price_adjustments(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_plan_id: "7aa11640-0703-4600-8eb9-293f535a6b74"\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/plans/$CUSTOMER_PLAN_ID/priceAdjustments \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/customers/{customer_id}/invoices', httpMethod: 'get', summary: 'List invoices', description: "Retrieves a paginated list of invoices for a specific customer, with flexible filtering options to narrow results by status, date range, credit type, and more. This endpoint provides a comprehensive view of a customer's billing history and current charges, supporting both real-time billing dashboards and historical reporting needs.\n\n### Use this endpoint to:\n- Display historical invoice details in customer-facing dashboards or billing portals.\n- Retrieve current month draft invoices to show customers their month-to-date spend.\n- Access finalized invoices for historical billing records and payment reconciliation.\n- Validate customer pricing and credit applications for customer support queries. \n- Generate financial reports by filtering invoices within specific date ranges\n\n### Key response fields:\nArray of invoice objects containing:\n- Invoice ID and status (DRAFT, FINALIZED, VOID)\n- Invoice type (USAGE, SCHEDULED)\n- Billing period start and end dates\n- Issue date and due date\n- Total amount, subtotal, and amount due\n- Applied credits summary\n- Contract ID reference\n- External billing provider status (if integrated with Stripe, etc.)\n- Pagination metadata `next_page` cursor\n\n### Usage guidelines:\n- The endpoint returns invoice summaries; use the Get Invoice endpoint for detailed line items\n- Draft invoices are continuously updated as new usage is reported and will show real-time spend\n- Results are ordered by creation date descending by default (newest first)\n- When filtering by date range, the filter applies to the billing period, not the issue date\n- For customers with many invoices, implement pagination to ensure all results are retrieved\nExternal billing provider statuses (like Stripe payment status) are included when applicable\n- Voided invoices are included in results by default unless filtered out by status\n", stainlessPath: '(resource) v1.customers.invoices > (method) list', qualified: 'client.v1.customers.invoices.list', params: [ 'customer_id: string;', 'contract_id?: string;', 'credit_type_id?: string;', 'ending_before?: string;', 'limit?: number;', 'next_page?: string;', 'skip_zero_qty_line_items?: boolean;', "sort?: 'date_asc' | 'date_desc';", 'starting_on?: string;', 'status?: string;', "type?: 'USAGE' | 'USAGE_CONSOLIDATED' | 'SCHEDULED';", 'webhook_notification_id?: string;', ], response: '{ id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }', markdown: "## list\n\n`client.v1.customers.invoices.list(customer_id: string, contract_id?: string, credit_type_id?: string, ending_before?: string, limit?: number, next_page?: string, skip_zero_qty_line_items?: boolean, sort?: 'date_asc' | 'date_desc', starting_on?: string, status?: string, type?: 'USAGE' | 'USAGE_CONSOLIDATED' | 'SCHEDULED', webhook_notification_id?: string): { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }`\n\n**get** `/v1/customers/{customer_id}/invoices`\n\nRetrieves a paginated list of invoices for a specific customer, with flexible filtering options to narrow results by status, date range, credit type, and more. This endpoint provides a comprehensive view of a customer's billing history and current charges, supporting both real-time billing dashboards and historical reporting needs.\n\n### Use this endpoint to:\n- Display historical invoice details in customer-facing dashboards or billing portals.\n- Retrieve current month draft invoices to show customers their month-to-date spend.\n- Access finalized invoices for historical billing records and payment reconciliation.\n- Validate customer pricing and credit applications for customer support queries. \n- Generate financial reports by filtering invoices within specific date ranges\n\n### Key response fields:\nArray of invoice objects containing:\n- Invoice ID and status (DRAFT, FINALIZED, VOID)\n- Invoice type (USAGE, SCHEDULED)\n- Billing period start and end dates\n- Issue date and due date\n- Total amount, subtotal, and amount due\n- Applied credits summary\n- Contract ID reference\n- External billing provider status (if integrated with Stripe, etc.)\n- Pagination metadata `next_page` cursor\n\n### Usage guidelines:\n- The endpoint returns invoice summaries; use the Get Invoice endpoint for detailed line items\n- Draft invoices are continuously updated as new usage is reported and will show real-time spend\n- Results are ordered by creation date descending by default (newest first)\n- When filtering by date range, the filter applies to the billing period, not the issue date\n- For customers with many invoices, implement pagination to ensure all results are retrieved\nExternal billing provider statuses (like Stripe payment status) are included when applicable\n- Voided invoices are included in results by default unless filtered out by status\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `contract_id?: string`\n Only return invoices for the specified contract\n\n- `credit_type_id?: string`\n Only return invoices for the specified credit type\n\n- `ending_before?: string`\n RFC 3339 timestamp (exclusive). Invoices will only be returned for billing periods that end before this time.\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `skip_zero_qty_line_items?: boolean`\n If set, all zero quantity line items will be filtered out of the response\n\n- `sort?: 'date_asc' | 'date_desc'`\n Invoice sort order by issued_at, e.g. date_asc or date_desc. Defaults to date_asc.\n\n- `starting_on?: string`\n RFC 3339 timestamp (inclusive). Invoices will only be returned for billing periods that start at or after this time.\n\n- `status?: string`\n Invoice status, e.g. DRAFT, FINALIZED, or VOID\n\n- `type?: 'USAGE' | 'USAGE_CONSOLIDATED' | 'SCHEDULED'`\n Filter invoices by type. Defaults to returning all invoice types.\n\n- `webhook_notification_id?: string`\n Indicates that this API request was triggered by a webhook notification with the provided ID.\n\n### Returns\n\n- `{ id: string; credit_type: { id: string; name: string; }; customer_id: string; line_items: { credit_type: object; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: object; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: object; tiers?: object[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; invoice_adjustments?: { credit_type: object; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }`\n\n - `id: string`\n - `credit_type: { id: string; name: string; }`\n - `customer_id: string`\n - `line_items: { credit_type: { id: string; name: string; }; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: { starting_at: string; ending_before?: string; }; tiers?: { price: number; quantity: number; starting_at: number; subtotal: number; }[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]`\n - `status: string`\n - `total: number`\n - `type: string`\n - `amendment_id?: string`\n - `billable_status?: object`\n - `constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]`\n - `contract_custom_fields?: object`\n - `contract_id?: string`\n - `correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; }`\n - `created_at?: string`\n - `custom_fields?: object`\n - `customer_custom_fields?: object`\n - `end_timestamp?: string`\n - `external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }`\n - `invoice_adjustments?: { credit_type: { id: string; name: string; }; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]`\n - `issued_at?: string`\n - `net_payment_terms_days?: number`\n - `netsuite_sales_order_id?: string`\n - `payer?: { contract_id: string; customer_id: string; }`\n - `plan_custom_fields?: object`\n - `plan_id?: string`\n - `plan_name?: string`\n - `regenerated_from_invoice_id?: string`\n - `reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }`\n - `revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]`\n - `salesforce_opportunity_id?: string`\n - `start_timestamp?: string`\n - `subtotal?: number`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const invoice of client.v1.customers.invoices.list({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' })) {\n console.log(invoice);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.invoices.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const invoice of client.v1.customers.invoices.list({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n})) {\n console.log(invoice.id);\n}", }, python: { method: 'v1.customers.invoices.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.invoices.list(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().invoices().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceListPage;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceListParams params = InvoiceListParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n InvoiceListPage page = client.v1().customers().invoices().list(params);\n }\n}', }, go: { method: 'client.V1.Customers.Invoices.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Invoices.List(context.TODO(), metronome.V1CustomerInvoiceListParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.invoices.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.invoices.list(customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/invoices \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'retrieve', endpoint: '/v1/customers/{customer_id}/invoices/{invoice_id}', httpMethod: 'get', summary: 'Get an invoice', description: 'Retrieve detailed information for a specific invoice by its unique identifier. This endpoint returns comprehensive invoice data including line items, applied credits, totals, and billing period details for both finalized and draft invoices.\n\n### Use this endpoint to:\n- Display historical invoice details in customer-facing dashboards or billing portals.\n- Retrieve current month draft invoices to show customers their month-to-date spend.\n- Access finalized invoices for historical billing records and payment reconciliation.\n- Validate customer pricing and credit applications for customer support queries. \n\n### Key response fields: \nInvoice status (DRAFT, FINALIZED, VOID)\nBilling period start and end dates\nTotal amount and amount due after credits\nDetailed line items broken down by:\n- Customer and contract information\n- Invoice line item type\n- Product/service name and ID\n- Quantity consumed\n- Unit and total price \n- Time period for usage-based charges\n- Applied credits or prepaid commitments\n\n\n### Usage guidelines:\n- Draft invoices update in real-time as usage is reported and may change before finalization\n- The response includes both usage-based line items (e.g., API calls, data processed) and scheduled charges (e.g., monthly subscriptions, commitment fees)\n- Credit and commitment applications are shown as separate line items with negative amounts\n- For voided invoices, the response will indicate VOID status but retain all original line item details\n', stainlessPath: '(resource) v1.customers.invoices > (method) retrieve', qualified: 'client.v1.customers.invoices.retrieve', params: ['customer_id: string;', 'invoice_id: string;', 'skip_zero_qty_line_items?: boolean;'], response: '{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }; }', markdown: "## retrieve\n\n`client.v1.customers.invoices.retrieve(customer_id: string, invoice_id: string, skip_zero_qty_line_items?: boolean): { data: invoice; }`\n\n**get** `/v1/customers/{customer_id}/invoices/{invoice_id}`\n\nRetrieve detailed information for a specific invoice by its unique identifier. This endpoint returns comprehensive invoice data including line items, applied credits, totals, and billing period details for both finalized and draft invoices.\n\n### Use this endpoint to:\n- Display historical invoice details in customer-facing dashboards or billing portals.\n- Retrieve current month draft invoices to show customers their month-to-date spend.\n- Access finalized invoices for historical billing records and payment reconciliation.\n- Validate customer pricing and credit applications for customer support queries. \n\n### Key response fields: \nInvoice status (DRAFT, FINALIZED, VOID)\nBilling period start and end dates\nTotal amount and amount due after credits\nDetailed line items broken down by:\n- Customer and contract information\n- Invoice line item type\n- Product/service name and ID\n- Quantity consumed\n- Unit and total price \n- Time period for usage-based charges\n- Applied credits or prepaid commitments\n\n\n### Usage guidelines:\n- Draft invoices update in real-time as usage is reported and may change before finalization\n- The response includes both usage-based line items (e.g., API calls, data processed) and scheduled charges (e.g., monthly subscriptions, commitment fees)\n- Credit and commitment applications are shown as separate line items with negative amounts\n- For voided invoices, the response will indicate VOID status but retain all original line item details\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `invoice_id: string`\n\n- `skip_zero_qty_line_items?: boolean`\n If set, all zero quantity line items will be filtered out of the response\n\n### Returns\n\n- `{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }; }`\n\n - `data: { id: string; credit_type: { id: string; name: string; }; customer_id: string; line_items: { credit_type: object; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: object; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: object; tiers?: object[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; invoice_adjustments?: { credit_type: object; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst invoice = await client.v1.customers.invoices.retrieve({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(invoice);\n```", perLanguage: { typescript: { method: 'client.v1.customers.invoices.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst invoice = await client.v1.customers.invoices.retrieve({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd',\n});\n\nconsole.log(invoice.data);", }, python: { method: 'v1.customers.invoices.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ninvoice = client.v1.customers.invoices.retrieve(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n invoice_id="6a37bb88-8538-48c5-b37b-a41c836328bd",\n)\nprint(invoice.data)', }, java: { method: 'v1().customers().invoices().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceRetrieveParams;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceRetrieveParams params = InvoiceRetrieveParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .invoiceId("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\n InvoiceRetrieveResponse invoice = client.v1().customers().invoices().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Customers.Invoices.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tinvoice, err := client.V1.Customers.Invoices.Get(context.TODO(), metronome.V1CustomerInvoiceGetParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tInvoiceID: "6a37bb88-8538-48c5-b37b-a41c836328bd",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", invoice.Data)\n}\n', }, ruby: { method: 'v1.customers.invoices.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ninvoice = metronome.v1.customers.invoices.retrieve(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n invoice_id: "6a37bb88-8538-48c5-b37b-a41c836328bd"\n)\n\nputs(invoice)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/invoices/$INVOICE_ID \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'add_charge', endpoint: '/v1/customers/{customer_id}/addCharge', httpMethod: 'post', summary: 'Add a one time charge', description: 'Add a one time charge to the specified invoice. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.invoices > (method) add_charge', qualified: 'client.v1.customers.invoices.addCharge', params: [ 'customer_id: string;', 'charge_id: string;', 'customer_plan_id: string;', 'description: string;', 'invoice_start_timestamp: string;', 'price: number;', 'quantity: number;', ], response: '{ }', markdown: "## add_charge\n\n`client.v1.customers.invoices.addCharge(customer_id: string, charge_id: string, customer_plan_id: string, description: string, invoice_start_timestamp: string, price: number, quantity: number): { }`\n\n**post** `/v1/customers/{customer_id}/addCharge`\n\nAdd a one time charge to the specified invoice. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `charge_id: string`\n The Metronome ID of the charge to add to the invoice. Note that the charge must be on a product that is not on the current plan, and the product must have only fixed charges.\n\n- `customer_plan_id: string`\n The Metronome ID of the customer plan to add the charge to.\n\n- `description: string`\n\n- `invoice_start_timestamp: string`\n The start_timestamp of the invoice to add the charge to.\n\n- `price: number`\n The price of the charge. This price will match the currency on the invoice, e.g. USD cents.\n\n- `quantity: number`\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.invoices.addCharge({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n charge_id: '5ae4b726-1ebe-439c-9190-9831760ba195',\n customer_plan_id: 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015',\n description: 'One time charge',\n invoice_start_timestamp: '2024-01-01T00:00:00Z',\n price: 250,\n quantity: 1,\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.invoices.addCharge', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.invoices.addCharge({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n charge_id: '5ae4b726-1ebe-439c-9190-9831760ba195',\n customer_plan_id: 'a23b3cf4-47fb-4c3f-bb3d-9e64f7704015',\n description: 'One time charge',\n invoice_start_timestamp: '2024-01-01T00:00:00Z',\n price: 250,\n quantity: 1,\n});\n\nconsole.log(response);", }, python: { method: 'v1.customers.invoices.add_charge', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.invoices.add_charge(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n charge_id="5ae4b726-1ebe-439c-9190-9831760ba195",\n customer_plan_id="a23b3cf4-47fb-4c3f-bb3d-9e64f7704015",\n description="One time charge",\n invoice_start_timestamp=datetime.fromisoformat("2024-01-01T00:00:00"),\n price=250,\n quantity=1,\n)\nprint(response)', }, java: { method: 'v1().customers().invoices().addCharge', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceAddChargeParams;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceAddChargeResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceAddChargeParams params = InvoiceAddChargeParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .chargeId("5ae4b726-1ebe-439c-9190-9831760ba195")\n .customerPlanId("a23b3cf4-47fb-4c3f-bb3d-9e64f7704015")\n .description("One time charge")\n .invoiceStartTimestamp(OffsetDateTime.parse("2024-01-01T00:00:00Z"))\n .price(250.0)\n .quantity(1.0)\n .build();\n InvoiceAddChargeResponse response = client.v1().customers().invoices().addCharge(params);\n }\n}', }, go: { method: 'client.V1.Customers.Invoices.AddCharge', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Invoices.AddCharge(context.TODO(), metronome.V1CustomerInvoiceAddChargeParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tChargeID: "5ae4b726-1ebe-439c-9190-9831760ba195",\n\t\tCustomerPlanID: "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015",\n\t\tDescription: "One time charge",\n\t\tInvoiceStartTimestamp: time.Now(),\n\t\tPrice: 250,\n\t\tQuantity: 1,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'v1.customers.invoices.add_charge', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.invoices.add_charge(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n charge_id: "5ae4b726-1ebe-439c-9190-9831760ba195",\n customer_plan_id: "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015",\n description: "One time charge",\n invoice_start_timestamp: "2024-01-01T00:00:00Z",\n price: 250,\n quantity: 1\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/addCharge \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "charge_id": "5ae4b726-1ebe-439c-9190-9831760ba195",\n "customer_plan_id": "a23b3cf4-47fb-4c3f-bb3d-9e64f7704015",\n "description": "One time charge",\n "invoice_start_timestamp": "2024-01-01T00:00:00Z",\n "price": 250,\n "quantity": 1\n }\'', }, }, }, { name: 'list_breakdowns', endpoint: '/v1/customers/{customer_id}/invoices/breakdowns', httpMethod: 'get', summary: 'List invoice breakdowns', description: 'Retrieve granular time-series breakdowns of invoice data at hourly or daily intervals. This endpoint transforms standard invoices into detailed timelines, enabling you to track usage patterns, identify consumption spikes, and provide customers with transparency into their billing details throughout the billing period.\n\n### Use this endpoint to:\n- Build usage analytics dashboards showing daily or hourly consumption trends\n- Identify peak usage periods for capacity planning and cost optimization\n- Generate detailed billing reports for finance teams and customer success\n- Troubleshoot billing disputes by examining usage patterns at specific times\n- Power real-time cost monitoring and alerting systems\n\n### Key response fields:\nAn array of BreakdownInvoice objects, each containing:\n- All standard invoice fields (ID, customer, commit, line items, totals, status)\n- Line items with quantities and costs for that specific period\n- `breakdown_start_timestamp`: Start of the specific time window\n- `breakdown_end_timestamp`: End of the specific time window\n- `next_page`: Pagination cursor for large result sets\n\n### Usage guidelines:\n- Time granularity: Set `window_size` to hour or day based on your analysis needs\n- Response limits: Daily breakdowns return up to 35 days; hourly breakdowns return up to 24 hours per request\n- Date filtering: Use `starting_on` and `ending_before` to focus on specific periods\n- Performance: For large date ranges, use pagination to retrieve all data efficiently\n- Backdated usage: If usage events arrive after invoice finalization, breakdowns will reflect the updated usage\n- Zero quantity filtering: Use `skip_zero_qty_line_items=true` to exclude periods with no usage', stainlessPath: '(resource) v1.customers.invoices > (method) list_breakdowns', qualified: 'client.v1.customers.invoices.listBreakdowns', params: [ 'customer_id: string;', 'ending_before: string;', 'starting_on: string;', 'credit_type_id?: string;', 'limit?: number;', 'next_page?: string;', 'skip_zero_qty_line_items?: boolean;', "sort?: 'date_asc' | 'date_desc';", 'status?: string;', "window_size?: 'HOUR' | 'DAY';", ], response: '{ id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }', markdown: "## list_breakdowns\n\n`client.v1.customers.invoices.listBreakdowns(customer_id: string, ending_before: string, starting_on: string, credit_type_id?: string, limit?: number, next_page?: string, skip_zero_qty_line_items?: boolean, sort?: 'date_asc' | 'date_desc', status?: string, window_size?: 'HOUR' | 'DAY'): object`\n\n**get** `/v1/customers/{customer_id}/invoices/breakdowns`\n\nRetrieve granular time-series breakdowns of invoice data at hourly or daily intervals. This endpoint transforms standard invoices into detailed timelines, enabling you to track usage patterns, identify consumption spikes, and provide customers with transparency into their billing details throughout the billing period.\n\n### Use this endpoint to:\n- Build usage analytics dashboards showing daily or hourly consumption trends\n- Identify peak usage periods for capacity planning and cost optimization\n- Generate detailed billing reports for finance teams and customer success\n- Troubleshoot billing disputes by examining usage patterns at specific times\n- Power real-time cost monitoring and alerting systems\n\n### Key response fields:\nAn array of BreakdownInvoice objects, each containing:\n- All standard invoice fields (ID, customer, commit, line items, totals, status)\n- Line items with quantities and costs for that specific period\n- `breakdown_start_timestamp`: Start of the specific time window\n- `breakdown_end_timestamp`: End of the specific time window\n- `next_page`: Pagination cursor for large result sets\n\n### Usage guidelines:\n- Time granularity: Set `window_size` to hour or day based on your analysis needs\n- Response limits: Daily breakdowns return up to 35 days; hourly breakdowns return up to 24 hours per request\n- Date filtering: Use `starting_on` and `ending_before` to focus on specific periods\n- Performance: For large date ranges, use pagination to retrieve all data efficiently\n- Backdated usage: If usage events arrive after invoice finalization, breakdowns will reflect the updated usage\n- Zero quantity filtering: Use `skip_zero_qty_line_items=true` to exclude periods with no usage\n\n### Parameters\n\n- `customer_id: string`\n\n- `ending_before: string`\n RFC 3339 timestamp. Breakdowns will only be returned for time windows that end on or before this time.\n\n- `starting_on: string`\n RFC 3339 timestamp. Breakdowns will only be returned for time windows that start on or after this time.\n\n- `credit_type_id?: string`\n Only return invoices for the specified credit type\n\n- `limit?: number`\n Max number of results that should be returned. For daily breakdowns, the response can return up to 35 days worth of breakdowns. For hourly breakdowns, the response can return up to 24 hours. If there are more results, a cursor to the next page is returned.\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `skip_zero_qty_line_items?: boolean`\n If set, all zero quantity line items will be filtered out of the response\n\n- `sort?: 'date_asc' | 'date_desc'`\n Invoice sort order by issued_at, e.g. date_asc or date_desc. Defaults to date_asc.\n\n- `status?: string`\n Invoice status, e.g. DRAFT or FINALIZED\n\n- `window_size?: 'HOUR' | 'DAY'`\n The granularity of the breakdowns to return. Defaults to day.\n\n### Returns\n\n- `{ id: string; credit_type: object; customer_id: string; line_items: { credit_type: credit_type_data; name: string; total: number; type: string; applied_commit_or_credit?: object; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: rate; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: object; postpaid_commit?: object; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: object[]; subscription_custom_fields?: object; subscription_id?: string; tier?: object; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: object; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; invoice_adjustments?: { credit_type: credit_type_data; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: object; gcp_options?: object; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const invoiceListBreakdownsResponse of client.v1.customers.invoices.listBreakdowns({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n ending_before: '2019-12-27T18:11:19.117Z',\n starting_on: '2019-12-27T18:11:19.117Z',\n})) {\n console.log(invoiceListBreakdownsResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.invoices.listBreakdowns', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const invoiceListBreakdownsResponse of client.v1.customers.invoices.listBreakdowns({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n ending_before: '2019-12-27T18:11:19.117Z',\n starting_on: '2019-12-27T18:11:19.117Z',\n})) {\n console.log(invoiceListBreakdownsResponse);\n}", }, python: { method: 'v1.customers.invoices.list_breakdowns', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.invoices.list_breakdowns(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ending_before=datetime.fromisoformat("2019-12-27T18:11:19.117"),\n starting_on=datetime.fromisoformat("2019-12-27T18:11:19.117"),\n)\npage = page.data[0]\nprint(page)', }, java: { method: 'v1().customers().invoices().listBreakdowns', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceListBreakdownsPage;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceListBreakdownsParams;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceListBreakdownsParams params = InvoiceListBreakdownsParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .endingBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))\n .startingOn(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))\n .build();\n InvoiceListBreakdownsPage page = client.v1().customers().invoices().listBreakdowns(params);\n }\n}', }, go: { method: 'client.V1.Customers.Invoices.ListBreakdowns', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Invoices.ListBreakdowns(context.TODO(), metronome.V1CustomerInvoiceListBreakdownsParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tEndingBefore: time.Now(),\n\t\tStartingOn: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.invoices.list_breakdowns', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.invoices.list_breakdowns(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n ending_before: "2019-12-27T18:11:19.117Z",\n starting_on: "2019-12-27T18:11:19.117Z"\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/invoices/breakdowns \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'retrieve_pdf', endpoint: '/v1/customers/{customer_id}/invoices/{invoice_id}/pdf', httpMethod: 'get', summary: 'Get an invoice PDF', description: 'Retrieve a PDF version of a specific invoice by its unique identifier. This endpoint generates a professionally formatted invoice document suitable for sharing with customers, accounting teams, or for record-keeping purposes.\n\n### Use this endpoint to:\n- Provide customers with downloadable or emailable copies of their invoices\n- Support accounting and finance teams with official billing documents\n- Maintain accurate records of billing transactions for audits and compliance\n\n### Key response details:\n- The response is a binary PDF file representing the full invoice\n- The PDF includes all standard invoice information such as line items, totals, billing period, and customer details\n- The document is formatted for clarity and professionalism, suitable for official use\n\n### Usage guidelines:\n- Ensure the `invoice_id` corresponds to an existing invoice for the specified `customer_id`\n- The PDF is generated on-demand; frequent requests for the same invoice may impact performance\n- Use appropriate headers to handle the binary response in your application (e.g., setting `Content-Type: application/pdf`)\n', stainlessPath: '(resource) v1.customers.invoices > (method) retrieve_pdf', qualified: 'client.v1.customers.invoices.retrievePdf', params: ['customer_id: string;', 'invoice_id: string;'], response: 'string', markdown: "## retrieve_pdf\n\n`client.v1.customers.invoices.retrievePdf(customer_id: string, invoice_id: string): string`\n\n**get** `/v1/customers/{customer_id}/invoices/{invoice_id}/pdf`\n\nRetrieve a PDF version of a specific invoice by its unique identifier. This endpoint generates a professionally formatted invoice document suitable for sharing with customers, accounting teams, or for record-keeping purposes.\n\n### Use this endpoint to:\n- Provide customers with downloadable or emailable copies of their invoices\n- Support accounting and finance teams with official billing documents\n- Maintain accurate records of billing transactions for audits and compliance\n\n### Key response details:\n- The response is a binary PDF file representing the full invoice\n- The PDF includes all standard invoice information such as line items, totals, billing period, and customer details\n- The document is formatted for clarity and professionalism, suitable for official use\n\n### Usage guidelines:\n- Ensure the `invoice_id` corresponds to an existing invoice for the specified `customer_id`\n- The PDF is generated on-demand; frequent requests for the same invoice may impact performance\n- Use appropriate headers to handle the binary response in your application (e.g., setting `Content-Type: application/pdf`)\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `invoice_id: string`\n\n### Returns\n\n- `string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.invoices.retrievePdf({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(response);\n\nconst content = await response.blob()\nconsole.log(content)\n```", perLanguage: { typescript: { method: 'client.v1.customers.invoices.retrievePdf', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.invoices.retrievePdf({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n invoice_id: '6a37bb88-8538-48c5-b37b-a41c836328bd',\n});\n\nconsole.log(response);\n\nconst content = await response.blob();\nconsole.log(content);", }, python: { method: 'v1.customers.invoices.retrieve_pdf', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.invoices.retrieve_pdf(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n invoice_id="6a37bb88-8538-48c5-b37b-a41c836328bd",\n)\nprint(response)\ncontent = response.read()\nprint(content)', }, java: { method: 'v1().customers().invoices().retrievePdf', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.http.HttpResponse;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceRetrievePdfParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceRetrievePdfParams params = InvoiceRetrievePdfParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .invoiceId("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\n HttpResponse response = client.v1().customers().invoices().retrievePdf(params);\n }\n}', }, go: { method: 'client.V1.Customers.Invoices.GetPdf', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Invoices.GetPdf(context.TODO(), metronome.V1CustomerInvoiceGetPdfParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tInvoiceID: "6a37bb88-8538-48c5-b37b-a41c836328bd",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'v1.customers.invoices.retrieve_pdf', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.invoices.retrieve_pdf(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n invoice_id: "6a37bb88-8538-48c5-b37b-a41c836328bd"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/invoices/$INVOICE_ID/pdf \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'retrieve', endpoint: '/v1/customers/{customer_id}/billing-config/{billing_provider_type}', httpMethod: 'get', summary: 'Get a customer billing configuration', description: 'Fetch the billing configuration for the given customer. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.billing_config > (method) retrieve', qualified: 'client.v1.customers.billingConfig.retrieve', params: ['customer_id: string;', 'billing_provider_type: string;'], response: "{ data: { aws_customer_account_id?: string; aws_customer_id?: string; aws_expiration_date?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; azure_expiration_date?: string; azure_plan_id?: string; azure_start_date?: string; azure_subscription_status?: 'Subscribed' | 'Unsubscribed' | 'Suspended' | 'PendingFulfillmentStart'; billing_provider_customer_id?: string; stripe_collection_method?: string; }; }", markdown: "## retrieve\n\n`client.v1.customers.billingConfig.retrieve(customer_id: string, billing_provider_type: string): { data: object; }`\n\n**get** `/v1/customers/{customer_id}/billing-config/{billing_provider_type}`\n\nFetch the billing configuration for the given customer. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `billing_provider_type: string`\n\n### Returns\n\n- `{ data: { aws_customer_account_id?: string; aws_customer_id?: string; aws_expiration_date?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; azure_expiration_date?: string; azure_plan_id?: string; azure_start_date?: string; azure_subscription_status?: 'Subscribed' | 'Unsubscribed' | 'Suspended' | 'PendingFulfillmentStart'; billing_provider_customer_id?: string; stripe_collection_method?: string; }; }`\n\n - `data: { aws_customer_account_id?: string; aws_customer_id?: string; aws_expiration_date?: string; aws_is_subscription_product?: boolean; aws_product_code?: string; aws_region?: string; azure_expiration_date?: string; azure_plan_id?: string; azure_start_date?: string; azure_subscription_status?: 'Subscribed' | 'Unsubscribed' | 'Suspended' | 'PendingFulfillmentStart'; billing_provider_customer_id?: string; stripe_collection_method?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst billingConfig = await client.v1.customers.billingConfig.retrieve({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', billing_provider_type: 'stripe' });\n\nconsole.log(billingConfig);\n```", perLanguage: { typescript: { method: 'client.v1.customers.billingConfig.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst billingConfig = await client.v1.customers.billingConfig.retrieve({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n billing_provider_type: 'stripe',\n});\n\nconsole.log(billingConfig.data);", }, python: { method: 'v1.customers.billing_config.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nbilling_config = client.v1.customers.billing_config.retrieve(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type="stripe",\n)\nprint(billing_config.data)', }, java: { method: 'v1().customers().billingConfig().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.billingconfig.BillingConfigRetrieveParams;\nimport com.metronome.api.models.v1.customers.billingconfig.BillingConfigRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillingConfigRetrieveParams params = BillingConfigRetrieveParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .billingProviderType(BillingConfigRetrieveParams.BillingProviderType.STRIPE)\n .build();\n BillingConfigRetrieveResponse billingConfig = client.v1().customers().billingConfig().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Customers.BillingConfig.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tbillingConfig, err := client.V1.Customers.BillingConfig.Get(context.TODO(), metronome.V1CustomerBillingConfigGetParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tBillingProviderType: metronome.V1CustomerBillingConfigGetParamsBillingProviderTypeStripe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", billingConfig.Data)\n}\n', }, ruby: { method: 'v1.customers.billing_config.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nbilling_config = metronome.v1.customers.billing_config.retrieve(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type: :stripe\n)\n\nputs(billing_config)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/billing-config/$BILLING_PROVIDER_TYPE \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/customers/{customer_id}/billing-config/{billing_provider_type}', httpMethod: 'post', summary: 'Set a customer billing configuration', description: 'Set the billing configuration for a given customer. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.billing_config > (method) create', qualified: 'client.v1.customers.billingConfig.create', params: [ 'customer_id: string;', 'billing_provider_type: string;', 'billing_provider_customer_id: string;', 'aws_customer_account_id?: string;', 'aws_customer_id?: string;', 'aws_product_code?: string;', 'aws_region?: string;', 'stripe_collection_method?: string;', ], markdown: "## create\n\n`client.v1.customers.billingConfig.create(customer_id: string, billing_provider_type: string, billing_provider_customer_id: string, aws_customer_account_id?: string, aws_customer_id?: string, aws_product_code?: string, aws_region?: string, stripe_collection_method?: string): void`\n\n**post** `/v1/customers/{customer_id}/billing-config/{billing_provider_type}`\n\nSet the billing configuration for a given customer. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `billing_provider_type: string`\n\n- `billing_provider_customer_id: string`\n The customer ID in the billing provider's system. For Azure, this is the subscription ID.\n\n- `aws_customer_account_id?: string`\n\n- `aws_customer_id?: string`\n\n- `aws_product_code?: string`\n\n- `aws_region?: string`\n\n- `stripe_collection_method?: string`\n The collection method for the customer's invoices.\nNOTE: `auto_charge_payment_intent` and `manually_charge_payment_intent` are in beta.\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.billingConfig.create({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n billing_provider_type: 'stripe',\n billing_provider_customer_id: 'cus_AJ6y20bjkOOayM',\n})\n```", perLanguage: { typescript: { method: 'client.v1.customers.billingConfig.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.billingConfig.create({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n billing_provider_type: 'stripe',\n billing_provider_customer_id: 'cus_AJ6y20bjkOOayM',\n stripe_collection_method: 'charge_automatically',\n});", }, python: { method: 'v1.customers.billing_config.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.billing_config.create(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type="stripe",\n billing_provider_customer_id="cus_AJ6y20bjkOOayM",\n stripe_collection_method="charge_automatically",\n)', }, java: { method: 'v1().customers().billingConfig().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.billingconfig.BillingConfigCreateParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillingConfigCreateParams params = BillingConfigCreateParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .billingProviderType(BillingConfigCreateParams.BillingProviderType.STRIPE)\n .billingProviderCustomerId("cus_AJ6y20bjkOOayM")\n .build();\n client.v1().customers().billingConfig().create(params);\n }\n}', }, go: { method: 'client.V1.Customers.BillingConfig.New', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.BillingConfig.New(context.TODO(), metronome.V1CustomerBillingConfigNewParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tBillingProviderType: metronome.V1CustomerBillingConfigNewParamsBillingProviderTypeStripe,\n\t\tBillingProviderCustomerID: "cus_AJ6y20bjkOOayM",\n\t\tStripeCollectionMethod: metronome.V1CustomerBillingConfigNewParamsStripeCollectionMethodChargeAutomatically,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.billing_config.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.billing_config.create(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type: :stripe,\n billing_provider_customer_id: "cus_AJ6y20bjkOOayM"\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/billing-config/$BILLING_PROVIDER_TYPE \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "billing_provider_customer_id": "cus_AJ6y20bjkOOayM",\n "stripe_collection_method": "charge_automatically"\n }\'', }, }, }, { name: 'delete', endpoint: '/v1/customers/{customer_id}/billing-config/{billing_provider_type}', httpMethod: 'delete', summary: 'Delete a customer billing configuration', description: 'Delete the billing configuration for a given customer.\nNote: this is unsupported for Azure and AWS Marketplace customers. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n', stainlessPath: '(resource) v1.customers.billing_config > (method) delete', qualified: 'client.v1.customers.billingConfig.delete', params: ['customer_id: string;', 'billing_provider_type: string;'], markdown: "## delete\n\n`client.v1.customers.billingConfig.delete(customer_id: string, billing_provider_type: string): void`\n\n**delete** `/v1/customers/{customer_id}/billing-config/{billing_provider_type}`\n\nDelete the billing configuration for a given customer.\nNote: this is unsupported for Azure and AWS Marketplace customers. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `billing_provider_type: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.billingConfig.delete({ customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', billing_provider_type: 'stripe' })\n```", perLanguage: { typescript: { method: 'client.v1.customers.billingConfig.delete', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.billingConfig.delete({\n customer_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n billing_provider_type: 'stripe',\n});", }, python: { method: 'v1.customers.billing_config.delete', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.billing_config.delete(\n customer_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type="stripe",\n)', }, java: { method: 'v1().customers().billingConfig().delete', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.billingconfig.BillingConfigDeleteParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillingConfigDeleteParams params = BillingConfigDeleteParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .billingProviderType(BillingConfigDeleteParams.BillingProviderType.STRIPE)\n .build();\n client.v1().customers().billingConfig().delete(params);\n }\n}', }, go: { method: 'client.V1.Customers.BillingConfig.Delete', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.BillingConfig.Delete(context.TODO(), metronome.V1CustomerBillingConfigDeleteParams{\n\t\tCustomerID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tBillingProviderType: metronome.V1CustomerBillingConfigDeleteParamsBillingProviderTypeStripe,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.billing_config.delete', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.billing_config.delete(\n customer_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n billing_provider_type: :stripe\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customers/$CUSTOMER_ID/billing-config/$BILLING_PROVIDER_TYPE \\\n -X DELETE \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/contracts/customerCommits/list', httpMethod: 'post', summary: 'List commits', description: "Retrieve all commit agreements for a customer, including both prepaid and postpaid commitments. This endpoint provides comprehensive visibility into contractual spending obligations, enabling you to track commitment utilization and manage customer contracts effectively.\n\n### Use this endpoint to:\n- Display commitment balances and utilization in customer dashboards\n- Track prepaid commitment drawdown and remaining balances\n- Monitor postpaid commitment progress toward minimum thresholds\n- Build commitment tracking and forecasting tools\n- Show commitment history with optional ledger details\n- Manage rollover balances between contract periods\n\n### Key response fields:\nAn array of Commit objects containing:\n- Commit type: PREPAID (pay upfront) or POSTPAID (pay at true-up)\n- Rate type: COMMIT_RATE (discounted) or LIST_RATE (standard pricing)\n- Access schedule: When commitment funds become available\n- Invoice schedule: When the customer is billed\n- Product targeting: Which product(s) usage is eligible to draw from this commit\n- Optional ledger entries: Transaction history (if `include_ledgers=true`)\n- Balance information: Current available amount (if `include_balance=true`)\n- Rollover settings: Fraction of unused amount that carries forward\n\n### Usage guidelines:\n- Pagination: Results limited to 25 commits per page; use 'next_page' for more\n- Date filtering options:\n - `covering_date`: Commits active on a specific date\n - `starting_at`: Commits with access on/after a date\n - `effective_before`: Commits with access before a date (exclusive)\n- Scope options:\n - `include_contract_commits`: Include contract-level commits (not just customer-level)\n - `include_archived`: Include archived commits and commits from archived contracts\n- Performance considerations:\n - include_ledgers: Adds detailed transaction history (slower)\n - include_balance: Adds current balance calculation (slower)\n- Optional filtering: Use commit_id to retrieve a specific commit\n", stainlessPath: '(resource) v1.customers.commits > (method) list', qualified: 'client.v1.customers.commits.list', params: [ 'customer_id: string;', 'commit_id?: string;', 'covering_date?: string;', 'effective_before?: string;', 'include_archived?: boolean;', 'include_balance?: boolean;', 'include_contract_commits?: boolean;', 'include_ledgers?: boolean;', 'limit?: number;', 'next_page?: string;', 'starting_at?: string;', ], response: "{ id: string; created_at: string; product: object; type: 'PREPAID' | 'POSTPAID'; access_schedule?: schedule_duration; amount?: number; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: object; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_contract?: object; invoice_schedule?: schedule_point_in_time; ledger?: object | object | object | object | object | object | object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: object; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; spend_tracker_attributes?: object; subscription_config?: object; uniqueness_key?: string; }", markdown: "## list\n\n`client.v1.customers.commits.list(customer_id: string, commit_id?: string, covering_date?: string, effective_before?: string, include_archived?: boolean, include_balance?: boolean, include_contract_commits?: boolean, include_ledgers?: boolean, limit?: number, next_page?: string, starting_at?: string): { id: string; created_at: string; product: object; type: 'PREPAID' | 'POSTPAID'; access_schedule?: schedule_duration; amount?: number; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: object; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_contract?: object; invoice_schedule?: schedule_point_in_time; ledger?: object | object | object | object | object | object | object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: object; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; spend_tracker_attributes?: object; subscription_config?: object; uniqueness_key?: string; }`\n\n**post** `/v1/contracts/customerCommits/list`\n\nRetrieve all commit agreements for a customer, including both prepaid and postpaid commitments. This endpoint provides comprehensive visibility into contractual spending obligations, enabling you to track commitment utilization and manage customer contracts effectively.\n\n### Use this endpoint to:\n- Display commitment balances and utilization in customer dashboards\n- Track prepaid commitment drawdown and remaining balances\n- Monitor postpaid commitment progress toward minimum thresholds\n- Build commitment tracking and forecasting tools\n- Show commitment history with optional ledger details\n- Manage rollover balances between contract periods\n\n### Key response fields:\nAn array of Commit objects containing:\n- Commit type: PREPAID (pay upfront) or POSTPAID (pay at true-up)\n- Rate type: COMMIT_RATE (discounted) or LIST_RATE (standard pricing)\n- Access schedule: When commitment funds become available\n- Invoice schedule: When the customer is billed\n- Product targeting: Which product(s) usage is eligible to draw from this commit\n- Optional ledger entries: Transaction history (if `include_ledgers=true`)\n- Balance information: Current available amount (if `include_balance=true`)\n- Rollover settings: Fraction of unused amount that carries forward\n\n### Usage guidelines:\n- Pagination: Results limited to 25 commits per page; use 'next_page' for more\n- Date filtering options:\n - `covering_date`: Commits active on a specific date\n - `starting_at`: Commits with access on/after a date\n - `effective_before`: Commits with access before a date (exclusive)\n- Scope options:\n - `include_contract_commits`: Include contract-level commits (not just customer-level)\n - `include_archived`: Include archived commits and commits from archived contracts\n- Performance considerations:\n - include_ledgers: Adds detailed transaction history (slower)\n - include_balance: Adds current balance calculation (slower)\n- Optional filtering: Use commit_id to retrieve a specific commit\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `commit_id?: string`\n\n- `covering_date?: string`\n Include only commits that have access schedules that \"cover\" the provided date\n\n- `effective_before?: string`\n Include only commits that have any access before the provided date (exclusive)\n\n- `include_archived?: boolean`\n Include archived commits and commits from archived contracts.\n\n- `include_balance?: boolean`\n Include the balance in the response. Setting this flag may cause the query to be slower.\n\n- `include_contract_commits?: boolean`\n Include commits on the contract level.\n\n- `include_ledgers?: boolean`\n Include commit ledgers in the response. Setting this flag may cause the query to be slower.\n\n- `limit?: number`\n The maximum number of commits to return. Defaults to 25.\n\n- `next_page?: string`\n The next page token from a previous response.\n\n- `starting_at?: string`\n Include only commits that have any access on or after the provided date\n\n### Returns\n\n- `{ id: string; created_at: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: object[]; credit_type?: credit_type_data; }; amount?: number; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; invoice_contract?: { id: string; }; invoice_schedule?: { credit_type?: credit_type_data; do_not_invoice?: boolean; schedule_items?: object[]; }; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_ROLLOVER'; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CREDITED'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_INITIAL_BALANCE'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_ROLLOVER'; } | { amount: number; invoice_id: string; timestamp: string; type: 'POSTPAID_COMMIT_TRUEUP'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'PREPAID_COMMIT_MANUAL'; } | { amount: number; reason: string; timestamp: string; type: 'POSTPAID_COMMIT_MANUAL'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_EXPIRATION'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: { commit_id: string; contract_id: string; }; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: { is_prorated: boolean; }; subscription_id?: string; }; uniqueness_key?: string; }`\n\n - `id: string`\n - `created_at: string`\n - `product: { id: string; name: string; }`\n - `type: 'PREPAID' | 'POSTPAID'`\n - `access_schedule?: { schedule_items: { id: string; amount: number; ending_before: string; starting_at: string; }[]; credit_type?: { id: string; name: string; }; }`\n - `amount?: number`\n - `applicable_contract_ids?: string[]`\n - `applicable_product_ids?: string[]`\n - `applicable_product_tags?: string[]`\n - `archived_at?: string`\n - `balance?: number`\n - `contract?: { id: string; }`\n - `cost_basis?: number`\n - `created_by?: string`\n - `custom_fields?: object`\n - `description?: string`\n - `hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }`\n - `invoice_contract?: { id: string; }`\n - `invoice_schedule?: { credit_type?: { id: string; name: string; }; do_not_invoice?: boolean; schedule_items?: { id: string; amount: number; quantity: number; timestamp: string; unit_price: number; invoice_id?: string; }[]; }`\n - `ledger?: { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_ROLLOVER'; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CREDITED'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_INITIAL_BALANCE'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_ROLLOVER'; } | { amount: number; invoice_id: string; timestamp: string; type: 'POSTPAID_COMMIT_TRUEUP'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'PREPAID_COMMIT_MANUAL'; } | { amount: number; reason: string; timestamp: string; type: 'POSTPAID_COMMIT_MANUAL'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_EXPIRATION'; }[]`\n - `name?: string`\n - `netsuite_sales_order_id?: string`\n - `priority?: number`\n - `rate_type?: 'COMMIT_RATE' | 'LIST_RATE'`\n - `recurring_commit_id?: string`\n - `rolled_over_from?: { commit_id: string; contract_id: string; }`\n - `rollover_fraction?: number`\n - `salesforce_opportunity_id?: string`\n - `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n - `spend_tracker_attributes?: { counts_as_discounted: boolean; }`\n - `subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: { is_prorated: boolean; }; subscription_id?: string; }`\n - `uniqueness_key?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const commit of client.v1.customers.commits.list({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' })) {\n console.log(commit);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.commits.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const commit of client.v1.customers.commits.list({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n commit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n include_ledgers: true,\n})) {\n console.log(commit.id);\n}", }, python: { method: 'v1.customers.commits.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.commits.list(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n commit_id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n include_ledgers=True,\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().commits().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.commits.CommitListPage;\nimport com.metronome.api.models.v1.customers.commits.CommitListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CommitListParams params = CommitListParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n CommitListPage page = client.v1().customers().commits().list(params);\n }\n}', }, go: { method: 'client.V1.Customers.Commits.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Commits.List(context.TODO(), metronome.V1CustomerCommitListParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tCommitID: metronome.String("6162d87b-e5db-4a33-b7f2-76ce6ead4e85"),\n\t\tIncludeLedgers: metronome.Bool(true),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.commits.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.commits.list(customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCommits/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "commit_id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "include_ledgers": true\n }\'', }, }, }, { name: 'create', endpoint: '/v1/contracts/customerCommits/create', httpMethod: 'post', summary: 'Create a commit', description: 'Creates customer-level commits that establish spending commitments for customers across their Metronome usage. Commits represent contracted spending obligations that can be either prepaid (paid upfront) or postpaid (billed later). \n\nNote: In most cases, you should add commitments directly to customer contracts using the contract/create or contract/edit APIs.\n\n### Use this endpoint to:\nUse this endpoint when you need to establish customer-level spending commitments that can be applied across multiple contracts or scoped to specific contracts. Customer-level commits are ideal for:\n- Enterprise-wide minimum spending agreements that span multiple contracts\n- Multi-contract volume commitments with shared spending pools\n- Cross-contract discount tiers based on aggregate usage\n\n#### Commit type Requirements: \n- You must specify either "prepaid" or "postpaid" as the commit type:\n- Prepaid commits: Customer pays upfront; invoice_schedule is optional (if omitted, creates a commit without an invoice)\n- Postpaid commits: Customer pays when the commitment expires (the end of the access_schedule); invoice_schedule is required and must match access_schedule totals. \n\n#### Billing configuration:\n- invoice_contract_id is required for postpaid commits and for prepaid commits with billing (only optional for free prepaid commits) unless do_not_invoice is set to true\n- For postpaid commits: access_schedule and invoice_schedule must have matching amounts\n- For postpaid commits: only one schedule item is allowed in both schedules.\n\n#### Scoping flexibility:\nCustomer-level commits can be configured in a few ways:\n- Contract-specific: Use the `applicable_contract_ids` field to limit the commit to specific contracts\n- Cross-contract: Leave `applicable_contract_ids` empty to allow the commit to be used across all of the customer\'s contracts\n\n#### Product targeting:\nCommits can be scoped to specific products using applicable_product_ids, applicable_product_tags, or specifiers, or left unrestricted to apply to all products.\n\n#### Priority considerations:\nWhen multiple commits are applicable, the one with the lower priority value will be consumed first. If there is a tie, contract level commits and credits will be applied before customer level commits and credits. Plan your priority scheme carefully to ensure commits are applied in the desired order.\n\n### Usage guidelines:\n⚠️ Preferred Alternative: In most cases, you should add commits directly to contracts using the create contract or edit contract APIs instead of creating customer-level commits. Contract-level commits provide better organization and are the recommended approach for standard use cases.\n', stainlessPath: '(resource) v1.customers.commits > (method) create', qualified: 'client.v1.customers.commits.create', params: [ 'access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; };', 'customer_id: string;', 'priority: number;', 'product_id: string;', "type: 'PREPAID' | 'POSTPAID';", 'applicable_contract_ids?: string[];', 'applicable_product_ids?: string[];', 'applicable_product_tags?: string[];', 'custom_fields?: object;', 'description?: string;', 'invoice_contract_id?: string;', "invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; };", 'name?: string;', 'netsuite_sales_order_id?: string;', "rate_type?: 'COMMIT_RATE' | 'LIST_RATE';", 'salesforce_opportunity_id?: string;', 'specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];', 'uniqueness_key?: string;', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.customers.commits.create(access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }, customer_id: string, priority: number, product_id: string, type: 'PREPAID' | 'POSTPAID', applicable_contract_ids?: string[], applicable_product_ids?: string[], applicable_product_tags?: string[], custom_fields?: object, description?: string, invoice_contract_id?: string, invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }, name?: string, netsuite_sales_order_id?: string, rate_type?: 'COMMIT_RATE' | 'LIST_RATE', salesforce_opportunity_id?: string, specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[], uniqueness_key?: string): { data: id; }`\n\n**post** `/v1/contracts/customerCommits/create`\n\nCreates customer-level commits that establish spending commitments for customers across their Metronome usage. Commits represent contracted spending obligations that can be either prepaid (paid upfront) or postpaid (billed later). \n\nNote: In most cases, you should add commitments directly to customer contracts using the contract/create or contract/edit APIs.\n\n### Use this endpoint to:\nUse this endpoint when you need to establish customer-level spending commitments that can be applied across multiple contracts or scoped to specific contracts. Customer-level commits are ideal for:\n- Enterprise-wide minimum spending agreements that span multiple contracts\n- Multi-contract volume commitments with shared spending pools\n- Cross-contract discount tiers based on aggregate usage\n\n#### Commit type Requirements: \n- You must specify either \"prepaid\" or \"postpaid\" as the commit type:\n- Prepaid commits: Customer pays upfront; invoice_schedule is optional (if omitted, creates a commit without an invoice)\n- Postpaid commits: Customer pays when the commitment expires (the end of the access_schedule); invoice_schedule is required and must match access_schedule totals. \n\n#### Billing configuration:\n- invoice_contract_id is required for postpaid commits and for prepaid commits with billing (only optional for free prepaid commits) unless do_not_invoice is set to true\n- For postpaid commits: access_schedule and invoice_schedule must have matching amounts\n- For postpaid commits: only one schedule item is allowed in both schedules.\n\n#### Scoping flexibility:\nCustomer-level commits can be configured in a few ways:\n- Contract-specific: Use the `applicable_contract_ids` field to limit the commit to specific contracts\n- Cross-contract: Leave `applicable_contract_ids` empty to allow the commit to be used across all of the customer's contracts\n\n#### Product targeting:\nCommits can be scoped to specific products using applicable_product_ids, applicable_product_tags, or specifiers, or left unrestricted to apply to all products.\n\n#### Priority considerations:\nWhen multiple commits are applicable, the one with the lower priority value will be consumed first. If there is a tie, contract level commits and credits will be applied before customer level commits and credits. Plan your priority scheme carefully to ensure commits are applied in the desired order.\n\n### Usage guidelines:\n⚠️ Preferred Alternative: In most cases, you should add commits directly to contracts using the create contract or edit contract APIs instead of creating customer-level commits. Contract-level commits provide better organization and are the recommended approach for standard use cases.\n\n\n### Parameters\n\n- `access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }`\n Schedule for distributing the commit to the customer. For \"POSTPAID\" commits only one schedule item is allowed and amount must match invoice_schedule total.\n - `schedule_items: { amount: number; ending_before: string; starting_at: string; }[]`\n - `credit_type_id?: string`\n Defaults to USD (cents) if not passed\n\n- `customer_id: string`\n\n- `priority: number`\n If multiple credits or commits are applicable, the one with the lower priority will apply first.\n\n- `product_id: string`\n ID of the fixed product associated with the commit. This is required because products are used to invoice the commit amount.\n\n- `type: 'PREPAID' | 'POSTPAID'`\n\n- `applicable_contract_ids?: string[]`\n Which contract the commit applies to. If not provided, the commit applies to all contracts.\n\n- `applicable_product_ids?: string[]`\n Which products the commit applies to. If applicable_product_ids, applicable_product_tags or specifiers are not provided, the commit applies to all products.\n\n- `applicable_product_tags?: string[]`\n Which tags the commit applies to. If applicable_product_ids, applicable_product_tags or specifiers are not provided, the commit applies to all products.\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `description?: string`\n Used only in UI/API. It is not exposed to end customers.\n\n- `invoice_contract_id?: string`\n The contract that this commit will be billed on. This is required for \"POSTPAID\" commits and for \"PREPAID\" commits unless there is no invoice schedule above (i.e., the commit is 'free'), or if do_not_invoice is set to true.\n\n- `invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }`\n Required for \"POSTPAID\" commits: the true up invoice will be generated at this time and only one schedule item is allowed; the total must match accesss_schedule amount. Optional for \"PREPAID\" commits: if not provided, this will be a \"complimentary\" commit with no invoice.\n - `credit_type_id?: string`\n Defaults to USD (cents) if not passed.\n - `do_not_invoice?: boolean`\n This field is only applicable to commit invoice schedules. If true, this schedule will not generate an invoice.\n - `recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }`\n Enter the unit price and quantity for the charge or instead only send the amount. If amount is sent, the unit price is assumed to be the amount and quantity is inferred to be 1.\n - `schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]`\n Either provide amount or provide both unit_price and quantity.\n\n- `name?: string`\n displayed on invoices\n\n- `netsuite_sales_order_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `rate_type?: 'COMMIT_RATE' | 'LIST_RATE'`\n\n- `salesforce_opportunity_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of filters that determine what kind of customer usage draws down a commit or credit. A customer's usage needs to meet the condition of at least one of the specifiers to contribute to a commit's or credit's drawdown. This field cannot be used together with `applicable_product_ids` or `applicable_product_tags`.\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a commit or credit is made with a uniqueness key that was previously used to create a commit or credit, a new record will not be created and the request will fail with a 409 error.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst commit = await client.v1.customers.commits.create({\n access_schedule: { schedule_items: [{\n amount: 1000,\n ending_before: '2020-02-01T00:00:00.000Z',\n starting_at: '2020-01-01T00:00:00.000Z',\n}] },\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n priority: 100,\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n type: 'PREPAID',\n});\n\nconsole.log(commit);\n```", perLanguage: { typescript: { method: 'client.v1.customers.commits.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst commit = await client.v1.customers.commits.create({\n access_schedule: {\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n schedule_items: [\n {\n amount: 1000,\n starting_at: '2020-01-01T00:00:00.000Z',\n ending_before: '2020-02-01T00:00:00.000Z',\n },\n ],\n },\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n priority: 100,\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n type: 'prepaid',\n invoice_contract_id: 'e57d6929-c2f1-4796-a9a8-63cedefe848d',\n invoice_schedule: {\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n schedule_items: [\n {\n unit_price: 10000000,\n quantity: 1,\n timestamp: '2020-03-01T00:00:00.000Z',\n },\n ],\n do_not_invoice: false,\n },\n name: 'My Commit',\n});\n\nconsole.log(commit.data);", }, python: { method: 'v1.customers.commits.create', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncommit = client.v1.customers.commits.create(\n access_schedule={\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "schedule_items": [{\n "amount": 1000,\n "starting_at": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "ending_before": datetime.fromisoformat("2020-02-01T00:00:00.000"),\n }],\n },\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n priority=100,\n product_id="f14d6729-6a44-4b13-9908-9387f1918790",\n type="prepaid",\n invoice_contract_id="e57d6929-c2f1-4796-a9a8-63cedefe848d",\n invoice_schedule={\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "schedule_items": [{\n "unit_price": 10000000,\n "quantity": 1,\n "timestamp": datetime.fromisoformat("2020-03-01T00:00:00.000"),\n }],\n "do_not_invoice": False,\n },\n name="My Commit",\n)\nprint(commit.data)', }, java: { method: 'v1().customers().commits().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.commits.CommitCreateParams;\nimport com.metronome.api.models.v1.customers.commits.CommitCreateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CommitCreateParams params = CommitCreateParams.builder()\n .accessSchedule(CommitCreateParams.AccessSchedule.builder()\n .addScheduleItem(CommitCreateParams.AccessSchedule.ScheduleItem.builder()\n .amount(1000.0)\n .endingBefore(OffsetDateTime.parse("2020-02-01T00:00:00.000Z"))\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build())\n .build())\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .priority(100.0)\n .productId("f14d6729-6a44-4b13-9908-9387f1918790")\n .type(CommitCreateParams.Type.PREPAID)\n .build();\n CommitCreateResponse commit = client.v1().customers().commits().create(params);\n }\n}', }, go: { method: 'client.V1.Customers.Commits.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcommit, err := client.V1.Customers.Commits.New(context.TODO(), metronome.V1CustomerCommitNewParams{\n\t\tAccessSchedule: metronome.V1CustomerCommitNewParamsAccessSchedule{\n\t\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\t\tScheduleItems: []metronome.V1CustomerCommitNewParamsAccessScheduleScheduleItem{{\n\t\t\t\tAmount: 1000,\n\t\t\t\tStartingAt: time.Now(),\n\t\t\t\tEndingBefore: time.Now(),\n\t\t\t}},\n\t\t},\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tPriority: 100,\n\t\tProductID: "f14d6729-6a44-4b13-9908-9387f1918790",\n\t\tType: metronome.V1CustomerCommitNewParamsType("prepaid"),\n\t\tInvoiceContractID: metronome.String("e57d6929-c2f1-4796-a9a8-63cedefe848d"),\n\t\tInvoiceSchedule: metronome.V1CustomerCommitNewParamsInvoiceSchedule{\n\t\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\t\tScheduleItems: []metronome.V1CustomerCommitNewParamsInvoiceScheduleScheduleItem{{\n\t\t\t\tUnitPrice: metronome.Float(10000000),\n\t\t\t\tQuantity: metronome.Float(1),\n\t\t\t\tTimestamp: time.Now(),\n\t\t\t}},\n\t\t\tDoNotInvoice: metronome.Bool(false),\n\t\t},\n\t\tName: metronome.String("My Commit"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", commit.Data)\n}\n', }, ruby: { method: 'v1.customers.commits.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncommit = metronome.v1.customers.commits.create(\n access_schedule: {\n schedule_items: [{amount: 1000, ending_before: "2020-02-01T00:00:00.000Z", starting_at: "2020-01-01T00:00:00.000Z"}]\n },\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n priority: 100,\n product_id: "f14d6729-6a44-4b13-9908-9387f1918790",\n type: :PREPAID\n)\n\nputs(commit)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCommits/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "access_schedule": {\n "schedule_items": [\n {\n "amount": 1000,\n "ending_before": "2020-02-01T00:00:00.000Z",\n "starting_at": "2020-01-01T00:00:00.000Z"\n }\n ],\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2"\n },\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "priority": 100,\n "product_id": "f14d6729-6a44-4b13-9908-9387f1918790",\n "type": "PREPAID",\n "invoice_contract_id": "e57d6929-c2f1-4796-a9a8-63cedefe848d",\n "invoice_schedule": {\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "do_not_invoice": false,\n "schedule_items": [\n {\n "timestamp": "2020-03-01T00:00:00.000Z",\n "quantity": 1,\n "unit_price": 10000000\n }\n ]\n },\n "name": "My Commit"\n }\'', }, }, }, { name: 'update_end_date', endpoint: '/v1/contracts/customerCommits/updateEndDate', httpMethod: 'post', summary: 'Update the commit end date', description: "Shortens the end date of a prepaid commit to terminate it earlier than originally scheduled. Use this endpoint when you need to cancel or reduce the duration of an existing prepaid commit. Only works with prepaid commit types and can only move the end date forward (earlier), not extend it. \n\n### Usage guidelines:\nTo extend commit end dates or make other comprehensive edits, use the 'edit commit' endpoint instead.\n", stainlessPath: '(resource) v1.customers.commits > (method) update_end_date', qualified: 'client.v1.customers.commits.updateEndDate', params: [ 'commit_id: string;', 'customer_id: string;', 'access_ending_before?: string;', 'invoices_ending_before?: string;', ], response: '{ data: { id: string; }; }', markdown: "## update_end_date\n\n`client.v1.customers.commits.updateEndDate(commit_id: string, customer_id: string, access_ending_before?: string, invoices_ending_before?: string): { data: id; }`\n\n**post** `/v1/contracts/customerCommits/updateEndDate`\n\nShortens the end date of a prepaid commit to terminate it earlier than originally scheduled. Use this endpoint when you need to cancel or reduce the duration of an existing prepaid commit. Only works with prepaid commit types and can only move the end date forward (earlier), not extend it. \n\n### Usage guidelines:\nTo extend commit end dates or make other comprehensive edits, use the 'edit commit' endpoint instead.\n\n\n### Parameters\n\n- `commit_id: string`\n ID of the commit to update. Only supports \"PREPAID\" commits.\n\n- `customer_id: string`\n ID of the customer whose commit is to be updated\n\n- `access_ending_before?: string`\n RFC 3339 timestamp indicating when access to the commit will end and it will no longer be possible to draw it down (exclusive). If not provided, the access will not be updated.\n\n- `invoices_ending_before?: string`\n RFC 3339 timestamp indicating when the commit will stop being invoiced (exclusive). If not provided, the invoice schedule will not be updated.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.commits.updateEndDate({ commit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.commits.updateEndDate', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.commits.updateEndDate({\n commit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n access_ending_before: '2020-01-01T00:00:00.000Z',\n invoices_ending_before: '2020-01-01T00:00:00.000Z',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.commits.update_end_date', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.commits.update_end_date(\n commit_id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n access_ending_before=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n invoices_ending_before=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\nprint(response.data)', }, java: { method: 'v1().customers().commits().updateEndDate', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.commits.CommitUpdateEndDateParams;\nimport com.metronome.api.models.v1.customers.commits.CommitUpdateEndDateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CommitUpdateEndDateParams params = CommitUpdateEndDateParams.builder()\n .commitId("6162d87b-e5db-4a33-b7f2-76ce6ead4e85")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n CommitUpdateEndDateResponse response = client.v1().customers().commits().updateEndDate(params);\n }\n}', }, go: { method: 'client.V1.Customers.Commits.UpdateEndDate', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Commits.UpdateEndDate(context.TODO(), metronome.V1CustomerCommitUpdateEndDateParams{\n\t\tCommitID: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tAccessEndingBefore: metronome.Time(time.Now()),\n\t\tInvoicesEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.commits.update_end_date', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.commits.update_end_date(\n commit_id: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCommits/updateEndDate \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "commit_id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "access_ending_before": "2020-01-01T00:00:00.000Z",\n "invoices_ending_before": "2020-01-01T00:00:00.000Z"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/contracts/customerCredits/list', httpMethod: 'post', summary: 'List credits', description: 'Retrieve a detailed list of all credits available to a customer, including promotional credits and contract-specific credits. This endpoint provides comprehensive visibility into credit balances, access schedules, and usage rules, enabling you to build credit management interfaces and track available funding.\n\n### Use this endpoint to:\n- Display all available credits in customer billing dashboards\n- Show credit balances and expiration dates\n- Track credit usage history with optional ledger details\n- Build credit management and reporting tools\n- Monitor promotional credit utilization\n• Support customer inquiries about available credits\n\n### Key response fields:\nAn array of Credit objects containing:\n- Credit details: Name, priority, and which applicable products/tags it applies to\n- Product ID: The `product_id` of the credit. This is for external mapping into your quote-to-cash stack, not the product it applies to. \n- Access schedule: When credits become available and expire\n- Optional ledger entries: Transaction history (if `include_ledgers=true`)\n- Balance information: Current available amount (if `include_balance=true`)\n- Metadata: Custom fields and usage specifiers\n\n### Usage guidelines:\n- Pagination: Results limited to 25 commits per page; use next_page for more\n- Date filtering options:\n - `covering_date`: Credits active on a specific date\n - `starting_at`: Credits with access on/after a date\n - `effective_before`: Credits with access before a date (exclusive)\n- Scope options:\n - `include_contract_credits`: Include contract-level credits (not just customer-level)\n - `include_archived`: Include archived credits and credits from archived contracts\n- Performance considerations:\n - `include_ledgers`: Adds detailed transaction history (slower)\n - `include_balance`: Adds current balance calculation (slower)\n- Optional filtering: Use credit_id to retrieve a specific commit\n', stainlessPath: '(resource) v1.customers.credits > (method) list', qualified: 'client.v1.customers.credits.list', params: [ 'customer_id: string;', 'covering_date?: string;', 'credit_id?: string;', 'effective_before?: string;', 'include_archived?: boolean;', 'include_balance?: boolean;', 'include_contract_credits?: boolean;', 'include_ledgers?: boolean;', 'limit?: number;', 'next_page?: string;', 'starting_at?: string;', ], response: "{ id: string; product: object; type: 'CREDIT'; access_schedule?: schedule_duration; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; balance?: number; contract?: object; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; ledger?: object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_credit_id?: string; rolled_over_from?: object; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; subscription_config?: object; uniqueness_key?: string; }", markdown: "## list\n\n`client.v1.customers.credits.list(customer_id: string, covering_date?: string, credit_id?: string, effective_before?: string, include_archived?: boolean, include_balance?: boolean, include_contract_credits?: boolean, include_ledgers?: boolean, limit?: number, next_page?: string, starting_at?: string): { id: string; product: object; type: 'CREDIT'; access_schedule?: schedule_duration; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; balance?: number; contract?: object; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; ledger?: object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_credit_id?: string; rolled_over_from?: object; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; subscription_config?: object; uniqueness_key?: string; }`\n\n**post** `/v1/contracts/customerCredits/list`\n\nRetrieve a detailed list of all credits available to a customer, including promotional credits and contract-specific credits. This endpoint provides comprehensive visibility into credit balances, access schedules, and usage rules, enabling you to build credit management interfaces and track available funding.\n\n### Use this endpoint to:\n- Display all available credits in customer billing dashboards\n- Show credit balances and expiration dates\n- Track credit usage history with optional ledger details\n- Build credit management and reporting tools\n- Monitor promotional credit utilization\n• Support customer inquiries about available credits\n\n### Key response fields:\nAn array of Credit objects containing:\n- Credit details: Name, priority, and which applicable products/tags it applies to\n- Product ID: The `product_id` of the credit. This is for external mapping into your quote-to-cash stack, not the product it applies to. \n- Access schedule: When credits become available and expire\n- Optional ledger entries: Transaction history (if `include_ledgers=true`)\n- Balance information: Current available amount (if `include_balance=true`)\n- Metadata: Custom fields and usage specifiers\n\n### Usage guidelines:\n- Pagination: Results limited to 25 commits per page; use next_page for more\n- Date filtering options:\n - `covering_date`: Credits active on a specific date\n - `starting_at`: Credits with access on/after a date\n - `effective_before`: Credits with access before a date (exclusive)\n- Scope options:\n - `include_contract_credits`: Include contract-level credits (not just customer-level)\n - `include_archived`: Include archived credits and credits from archived contracts\n- Performance considerations:\n - `include_ledgers`: Adds detailed transaction history (slower)\n - `include_balance`: Adds current balance calculation (slower)\n- Optional filtering: Use credit_id to retrieve a specific commit\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `covering_date?: string`\n Return only credits that have access schedules that \"cover\" the provided date\n\n- `credit_id?: string`\n\n- `effective_before?: string`\n Include only credits that have any access before the provided date (exclusive)\n\n- `include_archived?: boolean`\n Include archived credits and credits from archived contracts.\n\n- `include_balance?: boolean`\n Include the balance in the response. Setting this flag may cause the query to be slower.\n\n- `include_contract_credits?: boolean`\n Include credits on the contract level.\n\n- `include_ledgers?: boolean`\n Include credit ledgers in the response. Setting this flag may cause the query to be slower.\n\n- `limit?: number`\n The maximum number of commits to return. Defaults to 25.\n\n- `next_page?: string`\n The next page token from a previous response.\n\n- `starting_at?: string`\n Include only credits that have any access on or after the provided date\n\n### Returns\n\n- `{ id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: { schedule_items: object[]; credit_type?: credit_type_data; }; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; balance?: number; contract?: { id: string; }; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: object | object | object; }; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CREDITED'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'CREDIT_MANUAL'; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'CREDIT_ROLLOVER'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_credit_id?: string; rolled_over_from?: { contract_id: string; credit_id: string; }; salesforce_opportunity_id?: string; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: { is_prorated: boolean; }; subscription_id?: string; }; uniqueness_key?: string; }`\n\n - `id: string`\n - `product: { id: string; name: string; }`\n - `type: 'CREDIT'`\n - `access_schedule?: { schedule_items: { id: string; amount: number; ending_before: string; starting_at: string; }[]; credit_type?: { id: string; name: string; }; }`\n - `applicable_contract_ids?: string[]`\n - `applicable_product_ids?: string[]`\n - `applicable_product_tags?: string[]`\n - `balance?: number`\n - `contract?: { id: string; }`\n - `created_by?: string`\n - `custom_fields?: object`\n - `description?: string`\n - `hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }`\n - `ledger?: { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CREDITED'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'CREDIT_MANUAL'; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'CREDIT_ROLLOVER'; }[]`\n - `name?: string`\n - `netsuite_sales_order_id?: string`\n - `priority?: number`\n - `rate_type?: 'COMMIT_RATE' | 'LIST_RATE'`\n - `recurring_credit_id?: string`\n - `rolled_over_from?: { contract_id: string; credit_id: string; }`\n - `salesforce_opportunity_id?: string`\n - `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n - `subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: { is_prorated: boolean; }; subscription_id?: string; }`\n - `uniqueness_key?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const credit of client.v1.customers.credits.list({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' })) {\n console.log(credit);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customers.credits.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const credit of client.v1.customers.credits.list({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n credit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n include_ledgers: true,\n})) {\n console.log(credit.id);\n}", }, python: { method: 'v1.customers.credits.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.customers.credits.list(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n credit_id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n include_ledgers=True,\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().customers().credits().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.credits.CreditListPage;\nimport com.metronome.api.models.v1.customers.credits.CreditListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditListParams params = CreditListParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n CreditListPage page = client.v1().customers().credits().list(params);\n }\n}', }, go: { method: 'client.V1.Customers.Credits.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Customers.Credits.List(context.TODO(), metronome.V1CustomerCreditListParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tCreditID: metronome.String("6162d87b-e5db-4a33-b7f2-76ce6ead4e85"),\n\t\tIncludeLedgers: metronome.Bool(true),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.customers.credits.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.customers.credits.list(customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCredits/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "credit_id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "include_ledgers": true\n }\'', }, }, }, { name: 'create', endpoint: '/v1/contracts/customerCredits/create', httpMethod: 'post', summary: 'Create a credit', description: "Creates customer-level credits that provide spending allowances or free credit balances for customers across their Metronome usage. Note: In most cases, you should add credits directly to customer contracts using the contract/create or contract/edit APIs.\n\n### Use this endpoint to:\nUse this endpoint when you need to provision credits directly at the customer level that can be applied across multiple contracts or scoped to specific contracts. Customer-level credits are ideal for:\n- Customer onboarding incentives that apply globally\n- Flexible spending allowances that aren't tied to a single contract\n- Migration scenarios where you need to preserve existing customer balances\n\n#### Scoping flexibility: \nCustomer-level credits can be configured in two ways:\n- Contract-specific: Use the applicable_contract_ids field to limit the credit to specific contracts\n- Cross-contract: Leave applicable_contract_ids empty to allow the credit to be used across all of the customer's contracts\n\n#### Product Targeting: \nCredits can be scoped to specific products using `applicable_product_ids` or `applicable_product_tags`, or left unrestricted to apply to all products.\n\n#### Priority considerations: \nWhen multiple credits are applicable, the one with the lower priority value will be consumed first. If there is a tie, contract level commits and credits will be applied before customer level commits and credits. Plan your priority scheme carefully to ensure credits are applied in the desired order.\n\n#### Access Schedule Required: \nYou must provide an `access_schedule` that defines when and how much credit becomes available to the customer over time. This usually is aligned to the contract schedule or starts immediately and is set to expire in the future.\n\n### Usage Guidelines:\n⚠️ Preferred Alternative: In most cases, you should add credits directly to contracts using the contract/create or contract/edit APIs instead of creating customer-level credits. Contract-level credits provide better organization, and are easier for finance teams to recognize revenue, and are the recommended approach for most use cases.\n", stainlessPath: '(resource) v1.customers.credits > (method) create', qualified: 'client.v1.customers.credits.create', params: [ 'access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; };', 'customer_id: string;', 'priority: number;', 'product_id: string;', 'applicable_contract_ids?: string[];', 'applicable_product_ids?: string[];', 'applicable_product_tags?: string[];', 'custom_fields?: object;', 'description?: string;', 'name?: string;', 'netsuite_sales_order_id?: string;', "rate_type?: 'COMMIT_RATE' | 'LIST_RATE';", 'salesforce_opportunity_id?: string;', 'specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];', 'uniqueness_key?: string;', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.customers.credits.create(access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }, customer_id: string, priority: number, product_id: string, applicable_contract_ids?: string[], applicable_product_ids?: string[], applicable_product_tags?: string[], custom_fields?: object, description?: string, name?: string, netsuite_sales_order_id?: string, rate_type?: 'COMMIT_RATE' | 'LIST_RATE', salesforce_opportunity_id?: string, specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[], uniqueness_key?: string): { data: id; }`\n\n**post** `/v1/contracts/customerCredits/create`\n\nCreates customer-level credits that provide spending allowances or free credit balances for customers across their Metronome usage. Note: In most cases, you should add credits directly to customer contracts using the contract/create or contract/edit APIs.\n\n### Use this endpoint to:\nUse this endpoint when you need to provision credits directly at the customer level that can be applied across multiple contracts or scoped to specific contracts. Customer-level credits are ideal for:\n- Customer onboarding incentives that apply globally\n- Flexible spending allowances that aren't tied to a single contract\n- Migration scenarios where you need to preserve existing customer balances\n\n#### Scoping flexibility: \nCustomer-level credits can be configured in two ways:\n- Contract-specific: Use the applicable_contract_ids field to limit the credit to specific contracts\n- Cross-contract: Leave applicable_contract_ids empty to allow the credit to be used across all of the customer's contracts\n\n#### Product Targeting: \nCredits can be scoped to specific products using `applicable_product_ids` or `applicable_product_tags`, or left unrestricted to apply to all products.\n\n#### Priority considerations: \nWhen multiple credits are applicable, the one with the lower priority value will be consumed first. If there is a tie, contract level commits and credits will be applied before customer level commits and credits. Plan your priority scheme carefully to ensure credits are applied in the desired order.\n\n#### Access Schedule Required: \nYou must provide an `access_schedule` that defines when and how much credit becomes available to the customer over time. This usually is aligned to the contract schedule or starts immediately and is set to expire in the future.\n\n### Usage Guidelines:\n⚠️ Preferred Alternative: In most cases, you should add credits directly to contracts using the contract/create or contract/edit APIs instead of creating customer-level credits. Contract-level credits provide better organization, and are easier for finance teams to recognize revenue, and are the recommended approach for most use cases.\n\n\n### Parameters\n\n- `access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }`\n Schedule for distributing the credit to the customer.\n - `schedule_items: { amount: number; ending_before: string; starting_at: string; }[]`\n - `credit_type_id?: string`\n Defaults to USD (cents) if not passed\n\n- `customer_id: string`\n\n- `priority: number`\n If multiple credits or commits are applicable, the one with the lower priority will apply first.\n\n- `product_id: string`\n\n- `applicable_contract_ids?: string[]`\n Which contract the credit applies to. If not provided, the credit applies to all contracts.\n\n- `applicable_product_ids?: string[]`\n Which products the credit applies to. If both applicable_product_ids and applicable_product_tags are not provided, the credit applies to all products.\n\n- `applicable_product_tags?: string[]`\n Which tags the credit applies to. If both applicable_product_ids and applicable_product_tags are not provided, the credit applies to all products.\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `description?: string`\n Used only in UI/API. It is not exposed to end customers.\n\n- `name?: string`\n displayed on invoices\n\n- `netsuite_sales_order_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `rate_type?: 'COMMIT_RATE' | 'LIST_RATE'`\n\n- `salesforce_opportunity_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of filters that determine what kind of customer usage draws down a commit or credit. A customer's usage needs to meet the condition of at least one of the specifiers to contribute to a commit's or credit's drawdown. This field cannot be used together with `applicable_product_ids` or `applicable_product_tags`.\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a commit or credit is made with a uniqueness key that was previously used to create a commit or credit, a new record will not be created and the request will fail with a 409 error.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst credit = await client.v1.customers.credits.create({\n access_schedule: { schedule_items: [{\n amount: 1000,\n ending_before: '2020-02-01T00:00:00.000Z',\n starting_at: '2020-01-01T00:00:00.000Z',\n}] },\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n priority: 100,\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n});\n\nconsole.log(credit);\n```", perLanguage: { typescript: { method: 'client.v1.customers.credits.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst credit = await client.v1.customers.credits.create({\n access_schedule: {\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n schedule_items: [\n {\n amount: 1000,\n starting_at: '2020-01-01T00:00:00.000Z',\n ending_before: '2020-02-01T00:00:00.000Z',\n },\n ],\n },\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n priority: 100,\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n name: 'My Credit',\n});\n\nconsole.log(credit.data);", }, python: { method: 'v1.customers.credits.create', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncredit = client.v1.customers.credits.create(\n access_schedule={\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "schedule_items": [{\n "amount": 1000,\n "starting_at": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "ending_before": datetime.fromisoformat("2020-02-01T00:00:00.000"),\n }],\n },\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n priority=100,\n product_id="f14d6729-6a44-4b13-9908-9387f1918790",\n name="My Credit",\n)\nprint(credit.data)', }, java: { method: 'v1().customers().credits().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.credits.CreditCreateParams;\nimport com.metronome.api.models.v1.customers.credits.CreditCreateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditCreateParams params = CreditCreateParams.builder()\n .accessSchedule(CreditCreateParams.AccessSchedule.builder()\n .addScheduleItem(CreditCreateParams.AccessSchedule.ScheduleItem.builder()\n .amount(1000.0)\n .endingBefore(OffsetDateTime.parse("2020-02-01T00:00:00.000Z"))\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build())\n .build())\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .priority(100.0)\n .productId("f14d6729-6a44-4b13-9908-9387f1918790")\n .build();\n CreditCreateResponse credit = client.v1().customers().credits().create(params);\n }\n}', }, go: { method: 'client.V1.Customers.Credits.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcredit, err := client.V1.Customers.Credits.New(context.TODO(), metronome.V1CustomerCreditNewParams{\n\t\tAccessSchedule: metronome.V1CustomerCreditNewParamsAccessSchedule{\n\t\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\t\tScheduleItems: []metronome.V1CustomerCreditNewParamsAccessScheduleScheduleItem{{\n\t\t\t\tAmount: 1000,\n\t\t\t\tStartingAt: time.Now(),\n\t\t\t\tEndingBefore: time.Now(),\n\t\t\t}},\n\t\t},\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tPriority: 100,\n\t\tProductID: "f14d6729-6a44-4b13-9908-9387f1918790",\n\t\tName: metronome.String("My Credit"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", credit.Data)\n}\n', }, ruby: { method: 'v1.customers.credits.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncredit = metronome.v1.customers.credits.create(\n access_schedule: {\n schedule_items: [{amount: 1000, ending_before: "2020-02-01T00:00:00.000Z", starting_at: "2020-01-01T00:00:00.000Z"}]\n },\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n priority: 100,\n product_id: "f14d6729-6a44-4b13-9908-9387f1918790"\n)\n\nputs(credit)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCredits/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "access_schedule": {\n "schedule_items": [\n {\n "amount": 1000,\n "ending_before": "2020-02-01T00:00:00.000Z",\n "starting_at": "2020-01-01T00:00:00.000Z"\n }\n ],\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2"\n },\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "priority": 100,\n "product_id": "f14d6729-6a44-4b13-9908-9387f1918790",\n "name": "My Credit"\n }\'', }, }, }, { name: 'update_end_date', endpoint: '/v1/contracts/customerCredits/updateEndDate', httpMethod: 'post', summary: 'Update the credit end date', description: "Shortens the end date of an existing customer credit to terminate it earlier than originally scheduled. Only allows moving end dates forward (earlier), not extending them. \n\nNote: To extend credit end dates or make comprehensive edits, use the 'edit credit' endpoint instead.\n", stainlessPath: '(resource) v1.customers.credits > (method) update_end_date', qualified: 'client.v1.customers.credits.updateEndDate', params: ['access_ending_before: string;', 'credit_id: string;', 'customer_id: string;'], response: '{ data: { id: string; }; }', markdown: "## update_end_date\n\n`client.v1.customers.credits.updateEndDate(access_ending_before: string, credit_id: string, customer_id: string): { data: id; }`\n\n**post** `/v1/contracts/customerCredits/updateEndDate`\n\nShortens the end date of an existing customer credit to terminate it earlier than originally scheduled. Only allows moving end dates forward (earlier), not extending them. \n\nNote: To extend credit end dates or make comprehensive edits, use the 'edit credit' endpoint instead.\n\n\n### Parameters\n\n- `access_ending_before: string`\n RFC 3339 timestamp indicating when access to the credit will end and it will no longer be possible to draw it down (exclusive).\n\n- `credit_id: string`\n ID of the commit to update\n\n- `customer_id: string`\n ID of the customer whose credit is to be updated\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.customers.credits.updateEndDate({\n access_ending_before: '2020-01-01T00:00:00.000Z',\n credit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.customers.credits.updateEndDate', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.customers.credits.updateEndDate({\n access_ending_before: '2020-01-01T00:00:00.000Z',\n credit_id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.customers.credits.update_end_date', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.customers.credits.update_end_date(\n access_ending_before=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n credit_id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(response.data)', }, java: { method: 'v1().customers().credits().updateEndDate', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.credits.CreditUpdateEndDateParams;\nimport com.metronome.api.models.v1.customers.credits.CreditUpdateEndDateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CreditUpdateEndDateParams params = CreditUpdateEndDateParams.builder()\n .accessEndingBefore(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .creditId("6162d87b-e5db-4a33-b7f2-76ce6ead4e85")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n CreditUpdateEndDateResponse response = client.v1().customers().credits().updateEndDate(params);\n }\n}', }, go: { method: 'client.V1.Customers.Credits.UpdateEndDate', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Customers.Credits.UpdateEndDate(context.TODO(), metronome.V1CustomerCreditUpdateEndDateParams{\n\t\tAccessEndingBefore: time.Now(),\n\t\tCreditID: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.customers.credits.update_end_date', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.customers.credits.update_end_date(\n access_ending_before: "2020-01-01T00:00:00.000Z",\n credit_id: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerCredits/updateEndDate \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "access_ending_before": "2020-01-01T00:00:00.000Z",\n "credit_id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/customers/getNamedSchedule', httpMethod: 'post', summary: "Get a customer's named schedule", description: "Get a named schedule for the given customer. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.customers.named_schedules > (method) retrieve', qualified: 'client.v1.customers.namedSchedules.retrieve', params: ['customer_id: string;', 'schedule_name: string;', 'covering_date?: string;'], response: '{ data: { starting_at: string; value: object; ending_before?: string; }[]; }', markdown: "## retrieve\n\n`client.v1.customers.namedSchedules.retrieve(customer_id: string, schedule_name: string, covering_date?: string): { data: object[]; }`\n\n**post** `/v1/customers/getNamedSchedule`\n\nGet a named schedule for the given customer. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `customer_id: string`\n ID of the customer whose named schedule is to be retrieved\n\n- `schedule_name: string`\n The identifier for the schedule to be retrieved\n\n- `covering_date?: string`\n If provided, at most one schedule segment will be returned (the one that covers this date). If not provided, all segments will be returned.\n\n### Returns\n\n- `{ data: { starting_at: string; value: object; ending_before?: string; }[]; }`\n\n - `data: { starting_at: string; value: object; ending_before?: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst namedSchedule = await client.v1.customers.namedSchedules.retrieve({ customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1', schedule_name: 'my-schedule' });\n\nconsole.log(namedSchedule);\n```", perLanguage: { typescript: { method: 'client.v1.customers.namedSchedules.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst namedSchedule = await client.v1.customers.namedSchedules.retrieve({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n covering_date: '2022-02-15T00:00:00Z',\n});\n\nconsole.log(namedSchedule.data);", }, python: { method: 'v1.customers.named_schedules.retrieve', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nnamed_schedule = client.v1.customers.named_schedules.retrieve(\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name="my-schedule",\n covering_date=datetime.fromisoformat("2022-02-15T00:00:00"),\n)\nprint(named_schedule.data)', }, java: { method: 'v1().customers().namedSchedules().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customers.namedschedules.NamedScheduleRetrieveParams;\nimport com.metronome.api.models.v1.customers.namedschedules.NamedScheduleRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleRetrieveParams params = NamedScheduleRetrieveParams.builder()\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .scheduleName("my-schedule")\n .build();\n NamedScheduleRetrieveResponse namedSchedule = client.v1().customers().namedSchedules().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Customers.NamedSchedules.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tnamedSchedule, err := client.V1.Customers.NamedSchedules.Get(context.TODO(), metronome.V1CustomerNamedScheduleGetParams{\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tScheduleName: "my-schedule",\n\t\tCoveringDate: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", namedSchedule.Data)\n}\n', }, ruby: { method: 'v1.customers.named_schedules.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nnamed_schedule = metronome.v1.customers.named_schedules.retrieve(\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name: "my-schedule"\n)\n\nputs(named_schedule)', }, http: { example: 'curl https://api.metronome.com/v1/customers/getNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "schedule_name": "my-schedule",\n "covering_date": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/customers/updateNamedSchedule', httpMethod: 'post', summary: "Update a customer's named schedule", description: "Update a named schedule for the given customer. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.customers.named_schedules > (method) update', qualified: 'client.v1.customers.namedSchedules.update', params: [ 'customer_id: string;', 'schedule_name: string;', 'starting_at: string;', 'value: object;', 'ending_before?: string;', ], markdown: "## update\n\n`client.v1.customers.namedSchedules.update(customer_id: string, schedule_name: string, starting_at: string, value: object, ending_before?: string): void`\n\n**post** `/v1/customers/updateNamedSchedule`\n\nUpdate a named schedule for the given customer. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `customer_id: string`\n ID of the customer whose named schedule is to be updated\n\n- `schedule_name: string`\n The identifier for the schedule to be updated\n\n- `starting_at: string`\n\n- `value: object`\n The value to set for the named schedule. The structure of this object is specific to the named schedule.\n\n- `ending_before?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customers.namedSchedules.update({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n})\n```", perLanguage: { typescript: { method: 'client.v1.customers.namedSchedules.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customers.namedSchedules.update({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n ending_before: '2022-02-15T00:00:00Z',\n});", }, python: { method: 'v1.customers.named_schedules.update', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.customers.named_schedules.update(\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name="my-schedule",\n starting_at=datetime.fromisoformat("2022-02-01T00:00:00"),\n value={\n "my_key": "my_value"\n },\n ending_before=datetime.fromisoformat("2022-02-15T00:00:00"),\n)', }, java: { method: 'v1().customers().namedSchedules().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.customers.namedschedules.NamedScheduleUpdateParams;\nimport java.time.OffsetDateTime;\nimport java.util.Map;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleUpdateParams params = NamedScheduleUpdateParams.builder()\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .scheduleName("my-schedule")\n .startingAt(OffsetDateTime.parse("2022-02-01T00:00:00Z"))\n .value(JsonValue.from(Map.of(\n "my_key", "my_value"\n )))\n .build();\n client.v1().customers().namedSchedules().update(params);\n }\n}', }, go: { method: 'client.V1.Customers.NamedSchedules.Update', example: 'package main\n\nimport (\n\t"context"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Customers.NamedSchedules.Update(context.TODO(), metronome.V1CustomerNamedScheduleUpdateParams{\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tScheduleName: "my-schedule",\n\t\tStartingAt: time.Now(),\n\t\tValue: map[string]any{\n\t\t\t"my_key": "my_value",\n\t\t},\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.customers.named_schedules.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.customers.named_schedules.update(\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name: "my-schedule",\n starting_at: "2022-02-01T00:00:00Z",\n value: {my_key: "my_value"}\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customers/updateNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "schedule_name": "my-schedule",\n "starting_at": "2022-02-01T00:00:00Z",\n "value": {\n "my_key": "my_value"\n },\n "ending_before": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'get_embeddable_url', endpoint: '/v1/dashboards/getEmbeddableUrl', httpMethod: 'post', summary: 'Get an embeddable customer dashboard', description: 'Generate secure, embeddable dashboard URLs that allow you to seamlessly integrate Metronome\'s billing visualizations directly into your application. This endpoint creates authenticated iframe-ready URLs for customer-specific dashboards, providing a white-labeled billing experience without building custom UI.\n\n### Use this endpoint to:\n- Embed billing dashboards directly in your customer portal or admin interface\n- Provide self-service access to invoices, usage data, and credit balances\n- Build white-labeled billing experiences with minimal development effort\n\n### Key response fields:\n- A secure, time-limited URL that can be embedded in an iframe\n- The URL includes authentication tokens and configuration parameters\n- URLs are customer-specific and respect your security settings\n\n### Usage guidelines:\n- Dashboard types: Choose from `invoices`, `usage`, or `commits_and_credits`\n- Customization options:\n - `dashboard_options`: Configure dashboard behavior. Supported for the invoices dashboard only. Available keys include: `show_zero_usage_line_items` ("true"/"false"), `contract_id` (UUID, filters invoices by contract), `invoice_type` ("USAGE" or "SCHEDULED", filters by invoice type), and `invoice_status_filter` ("VOID", "FINALIZED", "DRAFT", "FINALIZED_AND_DRAFT", or "ALL")\n - `color_overrides`: Match your brand\'s color palette\n- Iframe implementation: Embed the returned URL directly in an iframe element\n- Responsive design: Dashboards automatically adapt to container dimensions\n', stainlessPath: '(resource) v1.dashboards > (method) get_embeddable_url', qualified: 'client.v1.dashboards.getEmbeddableURL', params: [ 'customer_id: string;', "dashboard: 'invoices' | 'usage' | 'credits' | 'commits_and_credits';", 'bm_group_key_overrides?: { group_key_name: string; display_name?: string; value_display_names?: object; }[];', 'color_overrides?: { name?: string; value?: string; }[];', 'dashboard_options?: { key: string; value: string; }[];', ], response: '{ data: { url?: string; }; }', markdown: "## get_embeddable_url\n\n`client.v1.dashboards.getEmbeddableURL(customer_id: string, dashboard: 'invoices' | 'usage' | 'credits' | 'commits_and_credits', bm_group_key_overrides?: { group_key_name: string; display_name?: string; value_display_names?: object; }[], color_overrides?: { name?: string; value?: string; }[], dashboard_options?: { key: string; value: string; }[]): { data: object; }`\n\n**post** `/v1/dashboards/getEmbeddableUrl`\n\nGenerate secure, embeddable dashboard URLs that allow you to seamlessly integrate Metronome's billing visualizations directly into your application. This endpoint creates authenticated iframe-ready URLs for customer-specific dashboards, providing a white-labeled billing experience without building custom UI.\n\n### Use this endpoint to:\n- Embed billing dashboards directly in your customer portal or admin interface\n- Provide self-service access to invoices, usage data, and credit balances\n- Build white-labeled billing experiences with minimal development effort\n\n### Key response fields:\n- A secure, time-limited URL that can be embedded in an iframe\n- The URL includes authentication tokens and configuration parameters\n- URLs are customer-specific and respect your security settings\n\n### Usage guidelines:\n- Dashboard types: Choose from `invoices`, `usage`, or `commits_and_credits`\n- Customization options:\n - `dashboard_options`: Configure dashboard behavior. Supported for the invoices dashboard only. Available keys include: `show_zero_usage_line_items` (\"true\"/\"false\"), `contract_id` (UUID, filters invoices by contract), `invoice_type` (\"USAGE\" or \"SCHEDULED\", filters by invoice type), and `invoice_status_filter` (\"VOID\", \"FINALIZED\", \"DRAFT\", \"FINALIZED_AND_DRAFT\", or \"ALL\")\n - `color_overrides`: Match your brand's color palette\n- Iframe implementation: Embed the returned URL directly in an iframe element\n- Responsive design: Dashboards automatically adapt to container dimensions\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `dashboard: 'invoices' | 'usage' | 'credits' | 'commits_and_credits'`\n The type of dashboard to retrieve.\n\n- `bm_group_key_overrides?: { group_key_name: string; display_name?: string; value_display_names?: object; }[]`\n Optional list of billable metric group key overrides\n\n- `color_overrides?: { name?: string; value?: string; }[]`\n Optional list of colors to override\n\n- `dashboard_options?: { key: string; value: string; }[]`\n Optional dashboard specific options\n\n### Returns\n\n- `{ data: { url?: string; }; }`\n\n - `data: { url?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.dashboards.getEmbeddableURL({ customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491', dashboard: 'invoices' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.dashboards.getEmbeddableURL', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.dashboards.getEmbeddableURL({\n customer_id: '4db51251-61de-4bfe-b9ce-495e244f3491',\n dashboard: 'invoices',\n color_overrides: [{ name: 'Gray_dark', value: '#ff0000' }],\n dashboard_options: [\n { key: 'show_zero_usage_line_items', value: 'false' },\n { key: 'invoice_status_filter', value: 'FINALIZED' },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.dashboards.get_embeddable_url', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.dashboards.get_embeddable_url(\n customer_id="4db51251-61de-4bfe-b9ce-495e244f3491",\n dashboard="invoices",\n color_overrides=[{\n "name": "Gray_dark",\n "value": "#ff0000",\n }],\n dashboard_options=[{\n "key": "show_zero_usage_line_items",\n "value": "false",\n }, {\n "key": "invoice_status_filter",\n "value": "FINALIZED",\n }],\n)\nprint(response.data)', }, java: { method: 'v1().dashboards().getEmbeddableUrl', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.dashboards.DashboardGetEmbeddableUrlParams;\nimport com.metronome.api.models.v1.dashboards.DashboardGetEmbeddableUrlResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n DashboardGetEmbeddableUrlParams params = DashboardGetEmbeddableUrlParams.builder()\n .customerId("4db51251-61de-4bfe-b9ce-495e244f3491")\n .dashboard(DashboardGetEmbeddableUrlParams.Dashboard.INVOICES)\n .build();\n DashboardGetEmbeddableUrlResponse response = client.v1().dashboards().getEmbeddableUrl(params);\n }\n}', }, go: { method: 'client.V1.Dashboards.GetEmbeddableURL', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Dashboards.GetEmbeddableURL(context.TODO(), metronome.V1DashboardGetEmbeddableURLParams{\n\t\tCustomerID: "4db51251-61de-4bfe-b9ce-495e244f3491",\n\t\tDashboard: metronome.V1DashboardGetEmbeddableURLParamsDashboardInvoices,\n\t\tColorOverrides: []metronome.V1DashboardGetEmbeddableURLParamsColorOverride{{\n\t\t\tName: "Gray_dark",\n\t\t\tValue: metronome.String("#ff0000"),\n\t\t}},\n\t\tDashboardOptions: []metronome.V1DashboardGetEmbeddableURLParamsDashboardOption{{\n\t\t\tKey: "show_zero_usage_line_items",\n\t\t\tValue: "false",\n\t\t}, {\n\t\t\tKey: "invoice_status_filter",\n\t\t\tValue: "FINALIZED",\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.dashboards.get_embeddable_url', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.dashboards.get_embeddable_url(\n customer_id: "4db51251-61de-4bfe-b9ce-495e244f3491",\n dashboard: :invoices\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/dashboards/getEmbeddableUrl \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "4db51251-61de-4bfe-b9ce-495e244f3491",\n "dashboard": "invoices",\n "color_overrides": [\n {\n "name": "Gray_dark",\n "value": "#ff0000"\n }\n ],\n "dashboard_options": [\n {\n "key": "show_zero_usage_line_items",\n "value": "false"\n },\n {\n "key": "invoice_status_filter",\n "value": "FINALIZED"\n }\n ]\n }\'', }, }, }, { name: 'ingest', endpoint: '/v1/ingest', httpMethod: 'post', summary: 'Ingest events', description: 'The ingest endpoint is the primary method for sending usage events to Metronome, serving as the foundation for all billing calculations in your usage-based pricing model. This high-throughput endpoint is designed for real-time streaming ingestion, supports backdating 34 days, and is built to handle mission-critical usage data with enterprise-grade reliability. Metronome supports 100,000 events per second without requiring pre-aggregation or rollups and can scale up from there. See the [Send usage events](/guides/events/send-usage-events) guide to learn more about usage events.\n\n### Use this endpoint to:\nCreate a customer usage pipeline into Metronome that drives billable metrics, credit drawdown, and invoicing. Track customer behavior, resource consumption, and feature usage\n\n### What happens when you send events:\n- Events are validated and processed in real-time\n- Events are matched to customers using customer IDs or customer ingest aliases\n- Events are matched to billable metrics and are immediately available for usage and spend calculations\n\n### Usage guidelines:\n- Historical events can be backdated up to 34 days and will immediately impact live customer spend\n- Duplicate events are automatically detected and ignored (34-day deduplication window)\n\n#### Event structure:\nUsage events are simple JSON objects designed for flexibility and ease of integration:\n```json\n{\n "transaction_id": "2021-01-01T00:00:00Z_cluster42",\n "customer_id": "team@example.com",\n "event_type": "api_request",\n "timestamp": "2021-01-01T00:00:00Z",\n "properties": {\n "endpoint": "/v1/users",\n "method": "POST",\n "response_time_ms": 45,\n "region": "us-west-2"\n }\n}\n```\n\nLearn more about [usage event structure definitions](/guides/events/design-usage-events).\n\n#### Transaction ID\n The transaction_id serves as your idempotency key, ensuring events are processed exactly once. Metronome maintains a 34-day deduplication window - significantly longer than typical 12-hour windows - enabling robust backfill scenarios without duplicate billing.\n - Best Practices:\n - Use UUIDs for one-time events: uuid4()\n - For heartbeat events, use deterministic IDs\n - Include enough context to avoid collisions across different event sources\n\n#### Customer ID\nIdentifies which customer should be billed for this usage. Supports two identification methods:\n - Metronome Customer ID: The UUID returned when creating a customer\n - Ingest Alias: Your system\'s identifier (email, account number, etc.) \n\nIngest aliases enable seamless integration without requiring ID mapping, and customers can have multiple aliases for flexibility.\n\n#### Event Type:\nCategorizes the event type for billable metric matching. Choose descriptive names that aligns with the product surface area.\n\n#### Properties:\nFlexible metadata also used to match billable metrics or to be used to serve as group keys to create multiple pricing dimensions or breakdown costs by novel properties for end customers or internal finance teams measuring underlying COGs.\n', stainlessPath: '(resource) v1.usage > (method) ingest', qualified: 'client.v1.usage.ingest', params: [ 'usage?: { customer_id: string; event_type: string; timestamp: string; transaction_id: string; properties?: object; }[];', ], markdown: '## ingest\n\n`client.v1.usage.ingest(usage?: { customer_id: string; event_type: string; timestamp: string; transaction_id: string; properties?: object; }[]): void`\n\n**post** `/v1/ingest`\n\nThe ingest endpoint is the primary method for sending usage events to Metronome, serving as the foundation for all billing calculations in your usage-based pricing model. This high-throughput endpoint is designed for real-time streaming ingestion, supports backdating 34 days, and is built to handle mission-critical usage data with enterprise-grade reliability. Metronome supports 100,000 events per second without requiring pre-aggregation or rollups and can scale up from there. See the [Send usage events](/guides/events/send-usage-events) guide to learn more about usage events.\n\n### Use this endpoint to:\nCreate a customer usage pipeline into Metronome that drives billable metrics, credit drawdown, and invoicing. Track customer behavior, resource consumption, and feature usage\n\n### What happens when you send events:\n- Events are validated and processed in real-time\n- Events are matched to customers using customer IDs or customer ingest aliases\n- Events are matched to billable metrics and are immediately available for usage and spend calculations\n\n### Usage guidelines:\n- Historical events can be backdated up to 34 days and will immediately impact live customer spend\n- Duplicate events are automatically detected and ignored (34-day deduplication window)\n\n#### Event structure:\nUsage events are simple JSON objects designed for flexibility and ease of integration:\n```json\n{\n "transaction_id": "2021-01-01T00:00:00Z_cluster42",\n "customer_id": "team@example.com",\n "event_type": "api_request",\n "timestamp": "2021-01-01T00:00:00Z",\n "properties": {\n "endpoint": "/v1/users",\n "method": "POST",\n "response_time_ms": 45,\n "region": "us-west-2"\n }\n}\n```\n\nLearn more about [usage event structure definitions](/guides/events/design-usage-events).\n\n#### Transaction ID\n The transaction_id serves as your idempotency key, ensuring events are processed exactly once. Metronome maintains a 34-day deduplication window - significantly longer than typical 12-hour windows - enabling robust backfill scenarios without duplicate billing.\n - Best Practices:\n - Use UUIDs for one-time events: uuid4()\n - For heartbeat events, use deterministic IDs\n - Include enough context to avoid collisions across different event sources\n\n#### Customer ID\nIdentifies which customer should be billed for this usage. Supports two identification methods:\n - Metronome Customer ID: The UUID returned when creating a customer\n - Ingest Alias: Your system\'s identifier (email, account number, etc.) \n\nIngest aliases enable seamless integration without requiring ID mapping, and customers can have multiple aliases for flexibility.\n\n#### Event Type:\nCategorizes the event type for billable metric matching. Choose descriptive names that aligns with the product surface area.\n\n#### Properties:\nFlexible metadata also used to match billable metrics or to be used to serve as group keys to create multiple pricing dimensions or breakdown costs by novel properties for end customers or internal finance teams measuring underlying COGs.\n\n\n### Parameters\n\n- `usage?: { customer_id: string; event_type: string; timestamp: string; transaction_id: string; properties?: object; }[]`\n\n### Example\n\n```typescript\nimport Metronome from \'@metronome/sdk\';\n\nconst client = new Metronome();\n\nawait client.v1.usage.ingest()\n```', perLanguage: { typescript: { method: 'client.v1.usage.ingest', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.usage.ingest();", }, python: { method: 'v1.usage.ingest', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.usage.ingest()', }, java: { method: 'v1().usage().ingest', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n client.v1().usage().ingest();\n }\n}', }, go: { method: 'client.V1.Usage.Ingest', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Usage.Ingest(context.TODO(), metronome.V1UsageIngestParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.usage.ingest', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.usage.ingest\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/ingest \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/usage', httpMethod: 'post', summary: 'Get batched usage data', description: 'Retrieve aggregated usage data across multiple customers and billable metrics in a single query. This batch endpoint enables you to fetch usage patterns at scale, broken down by time windows, making it ideal for building analytics dashboards, generating reports, and monitoring platform-wide usage trends.\n\n### Use this endpoint to:\n- Generate platform-wide usage reports for internal teams\n- Monitor aggregate usage trends across your entire customer base\n- Create comparative usage analyses between customers or time periods\n- Support capacity planning with historical usage patterns\n\n### Key response fields:\nAn array of `UsageBatchAggregate` objects containing:\n\n- `customer_id`: The customer this usage belongs to\n- `billable_metric_id` and `billable_metric_name`: What was measured\n- `start_timestamp` and `end_timestamp`: Time window for this data point\n- `value`: Aggregated usage amount for the period\n- `groups` (optional): Usage broken down by group keys with values\n- `next_page`: Pagination cursor for large result sets\n\n### Usage guidelines:\n- Time windows: Set `window_size` to `hour`, `day`, or `none` (entire period)\n- Required parameters: Must specify `starting_on`, `ending_before`, and `window_size`\n- Filtering options:\n - `customer_ids`: Limit to specific customers (omit for all customers)\n - `billable_metrics`: Limit to specific metrics (omit for all metrics)\n- Pagination: Use `next_page` cursor to retrieve large datasets\n- Null values: Group values may be null when no usage matches that group\n', stainlessPath: '(resource) v1.usage > (method) list', qualified: 'client.v1.usage.list', params: [ 'ending_before: string;', 'starting_on: string;', "window_size: 'HOUR' | 'DAY' | 'NONE';", 'next_page?: string;', 'billable_metrics?: { id: string; group_by?: { key: string; values?: string[]; }; }[];', 'customer_ids?: string[];', ], response: '{ billable_metric_id: string; billable_metric_name: string; customer_id: string; end_timestamp: string; start_timestamp: string; value: number; groups?: object; }', markdown: "## list\n\n`client.v1.usage.list(ending_before: string, starting_on: string, window_size: 'HOUR' | 'DAY' | 'NONE', next_page?: string, billable_metrics?: { id: string; group_by?: { key: string; values?: string[]; }; }[], customer_ids?: string[]): { billable_metric_id: string; billable_metric_name: string; customer_id: string; end_timestamp: string; start_timestamp: string; value: number; groups?: object; }`\n\n**post** `/v1/usage`\n\nRetrieve aggregated usage data across multiple customers and billable metrics in a single query. This batch endpoint enables you to fetch usage patterns at scale, broken down by time windows, making it ideal for building analytics dashboards, generating reports, and monitoring platform-wide usage trends.\n\n### Use this endpoint to:\n- Generate platform-wide usage reports for internal teams\n- Monitor aggregate usage trends across your entire customer base\n- Create comparative usage analyses between customers or time periods\n- Support capacity planning with historical usage patterns\n\n### Key response fields:\nAn array of `UsageBatchAggregate` objects containing:\n\n- `customer_id`: The customer this usage belongs to\n- `billable_metric_id` and `billable_metric_name`: What was measured\n- `start_timestamp` and `end_timestamp`: Time window for this data point\n- `value`: Aggregated usage amount for the period\n- `groups` (optional): Usage broken down by group keys with values\n- `next_page`: Pagination cursor for large result sets\n\n### Usage guidelines:\n- Time windows: Set `window_size` to `hour`, `day`, or `none` (entire period)\n- Required parameters: Must specify `starting_on`, `ending_before`, and `window_size`\n- Filtering options:\n - `customer_ids`: Limit to specific customers (omit for all customers)\n - `billable_metrics`: Limit to specific metrics (omit for all metrics)\n- Pagination: Use `next_page` cursor to retrieve large datasets\n- Null values: Group values may be null when no usage matches that group\n\n\n### Parameters\n\n- `ending_before: string`\n\n- `starting_on: string`\n\n- `window_size: 'HOUR' | 'DAY' | 'NONE'`\n A window_size of \"day\" or \"hour\" will return the usage for the specified period segmented into daily or hourly aggregates. A window_size of \"none\" will return a single usage aggregate for the entirety of the specified period.\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `billable_metrics?: { id: string; group_by?: { key: string; values?: string[]; }; }[]`\n A list of billable metrics to fetch usage for. If absent, all billable metrics will be returned.\n\n- `customer_ids?: string[]`\n A list of Metronome customer IDs to fetch usage for. If absent, usage for all customers will be returned.\n\n### Returns\n\n- `{ billable_metric_id: string; billable_metric_name: string; customer_id: string; end_timestamp: string; start_timestamp: string; value: number; groups?: object; }`\n\n - `billable_metric_id: string`\n - `billable_metric_name: string`\n - `customer_id: string`\n - `end_timestamp: string`\n - `start_timestamp: string`\n - `value: number`\n - `groups?: object`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const usageListResponse of client.v1.usage.list({\n ending_before: '2021-01-03T00:00:00Z',\n starting_on: '2021-01-01T00:00:00Z',\n window_size: 'HOUR',\n})) {\n console.log(usageListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.usage.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const usageListResponse of client.v1.usage.list({\n ending_before: '2021-01-03T00:00:00Z',\n starting_on: '2021-01-01T00:00:00Z',\n window_size: 'day',\n})) {\n console.log(usageListResponse.billable_metric_id);\n}", }, python: { method: 'v1.usage.list', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.usage.list(\n ending_before=datetime.fromisoformat("2021-01-03T00:00:00"),\n starting_on=datetime.fromisoformat("2021-01-01T00:00:00"),\n window_size="day",\n)\npage = page.data[0]\nprint(page.billable_metric_id)', }, java: { method: 'v1().usage().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.usage.UsageListPage;\nimport com.metronome.api.models.v1.usage.UsageListParams;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n UsageListParams params = UsageListParams.builder()\n .endingBefore(OffsetDateTime.parse("2021-01-03T00:00:00Z"))\n .startingOn(OffsetDateTime.parse("2021-01-01T00:00:00Z"))\n .windowSize(UsageListParams.WindowSize.HOUR)\n .build();\n UsageListPage page = client.v1().usage().list(params);\n }\n}', }, go: { method: 'client.V1.Usage.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Usage.List(context.TODO(), metronome.V1UsageListParams{\n\t\tEndingBefore: time.Now(),\n\t\tStartingOn: time.Now(),\n\t\tWindowSize: metronome.V1UsageListParamsWindowSize("day"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.usage.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.usage.list(\n ending_before: "2021-01-03T00:00:00Z",\n starting_on: "2021-01-01T00:00:00Z",\n window_size: :HOUR\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/usage \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "ending_before": "2021-01-03T00:00:00Z",\n "starting_on": "2021-01-01T00:00:00Z",\n "window_size": "HOUR"\n }\'', }, }, }, { name: 'list_with_groups', endpoint: '/v1/usage/groups', httpMethod: 'post', summary: 'Get usage data with paginated groupings', description: 'Retrieve granular usage data for a specific customer and billable metric, with the ability to break down usage by custom grouping dimensions. This endpoint enables deep usage analytics by segmenting data across attributes like region, user, model type, or any custom dimension defined in your billable metrics.\n\n### Use this endpoint to:\n- Analyze usage patterns broken down by specific attributes (region, user, department, etc.)\n- Build detailed usage dashboards with dimensional filtering\n- Identify high-usage segments for optimization opportunities\n\n### Request parameters\nUse [`group_key`](#body-group-key) and [`group_filters`](#body-group-filters) to group by one or more dimensions. This is required for compound group keys and recommended for all new integrations:\n```json\n{\n "group_key": ["region", "team"],\n "group_filters": {\n "region": ["US-East", "US-West"]\n }\n}\n```\nImportant: For compound group keys, you must pass the complete set of keys that make up the compound key. Partial key combinations are not supported. For example, if your billable metric has a compound group key [region, team, environment], you must pass all three keys in group_key—you cannot pass just `[region]` or `[region, team]`.\n\n### Key response fields:\nAn array of `PagedUsageAggregate` objects containing:\n- `starting_on` and `ending_before`: Time window boundaries\n- `group`: Object mapping group keys to their values\n - For simple groups, this will be a map with a single key-value pair (e.g., `{"region": "US-East"}`)\n - For compound groups, this will be a map with multiple key-value pairs (e.g., `{"region": "US-East", "team": "engineering"}`)\n- `value`: Aggregated usage for this group and time window\n- `next_page`: Pagination cursor for large datasets\n\n### Usage guidelines:\n- Required parameters: Must specify `customer_id`, `billable_metric_id`, and `window_size`\n- Time windows: Set `window_size` to hour, day, or none for different granularities\n- Group filtering: Use `group_key` and `group_filters` to specify groups and group filters\n- Limits: When using compound group keys (2+ keys in `group_key`), the default and max limit is 100\n- Pagination: Use limit and `next_page` for large result sets\n- Null handling: Group values may be null for events missing the group key property\n', stainlessPath: '(resource) v1.usage > (method) list_with_groups', qualified: 'client.v1.usage.listWithGroups', params: [ 'billable_metric_id: string;', 'customer_id: string;', "window_size: 'HOUR' | 'DAY' | 'NONE';", 'limit?: number;', 'next_page?: string;', 'current_period?: boolean;', 'ending_before?: string;', 'group_by?: { key: string; values?: string[]; };', 'group_filters?: object;', 'group_key?: string[];', 'starting_on?: string;', ], response: '{ ending_before: string; group_key: string; group_value: string; starting_on: string; value: number; group?: object; }', markdown: '## list_with_groups\n\n`client.v1.usage.listWithGroups(billable_metric_id: string, customer_id: string, window_size: \'HOUR\' | \'DAY\' | \'NONE\', limit?: number, next_page?: string, current_period?: boolean, ending_before?: string, group_by?: { key: string; values?: string[]; }, group_filters?: object, group_key?: string[], starting_on?: string): { ending_before: string; group_key: string; group_value: string; starting_on: string; value: number; group?: object; }`\n\n**post** `/v1/usage/groups`\n\nRetrieve granular usage data for a specific customer and billable metric, with the ability to break down usage by custom grouping dimensions. This endpoint enables deep usage analytics by segmenting data across attributes like region, user, model type, or any custom dimension defined in your billable metrics.\n\n### Use this endpoint to:\n- Analyze usage patterns broken down by specific attributes (region, user, department, etc.)\n- Build detailed usage dashboards with dimensional filtering\n- Identify high-usage segments for optimization opportunities\n\n### Request parameters\nUse [`group_key`](#body-group-key) and [`group_filters`](#body-group-filters) to group by one or more dimensions. This is required for compound group keys and recommended for all new integrations:\n```json\n{\n "group_key": ["region", "team"],\n "group_filters": {\n "region": ["US-East", "US-West"]\n }\n}\n```\nImportant: For compound group keys, you must pass the complete set of keys that make up the compound key. Partial key combinations are not supported. For example, if your billable metric has a compound group key [region, team, environment], you must pass all three keys in group_key—you cannot pass just `[region]` or `[region, team]`.\n\n### Key response fields:\nAn array of `PagedUsageAggregate` objects containing:\n- `starting_on` and `ending_before`: Time window boundaries\n- `group`: Object mapping group keys to their values\n - For simple groups, this will be a map with a single key-value pair (e.g., `{"region": "US-East"}`)\n - For compound groups, this will be a map with multiple key-value pairs (e.g., `{"region": "US-East", "team": "engineering"}`)\n- `value`: Aggregated usage for this group and time window\n- `next_page`: Pagination cursor for large datasets\n\n### Usage guidelines:\n- Required parameters: Must specify `customer_id`, `billable_metric_id`, and `window_size`\n- Time windows: Set `window_size` to hour, day, or none for different granularities\n- Group filtering: Use `group_key` and `group_filters` to specify groups and group filters\n- Limits: When using compound group keys (2+ keys in `group_key`), the default and max limit is 100\n- Pagination: Use limit and `next_page` for large result sets\n- Null handling: Group values may be null for events missing the group key property\n\n\n### Parameters\n\n- `billable_metric_id: string`\n\n- `customer_id: string`\n\n- `window_size: \'HOUR\' | \'DAY\' | \'NONE\'`\n A window_size of "day" or "hour" will return the usage for the specified period segmented into daily or hourly aggregates. A window_size of "none" will return a single usage aggregate for the entirety of the specified period.\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `current_period?: boolean`\n If true, will return the usage for the current billing period. Will return an error if the customer is currently uncontracted or starting_on and ending_before are specified when this is true.\n\n- `ending_before?: string`\n\n- `group_by?: { key: string; values?: string[]; }`\n Use group_key and group_filters instead. Use a single group key to group by. Compound group keys are not supported.\n - `key: string`\n The name of the group_by key to use\n - `values?: string[]`\n Values of the group_by key to return in the query. Omit this if you\'d like all values for the key returned.\n\n- `group_filters?: object`\n Object mapping group keys to arrays of values to filter on. Only usage matching these filter values will be returned.\nKeys must be present in group_key. Omit a key or use an empty array to include all values for that dimension.\n\n\n- `group_key?: string[]`\n Group key to group usage by. Supports both simple (single key) and compound (multiple keys) group keys.\n\nFor simple group keys, provide a single key e.g. `["region"]`.\nFor compound group keys, provide multiple keys e.g. `["region", "team"]`.\n\nFor streaming metrics, the keys must be defined as a simple or compound group key on the billable metric.\nFor compound group keys, all keys must match an exact compound group key definition — partial matches are not allowed.\n\nCannot be used together with `group_by`.\n\n\n- `starting_on?: string`\n\n### Returns\n\n- `{ ending_before: string; group_key: string; group_value: string; starting_on: string; value: number; group?: object; }`\n\n - `ending_before: string`\n - `group_key: string`\n - `group_value: string`\n - `starting_on: string`\n - `value: number`\n - `group?: object`\n\n### Example\n\n```typescript\nimport Metronome from \'@metronome/sdk\';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const usageListWithGroupsResponse of client.v1.usage.listWithGroups({\n billable_metric_id: \'222796fd-d29c-429e-89b2-549fabda4ed6\',\n customer_id: \'04ca7e72-4229-4a6e-ab11-9f7376fccbcb\',\n window_size: \'HOUR\',\n})) {\n console.log(usageListWithGroupsResponse);\n}\n```', perLanguage: { typescript: { method: 'client.v1.usage.listWithGroups', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const usageListWithGroupsResponse of client.v1.usage.listWithGroups({\n billable_metric_id: '222796fd-d29c-429e-89b2-549fabda4ed6',\n customer_id: '04ca7e72-4229-4a6e-ab11-9f7376fccbcb',\n window_size: 'day',\n ending_before: '2021-01-03T00:00:00Z',\n group_filters: { region: ['us-east1', 'us-west1'] },\n group_key: ['region'],\n starting_on: '2021-01-01T00:00:00Z',\n})) {\n console.log(usageListWithGroupsResponse.ending_before);\n}", }, python: { method: 'v1.usage.list_with_groups', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.usage.list_with_groups(\n billable_metric_id="222796fd-d29c-429e-89b2-549fabda4ed6",\n customer_id="04ca7e72-4229-4a6e-ab11-9f7376fccbcb",\n window_size="day",\n ending_before=datetime.fromisoformat("2021-01-03T00:00:00"),\n group_filters={\n "region": ["us-east1", "us-west1"]\n },\n group_key=["region"],\n starting_on=datetime.fromisoformat("2021-01-01T00:00:00"),\n)\npage = page.data[0]\nprint(page.ending_before)', }, java: { method: 'v1().usage().listWithGroups', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.usage.UsageListWithGroupsPage;\nimport com.metronome.api.models.v1.usage.UsageListWithGroupsParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n UsageListWithGroupsParams params = UsageListWithGroupsParams.builder()\n .billableMetricId("222796fd-d29c-429e-89b2-549fabda4ed6")\n .customerId("04ca7e72-4229-4a6e-ab11-9f7376fccbcb")\n .windowSize(UsageListWithGroupsParams.WindowSize.HOUR)\n .build();\n UsageListWithGroupsPage page = client.v1().usage().listWithGroups(params);\n }\n}', }, go: { method: 'client.V1.Usage.ListWithGroups', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Usage.ListWithGroups(context.TODO(), metronome.V1UsageListWithGroupsParams{\n\t\tBillableMetricID: "222796fd-d29c-429e-89b2-549fabda4ed6",\n\t\tCustomerID: "04ca7e72-4229-4a6e-ab11-9f7376fccbcb",\n\t\tWindowSize: metronome.V1UsageListWithGroupsParamsWindowSize("day"),\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t\tGroupFilters: map[string][]string{\n\t\t\t"region": {"us-east1", "us-west1"},\n\t\t},\n\t\tGroupKey: []string{"region"},\n\t\tStartingOn: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.usage.list_with_groups', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.usage.list_with_groups(\n billable_metric_id: "222796fd-d29c-429e-89b2-549fabda4ed6",\n customer_id: "04ca7e72-4229-4a6e-ab11-9f7376fccbcb",\n window_size: :HOUR\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/usage/groups \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "billable_metric_id": "222796fd-d29c-429e-89b2-549fabda4ed6",\n "customer_id": "04ca7e72-4229-4a6e-ab11-9f7376fccbcb",\n "window_size": "HOUR",\n "ending_before": "2021-01-03T00:00:00Z",\n "group_filters": {\n "region": [\n "us-east1",\n "us-west1"\n ]\n },\n "group_key": [\n "region"\n ],\n "starting_on": "2021-01-01T00:00:00Z"\n }\'', }, }, }, { name: 'search', endpoint: '/v1/events/search', httpMethod: 'post', summary: 'Search events', description: 'This endpoint retrieves events by transaction ID for events that occurred within the last 34 days. It is specifically designed for sampling-based testing workflows to detect revenue leakage. The Event Search API provides a critical observability tool that validates the integrity of your usage pipeline by allowing you to sample raw events and verify their matching against active billable metrics. \n\nWhy event observability matters for revenue leakage:\nSilent revenue loss occurs when events are dropped, delayed, or fail to match billable metrics due to:\n- Upstream system failures\n- Event format changes\n- Misconfigured billable metrics\n\n### Use this endpoint to:\n- Sample raw events and validate they match the expected billable metrics\n- Build custom leakage detection alerts to prevent silent revenue loss\n- Verify event processing accuracy during system changes or metric updates\n- Debug event matching issues in real-time\n\n### Key response fields:\n- Complete event details including transaction ID, customer ID, and properties\n- Matched Metronome customer (if any)\n- Matched billable metric information (if any)\n- Processing status and duplicate detection flags\n\n### Usage guidelines:\n⚠️ Important: This endpoint is heavily rate limited and designed for sampling workflows only. Do not use this endpoint to check every event in your system. Instead, implement a sampling strategy to randomly validate a subset of events for observability purposes.\n', stainlessPath: '(resource) v1.usage > (method) search', qualified: 'client.v1.usage.search', params: ['transactionIds: string[];'], response: "{ id: string; customer_id: string; event_type: string; timestamp: string; transaction_id: string; is_duplicate?: boolean; matched_billable_metrics?: { id: string; name: string; aggregate?: string; aggregate_keys?: string[]; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE' | 'custom_sql'; archived_at?: string; custom_fields?: object; event_type_filter?: object; filter?: object; group_by?: string[]; group_keys?: string[][]; property_filters?: object[]; sql?: string; }[]; matched_customer?: { id?: string; name?: string; }; processed_at?: string; properties?: object; }[]", markdown: "## search\n\n`client.v1.usage.search(transactionIds: string[]): { id: string; customer_id: string; event_type: string; timestamp: string; transaction_id: string; is_duplicate?: boolean; matched_billable_metrics?: object[]; matched_customer?: object; processed_at?: string; properties?: object; }[]`\n\n**post** `/v1/events/search`\n\nThis endpoint retrieves events by transaction ID for events that occurred within the last 34 days. It is specifically designed for sampling-based testing workflows to detect revenue leakage. The Event Search API provides a critical observability tool that validates the integrity of your usage pipeline by allowing you to sample raw events and verify their matching against active billable metrics. \n\nWhy event observability matters for revenue leakage:\nSilent revenue loss occurs when events are dropped, delayed, or fail to match billable metrics due to:\n- Upstream system failures\n- Event format changes\n- Misconfigured billable metrics\n\n### Use this endpoint to:\n- Sample raw events and validate they match the expected billable metrics\n- Build custom leakage detection alerts to prevent silent revenue loss\n- Verify event processing accuracy during system changes or metric updates\n- Debug event matching issues in real-time\n\n### Key response fields:\n- Complete event details including transaction ID, customer ID, and properties\n- Matched Metronome customer (if any)\n- Matched billable metric information (if any)\n- Processing status and duplicate detection flags\n\n### Usage guidelines:\n⚠️ Important: This endpoint is heavily rate limited and designed for sampling workflows only. Do not use this endpoint to check every event in your system. Instead, implement a sampling strategy to randomly validate a subset of events for observability purposes.\n\n\n### Parameters\n\n- `transactionIds: string[]`\n The transaction IDs of the events to retrieve\n\n### Returns\n\n- `{ id: string; customer_id: string; event_type: string; timestamp: string; transaction_id: string; is_duplicate?: boolean; matched_billable_metrics?: { id: string; name: string; aggregate?: string; aggregate_keys?: string[]; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE' | 'custom_sql'; archived_at?: string; custom_fields?: object; event_type_filter?: object; filter?: object; group_by?: string[]; group_keys?: string[][]; property_filters?: object[]; sql?: string; }[]; matched_customer?: { id?: string; name?: string; }; processed_at?: string; properties?: object; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.usage.search({ transactionIds: ['2021-01-01T00:00:00Z_cluster42'] });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.usage.search', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.usage.search({\n transactionIds: ['2021-01-01T00:00:00Z_cluster42'],\n});\n\nconsole.log(response);", }, python: { method: 'v1.usage.search', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.usage.search(\n transaction_ids=["2021-01-01T00:00:00Z_cluster42"],\n)\nprint(response)', }, java: { method: 'v1().usage().search', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.usage.UsageSearchParams;\nimport com.metronome.api.models.v1.usage.UsageSearchResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n UsageSearchParams params = UsageSearchParams.builder()\n .addTransactionId("2021-01-01T00:00:00Z_cluster42")\n .build();\n List response = client.v1().usage().search(params);\n }\n}', }, go: { method: 'client.V1.Usage.Search', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Usage.Search(context.TODO(), metronome.V1UsageSearchParams{\n\t\tTransactionIDs: []string{"2021-01-01T00:00:00Z_cluster42"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'v1.usage.search', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.usage.search(transaction_ids: ["2021-01-01T00:00:00Z_cluster42"])\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/events/search \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "transactionIds": [\n "2021-01-01T00:00:00Z_cluster42"\n ]\n }\'', }, }, }, { name: 'list', endpoint: '/v1/auditLogs', httpMethod: 'get', summary: 'Get audit logs', description: 'Get a comprehensive audit trail of all operations performed in your Metronome account, whether initiated through the API, web interface, or automated processes. This endpoint provides detailed logs of who did what and when, enabling compliance reporting, security monitoring, and operational troubleshooting across all interaction channels.\n\n### Use this endpoint to:\n- Monitor all account activity for security and compliance purposes\n- Track configuration changes regardless of source (API, UI, or system)\n- Investigate issues by reviewing historical operations\n\n### Key response fields: \nAn array of AuditLog objects containing:\n- id: Unique identifier for the audit log entry\n- timestamp: When the action occurred (RFC 3339 format)\n- actor: Information about who performed the action\n- request: Details including request ID, IP address, and user agent\n- `resource_type`: The type of resource affected (e.g., customer, contract, invoice)\n- `resource_id`: The specific resource identifier\n- `action`: The operation performed\n- `next_page`: Cursor for continuous log retrieval\n\n### Usage guidelines:\n- Continuous retrieval: The next_page token enables uninterrupted log streaming—save it between requests to ensure no logs are missed\n- Empty responses: An empty data array means no new logs yet; continue polling with the same next_page token\n- Date filtering:\n - `starting_on`: Earliest logs to return (inclusive)\n - `ending_before`: Latest logs to return (exclusive)\n - Cannot be used with `next_page`\n- Resource filtering: Must specify both `resource_type` and `resource_id` together\n- Sort order: Default is `date_asc`; use `date_desc` for newest first\n', stainlessPath: '(resource) v1.audit_logs > (method) list', qualified: 'client.v1.auditLogs.list', params: [ 'ending_before?: string;', 'limit?: number;', 'next_page?: string;', 'resource_id?: string;', 'resource_type?: string;', "sort?: 'date_asc' | 'date_desc';", 'starting_on?: string;', ], response: "{ id: string; request: { id: string; ip?: string; user_agent?: string; }; timestamp: string; action?: string; actor?: { id: string; name: string; email?: string; }; description?: string; resource_id?: string; resource_type?: string; status?: 'success' | 'failure' | 'pending'; }", markdown: "## list\n\n`client.v1.auditLogs.list(ending_before?: string, limit?: number, next_page?: string, resource_id?: string, resource_type?: string, sort?: 'date_asc' | 'date_desc', starting_on?: string): { id: string; request: object; timestamp: string; action?: string; actor?: object; description?: string; resource_id?: string; resource_type?: string; status?: 'success' | 'failure' | 'pending'; }`\n\n**get** `/v1/auditLogs`\n\nGet a comprehensive audit trail of all operations performed in your Metronome account, whether initiated through the API, web interface, or automated processes. This endpoint provides detailed logs of who did what and when, enabling compliance reporting, security monitoring, and operational troubleshooting across all interaction channels.\n\n### Use this endpoint to:\n- Monitor all account activity for security and compliance purposes\n- Track configuration changes regardless of source (API, UI, or system)\n- Investigate issues by reviewing historical operations\n\n### Key response fields: \nAn array of AuditLog objects containing:\n- id: Unique identifier for the audit log entry\n- timestamp: When the action occurred (RFC 3339 format)\n- actor: Information about who performed the action\n- request: Details including request ID, IP address, and user agent\n- `resource_type`: The type of resource affected (e.g., customer, contract, invoice)\n- `resource_id`: The specific resource identifier\n- `action`: The operation performed\n- `next_page`: Cursor for continuous log retrieval\n\n### Usage guidelines:\n- Continuous retrieval: The next_page token enables uninterrupted log streaming—save it between requests to ensure no logs are missed\n- Empty responses: An empty data array means no new logs yet; continue polling with the same next_page token\n- Date filtering:\n - `starting_on`: Earliest logs to return (inclusive)\n - `ending_before`: Latest logs to return (exclusive)\n - Cannot be used with `next_page`\n- Resource filtering: Must specify both `resource_type` and `resource_id` together\n- Sort order: Default is `date_asc`; use `date_desc` for newest first\n\n\n### Parameters\n\n- `ending_before?: string`\n RFC 3339 timestamp (exclusive). Cannot be used with 'next_page'.\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `resource_id?: string`\n Optional parameter that can be used to filter which audit logs are returned. If you specify resource_id, you must also specify resource_type.\n\n- `resource_type?: string`\n Optional parameter that can be used to filter which audit logs are returned. If you specify resource_type, you must also specify resource_id.\n\n- `sort?: 'date_asc' | 'date_desc'`\n Sort order by timestamp, e.g. date_asc or date_desc. Defaults to date_asc.\n\n- `starting_on?: string`\n RFC 3339 timestamp of the earliest audit log to return. Cannot be used with 'next_page'.\n\n### Returns\n\n- `{ id: string; request: { id: string; ip?: string; user_agent?: string; }; timestamp: string; action?: string; actor?: { id: string; name: string; email?: string; }; description?: string; resource_id?: string; resource_type?: string; status?: 'success' | 'failure' | 'pending'; }`\n\n - `id: string`\n - `request: { id: string; ip?: string; user_agent?: string; }`\n - `timestamp: string`\n - `action?: string`\n - `actor?: { id: string; name: string; email?: string; }`\n - `description?: string`\n - `resource_id?: string`\n - `resource_type?: string`\n - `status?: 'success' | 'failure' | 'pending'`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const auditLogListResponse of client.v1.auditLogs.list()) {\n console.log(auditLogListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.auditLogs.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const auditLogListResponse of client.v1.auditLogs.list()) {\n console.log(auditLogListResponse.id);\n}", }, python: { method: 'v1.audit_logs.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.audit_logs.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().auditLogs().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.auditlogs.AuditLogListPage;\nimport com.metronome.api.models.v1.auditlogs.AuditLogListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n AuditLogListPage page = client.v1().auditLogs().list();\n }\n}', }, go: { method: 'client.V1.AuditLogs.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.AuditLogs.List(context.TODO(), metronome.V1AuditLogListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.audit_logs.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.audit_logs.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/auditLogs \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'add_key', endpoint: '/v1/customFields/addKey', httpMethod: 'post', summary: 'Create a custom field key', description: 'Creates a new custom field key for a given entity (e.g. billable metric, contract, alert).\n\nCustom fields are properties that you can add to Metronome objects to store metadata like foreign keys or other descriptors. This metadata can get transferred to or accessed by other systems to contextualize Metronome data and power business processes. For example, to service workflows like revenue recognition, reconciliation, and invoicing, custom fields help Metronome know the relationship between entities in the platform and third-party systems.\n\n### Use this endpoint to:\n- Create a new custom field key for Customer objects in Metronome. You can then use the Set Custom Field Values endpoint to set the value of this key for a specific customer. \n- Specify whether the key should enforce uniqueness. If the key is set to enforce uniqueness and you attempt to set a custom field value for the key that already exists, it will fail. \n\n### Usage guidelines:\n- Custom fields set on commits, credits, and contracts can be used to scope alert evaluation. For example, you can create a spend threshold alert that only considers spend associated with contracts with custom field key `contract_type` and value `paygo`\n- Custom fields set on products can be used in the Stripe integration to set metadata on invoices.\n- Custom fields for customers, contracts, invoices, products, commits, scheduled charges, and subscriptions are passed down to the invoice.\n', stainlessPath: '(resource) v1.custom_fields > (method) add_key', qualified: 'client.v1.customFields.addKey', params: ['enforce_uniqueness: boolean;', 'entity: string;', 'key: string;'], markdown: "## add_key\n\n`client.v1.customFields.addKey(enforce_uniqueness: boolean, entity: string, key: string): void`\n\n**post** `/v1/customFields/addKey`\n\nCreates a new custom field key for a given entity (e.g. billable metric, contract, alert).\n\nCustom fields are properties that you can add to Metronome objects to store metadata like foreign keys or other descriptors. This metadata can get transferred to or accessed by other systems to contextualize Metronome data and power business processes. For example, to service workflows like revenue recognition, reconciliation, and invoicing, custom fields help Metronome know the relationship between entities in the platform and third-party systems.\n\n### Use this endpoint to:\n- Create a new custom field key for Customer objects in Metronome. You can then use the Set Custom Field Values endpoint to set the value of this key for a specific customer. \n- Specify whether the key should enforce uniqueness. If the key is set to enforce uniqueness and you attempt to set a custom field value for the key that already exists, it will fail. \n\n### Usage guidelines:\n- Custom fields set on commits, credits, and contracts can be used to scope alert evaluation. For example, you can create a spend threshold alert that only considers spend associated with contracts with custom field key `contract_type` and value `paygo`\n- Custom fields set on products can be used in the Stripe integration to set metadata on invoices.\n- Custom fields for customers, contracts, invoices, products, commits, scheduled charges, and subscriptions are passed down to the invoice.\n\n\n### Parameters\n\n- `enforce_uniqueness: boolean`\n\n- `entity: string`\n\n- `key: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customFields.addKey({\n enforce_uniqueness: true,\n entity: 'customer',\n key: 'x_account_id',\n})\n```", perLanguage: { typescript: { method: 'client.v1.customFields.addKey', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customFields.addKey({\n enforce_uniqueness: true,\n entity: 'customer',\n key: 'x_account_id',\n});", }, python: { method: 'v1.custom_fields.add_key', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.custom_fields.add_key(\n enforce_uniqueness=True,\n entity="customer",\n key="x_account_id",\n)', }, java: { method: 'v1().customFields().addKey', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customfields.CustomFieldAddKeyParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomFieldAddKeyParams params = CustomFieldAddKeyParams.builder()\n .enforceUniqueness(true)\n .entity(CustomFieldAddKeyParams.Entity.CUSTOMER)\n .key("x_account_id")\n .build();\n client.v1().customFields().addKey(params);\n }\n}', }, go: { method: 'client.V1.CustomFields.AddKey', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.CustomFields.AddKey(context.TODO(), metronome.V1CustomFieldAddKeyParams{\n\t\tEnforceUniqueness: true,\n\t\tEntity: metronome.V1CustomFieldAddKeyParamsEntityCustomer,\n\t\tKey: "x_account_id",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.custom_fields.add_key', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.custom_fields.add_key(enforce_uniqueness: true, entity: :customer, key: "x_account_id")\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customFields/addKey \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "enforce_uniqueness": true,\n "entity": "customer",\n "key": "x_account_id"\n }\'', }, }, }, { name: 'remove_key', endpoint: '/v1/customFields/removeKey', httpMethod: 'post', summary: 'Delete a custom field key', description: 'Removes a custom field key from the allowlist for a specific entity type, preventing future use of that key across all instances of the entity. Existing values for this key on entity instances will no longer be accessible once the key is removed.\n', stainlessPath: '(resource) v1.custom_fields > (method) remove_key', qualified: 'client.v1.customFields.removeKey', params: ['entity: string;', 'key: string;'], markdown: "## remove_key\n\n`client.v1.customFields.removeKey(entity: string, key: string): void`\n\n**post** `/v1/customFields/removeKey`\n\nRemoves a custom field key from the allowlist for a specific entity type, preventing future use of that key across all instances of the entity. Existing values for this key on entity instances will no longer be accessible once the key is removed.\n\n\n### Parameters\n\n- `entity: string`\n\n- `key: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customFields.removeKey({ entity: 'customer', key: 'x_account_id' })\n```", perLanguage: { typescript: { method: 'client.v1.customFields.removeKey', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customFields.removeKey({ entity: 'customer', key: 'x_account_id' });", }, python: { method: 'v1.custom_fields.remove_key', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.custom_fields.remove_key(\n entity="customer",\n key="x_account_id",\n)', }, java: { method: 'v1().customFields().removeKey', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customfields.CustomFieldRemoveKeyParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomFieldRemoveKeyParams params = CustomFieldRemoveKeyParams.builder()\n .entity(CustomFieldRemoveKeyParams.Entity.CUSTOMER)\n .key("x_account_id")\n .build();\n client.v1().customFields().removeKey(params);\n }\n}', }, go: { method: 'client.V1.CustomFields.RemoveKey', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.CustomFields.RemoveKey(context.TODO(), metronome.V1CustomFieldRemoveKeyParams{\n\t\tEntity: metronome.V1CustomFieldRemoveKeyParamsEntityCustomer,\n\t\tKey: "x_account_id",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.custom_fields.remove_key', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.custom_fields.remove_key(entity: :customer, key: "x_account_id")\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customFields/removeKey \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "entity": "customer",\n "key": "x_account_id"\n }\'', }, }, }, { name: 'set_values', endpoint: '/v1/customFields/setValues', httpMethod: 'post', summary: 'Set custom field values', description: 'Sets custom field values on a specific Metronome entity instance. Overwrites existing values for matching keys while preserving other fields. All updates are transactional—either all values are set or none are. Custom field values are limited to 200 characters each.\n', stainlessPath: '(resource) v1.custom_fields > (method) set_values', qualified: 'client.v1.customFields.setValues', params: ['custom_fields: object;', 'entity: string;', 'entity_id: string;'], markdown: '## set_values\n\n`client.v1.customFields.setValues(custom_fields: object, entity: string, entity_id: string): void`\n\n**post** `/v1/customFields/setValues`\n\nSets custom field values on a specific Metronome entity instance. Overwrites existing values for matching keys while preserving other fields. All updates are transactional—either all values are set or none are. Custom field values are limited to 200 characters each.\n\n\n### Parameters\n\n- `custom_fields: object`\n Custom fields to be added eg. { "key1": "value1", "key2": "value2" }\n\n- `entity: string`\n\n- `entity_id: string`\n\n### Example\n\n```typescript\nimport Metronome from \'@metronome/sdk\';\n\nconst client = new Metronome();\n\nawait client.v1.customFields.setValues({\n custom_fields: { x_account_id: \'KyVnHhSBWl7eY2bl\' },\n entity: \'customer\',\n entity_id: \'99594816-e8a5-4bca-be21-8d1de0f45120\',\n})\n```', perLanguage: { typescript: { method: 'client.v1.customFields.setValues', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customFields.setValues({\n custom_fields: { x_account_id: 'KyVnHhSBWl7eY2bl' },\n entity: 'customer',\n entity_id: '99594816-e8a5-4bca-be21-8d1de0f45120',\n});", }, python: { method: 'v1.custom_fields.set_values', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.custom_fields.set_values(\n custom_fields={\n "x_account_id": "KyVnHhSBWl7eY2bl"\n },\n entity="customer",\n entity_id="99594816-e8a5-4bca-be21-8d1de0f45120",\n)', }, java: { method: 'v1().customFields().setValues', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.customfields.CustomFieldSetValuesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomFieldSetValuesParams params = CustomFieldSetValuesParams.builder()\n .customFields(CustomFieldSetValuesParams.CustomFields.builder()\n .putAdditionalProperty("x_account_id", JsonValue.from("KyVnHhSBWl7eY2bl"))\n .build())\n .entity(CustomFieldSetValuesParams.Entity.CUSTOMER)\n .entityId("99594816-e8a5-4bca-be21-8d1de0f45120")\n .build();\n client.v1().customFields().setValues(params);\n }\n}', }, go: { method: 'client.V1.CustomFields.SetValues', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.CustomFields.SetValues(context.TODO(), metronome.V1CustomFieldSetValuesParams{\n\t\tCustomFields: map[string]string{\n\t\t\t"x_account_id": "KyVnHhSBWl7eY2bl",\n\t\t},\n\t\tEntity: metronome.V1CustomFieldSetValuesParamsEntityCustomer,\n\t\tEntityID: "99594816-e8a5-4bca-be21-8d1de0f45120",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.custom_fields.set_values', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.custom_fields.set_values(\n custom_fields: {x_account_id: "KyVnHhSBWl7eY2bl"},\n entity: :customer,\n entity_id: "99594816-e8a5-4bca-be21-8d1de0f45120"\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customFields/setValues \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "custom_fields": {\n "x_account_id": "KyVnHhSBWl7eY2bl"\n },\n "entity": "customer",\n "entity_id": "99594816-e8a5-4bca-be21-8d1de0f45120"\n }\'', }, }, }, { name: 'delete_values', endpoint: '/v1/customFields/deleteValues', httpMethod: 'post', summary: 'Delete custom fields', description: 'Remove specific custom field values from a Metronome entity instance by specifying the field keys to delete. Use this endpoint to clean up unwanted custom field data while preserving other fields on the same entity. Requires the entity type, entity ID, and array of keys to remove.\n', stainlessPath: '(resource) v1.custom_fields > (method) delete_values', qualified: 'client.v1.customFields.deleteValues', params: ['entity: string;', 'entity_id: string;', 'keys: string[];'], markdown: "## delete_values\n\n`client.v1.customFields.deleteValues(entity: string, entity_id: string, keys: string[]): void`\n\n**post** `/v1/customFields/deleteValues`\n\nRemove specific custom field values from a Metronome entity instance by specifying the field keys to delete. Use this endpoint to clean up unwanted custom field data while preserving other fields on the same entity. Requires the entity type, entity ID, and array of keys to remove.\n\n\n### Parameters\n\n- `entity: string`\n\n- `entity_id: string`\n\n- `keys: string[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.customFields.deleteValues({\n entity: 'customer',\n entity_id: '99594816-e8a5-4bca-be21-8d1de0f45120',\n keys: ['x_account_id'],\n})\n```", perLanguage: { typescript: { method: 'client.v1.customFields.deleteValues', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.customFields.deleteValues({\n entity: 'customer',\n entity_id: '99594816-e8a5-4bca-be21-8d1de0f45120',\n keys: ['x_account_id'],\n});", }, python: { method: 'v1.custom_fields.delete_values', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.custom_fields.delete_values(\n entity="customer",\n entity_id="99594816-e8a5-4bca-be21-8d1de0f45120",\n keys=["x_account_id"],\n)', }, java: { method: 'v1().customFields().deleteValues', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customfields.CustomFieldDeleteValuesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomFieldDeleteValuesParams params = CustomFieldDeleteValuesParams.builder()\n .entity(CustomFieldDeleteValuesParams.Entity.CUSTOMER)\n .entityId("99594816-e8a5-4bca-be21-8d1de0f45120")\n .addKey("x_account_id")\n .build();\n client.v1().customFields().deleteValues(params);\n }\n}', }, go: { method: 'client.V1.CustomFields.DeleteValues', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.CustomFields.DeleteValues(context.TODO(), metronome.V1CustomFieldDeleteValuesParams{\n\t\tEntity: metronome.V1CustomFieldDeleteValuesParamsEntityCustomer,\n\t\tEntityID: "99594816-e8a5-4bca-be21-8d1de0f45120",\n\t\tKeys: []string{"x_account_id"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.custom_fields.delete_values', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.custom_fields.delete_values(\n entity: :customer,\n entity_id: "99594816-e8a5-4bca-be21-8d1de0f45120",\n keys: ["x_account_id"]\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/customFields/deleteValues \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "entity": "customer",\n "entity_id": "99594816-e8a5-4bca-be21-8d1de0f45120",\n "keys": [\n "x_account_id"\n ]\n }\'', }, }, }, { name: 'list_keys', endpoint: '/v1/customFields/listKeys', httpMethod: 'post', summary: 'List custom field keys', description: 'Retrieve all your active custom field keys, with optional filtering by entity type (customer, contract, product, etc.). Use this endpoint to discover what custom field keys are available before setting values on entities or to audit your custom field configuration across different entity types.\n', stainlessPath: '(resource) v1.custom_fields > (method) list_keys', qualified: 'client.v1.customFields.listKeys', params: ['next_page?: string;', 'entities?: string[];'], response: '{ enforce_uniqueness: boolean; entity: string; key: string; }', markdown: "## list_keys\n\n`client.v1.customFields.listKeys(next_page?: string, entities?: string[]): { enforce_uniqueness: boolean; entity: string; key: string; }`\n\n**post** `/v1/customFields/listKeys`\n\nRetrieve all your active custom field keys, with optional filtering by entity type (customer, contract, product, etc.). Use this endpoint to discover what custom field keys are available before setting values on entities or to audit your custom field configuration across different entity types.\n\n\n### Parameters\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `entities?: string[]`\n Optional list of entity types to return keys for\n\n### Returns\n\n- `{ enforce_uniqueness: boolean; entity: string; key: string; }`\n\n - `enforce_uniqueness: boolean`\n - `entity: string`\n - `key: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const customFieldListKeysResponse of client.v1.customFields.listKeys()) {\n console.log(customFieldListKeysResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.customFields.listKeys', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const customFieldListKeysResponse of client.v1.customFields.listKeys({\n entities: ['customer'],\n})) {\n console.log(customFieldListKeysResponse.enforce_uniqueness);\n}", }, python: { method: 'v1.custom_fields.list_keys', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.custom_fields.list_keys(\n entities=["customer"],\n)\npage = page.data[0]\nprint(page.enforce_uniqueness)', }, java: { method: 'v1().customFields().listKeys', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.customfields.CustomFieldListKeysPage;\nimport com.metronome.api.models.v1.customfields.CustomFieldListKeysParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n CustomFieldListKeysPage page = client.v1().customFields().listKeys();\n }\n}', }, go: { method: 'client.V1.CustomFields.ListKeys', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.CustomFields.ListKeys(context.TODO(), metronome.V1CustomFieldListKeysParams{\n\t\tEntities: []string{"customer"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.custom_fields.list_keys', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.custom_fields.list_keys\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/customFields/listKeys \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/billable-metrics/create', httpMethod: 'post', summary: 'Create a billable metric', description: 'Create billable metrics programmatically with this endpoint—an essential step in configuring your pricing and packaging in Metronome.\n\nA billable metric is a customizable query that filters and aggregates events from your event stream. These metrics are continuously tracked as usage data enters Metronome through the ingestion pipeline. The ingestion process transforms raw usage data into actionable pricing metrics, enabling accurate metering and billing for your products.\n\n### Use this endpoint to: \n- Create individual or multiple billable metrics as part of a setup workflow.\n- Automate the entire pricing configuration process, from metric creation to customer contract setup.\n- Define metrics using either standard filtering/aggregation or a custom SQL query.\n\n### Key response fields: \n- The ID of the billable metric that was created\n- The created billable metric will be available to be used in Products, usage endpoints, and alerts. \n\n### Usage guidelines: \n- Metrics defined using standard filtering and aggregation are Streaming billable metrics, which have been optimized for ultra low latency and high throughput workflows. \n- Use SQL billable metrics if you require more flexible aggregation options.\n', stainlessPath: '(resource) v1.billable_metrics > (method) create', qualified: 'client.v1.billableMetrics.create', params: [ 'name: string;', 'aggregation_key?: string;', "aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE';", 'custom_fields?: object;', 'event_type_filter?: { in_values?: string[]; not_in_values?: string[]; };', 'group_keys?: string[][];', 'property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[];', 'sql?: string;', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.billableMetrics.create(name: string, aggregation_key?: string, aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE', custom_fields?: object, event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }, group_keys?: string[][], property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[], sql?: string): { data: id; }`\n\n**post** `/v1/billable-metrics/create`\n\nCreate billable metrics programmatically with this endpoint—an essential step in configuring your pricing and packaging in Metronome.\n\nA billable metric is a customizable query that filters and aggregates events from your event stream. These metrics are continuously tracked as usage data enters Metronome through the ingestion pipeline. The ingestion process transforms raw usage data into actionable pricing metrics, enabling accurate metering and billing for your products.\n\n### Use this endpoint to: \n- Create individual or multiple billable metrics as part of a setup workflow.\n- Automate the entire pricing configuration process, from metric creation to customer contract setup.\n- Define metrics using either standard filtering/aggregation or a custom SQL query.\n\n### Key response fields: \n- The ID of the billable metric that was created\n- The created billable metric will be available to be used in Products, usage endpoints, and alerts. \n\n### Usage guidelines: \n- Metrics defined using standard filtering and aggregation are Streaming billable metrics, which have been optimized for ultra low latency and high throughput workflows. \n- Use SQL billable metrics if you require more flexible aggregation options.\n\n\n### Parameters\n\n- `name: string`\n The display name of the billable metric.\n\n- `aggregation_key?: string`\n Specifies the type of aggregation performed on matching events. Required if `sql` is not provided.\n\n- `aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'`\n Specifies the type of aggregation performed on matching events.\n\n- `custom_fields?: object`\n Custom fields to attach to the billable metric.\n\n- `event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }`\n An optional filtering rule to match the 'event_type' property of an event.\n - `in_values?: string[]`\n A list of event types that are explicitly included in the billable metric. If specified, only events of these types will match the billable metric. Must be non-empty if present.\n - `not_in_values?: string[]`\n A list of event types that are explicitly excluded from the billable metric. If specified, events of these types will not match the billable metric. Must be non-empty if present.\n\n- `group_keys?: string[][]`\n Property names that are used to group usage costs on an invoice. Each entry represents a set of properties used to slice events into distinct buckets.\n\n- `property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]`\n A list of filters to match events to this billable metric. Each filter defines a rule on an event property. All rules must pass for the event to match the billable metric.\n\n- `sql?: string`\n The SQL query associated with the billable metric. This field is mutually exclusive with aggregation_type, event_type_filter, property_filters, aggregation_key, and group_keys. If provided, these other fields must be omitted.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst billableMetric = await client.v1.billableMetrics.create({ name: 'CPU Hours' });\n\nconsole.log(billableMetric);\n```", perLanguage: { typescript: { method: 'client.v1.billableMetrics.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst billableMetric = await client.v1.billableMetrics.create({\n name: 'CPU Hours',\n aggregation_key: 'cpu_hours',\n aggregation_type: 'SUM',\n event_type_filter: { in_values: ['cpu_usage'] },\n group_keys: [['region'], ['machine_type']],\n property_filters: [\n { name: 'cpu_hours', exists: true },\n {\n name: 'region',\n exists: true,\n in_values: ['EU', 'NA'],\n },\n {\n name: 'machine_type',\n exists: true,\n in_values: ['slow', 'fast'],\n },\n ],\n});\n\nconsole.log(billableMetric.data);", }, python: { method: 'v1.billable_metrics.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nbillable_metric = client.v1.billable_metrics.create(\n name="CPU Hours",\n aggregation_key="cpu_hours",\n aggregation_type="SUM",\n event_type_filter={\n "in_values": ["cpu_usage"]\n },\n group_keys=[["region"], ["machine_type"]],\n property_filters=[{\n "name": "cpu_hours",\n "exists": True,\n }, {\n "name": "region",\n "exists": True,\n "in_values": ["EU", "NA"],\n }, {\n "name": "machine_type",\n "exists": True,\n "in_values": ["slow", "fast"],\n }],\n)\nprint(billable_metric.data)', }, java: { method: 'v1().billableMetrics().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricCreateParams;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillableMetricCreateParams params = BillableMetricCreateParams.builder()\n .name("CPU Hours")\n .build();\n BillableMetricCreateResponse billableMetric = client.v1().billableMetrics().create(params);\n }\n}', }, go: { method: 'client.V1.BillableMetrics.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tbillableMetric, err := client.V1.BillableMetrics.New(context.TODO(), metronome.V1BillableMetricNewParams{\n\t\tName: "CPU Hours",\n\t\tAggregationKey: metronome.String("cpu_hours"),\n\t\tAggregationType: metronome.V1BillableMetricNewParamsAggregationTypeSum,\n\t\tEventTypeFilter: shared.EventTypeFilterParam{\n\t\t\tInValues: []string{"cpu_usage"},\n\t\t},\n\t\tGroupKeys: [][]string{{"region"}, {"machine_type"}},\n\t\tPropertyFilters: []shared.PropertyFilterParam{{\n\t\t\tName: "cpu_hours",\n\t\t\tExists: metronome.Bool(true),\n\t\t}, {\n\t\t\tName: "region",\n\t\t\tExists: metronome.Bool(true),\n\t\t\tInValues: []string{"EU", "NA"},\n\t\t}, {\n\t\t\tName: "machine_type",\n\t\t\tExists: metronome.Bool(true),\n\t\t\tInValues: []string{"slow", "fast"},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", billableMetric.Data)\n}\n', }, ruby: { method: 'v1.billable_metrics.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nbillable_metric = metronome.v1.billable_metrics.create(name: "CPU Hours")\n\nputs(billable_metric)', }, http: { example: 'curl https://api.metronome.com/v1/billable-metrics/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "CPU Hours",\n "aggregation_key": "cpu_hours",\n "aggregation_type": "SUM",\n "event_type_filter": {\n "in_values": [\n "cpu_usage"\n ]\n },\n "group_keys": [\n [\n "region"\n ],\n [\n "machine_type"\n ]\n ],\n "property_filters": [\n {\n "name": "cpu_hours",\n "exists": true\n },\n {\n "name": "region",\n "exists": true,\n "in_values": [\n "EU",\n "NA"\n ]\n },\n {\n "name": "machine_type",\n "exists": true,\n "in_values": [\n "slow",\n "fast"\n ]\n }\n ]\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/billable-metrics/archive', httpMethod: 'post', summary: 'Archive a billable metric', description: 'Use this endpoint to retire billable metrics that are no longer used. After a billable metric is archived, that billable metric can no longer be used in any new Products to define how that product should be metered. If you archive a billable metric that is already associated with a Product, the Product will continue to function as usual, metering based on the definition of the archived billable metric. \n\nArchived billable metrics will be returned on the `getBillableMetric` and `listBillableMetrics` endpoints with a populated `archived_at` field.\n', stainlessPath: '(resource) v1.billable_metrics > (method) archive', qualified: 'client.v1.billableMetrics.archive', params: ['id: string;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.billableMetrics.archive(id: string): { data: id; }`\n\n**post** `/v1/billable-metrics/archive`\n\nUse this endpoint to retire billable metrics that are no longer used. After a billable metric is archived, that billable metric can no longer be used in any new Products to define how that product should be metered. If you archive a billable metric that is already associated with a Product, the Product will continue to function as usual, metering based on the definition of the archived billable metric. \n\nArchived billable metrics will be returned on the `getBillableMetric` and `listBillableMetrics` endpoints with a populated `archived_at` field.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.billableMetrics.archive({ id: '8deed800-1b7a-495d-a207-6c52bac54dc9' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.billableMetrics.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.billableMetrics.archive({\n id: '8deed800-1b7a-495d-a207-6c52bac54dc9',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.billable_metrics.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.billable_metrics.archive(\n id="8deed800-1b7a-495d-a207-6c52bac54dc9",\n)\nprint(response.data)', }, java: { method: 'v1().billableMetrics().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.Id;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n Id params = Id.builder()\n .id("8deed800-1b7a-495d-a207-6c52bac54dc9")\n .build();\n BillableMetricArchiveResponse response = client.v1().billableMetrics().archive(params);\n }\n}', }, go: { method: 'client.V1.BillableMetrics.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.BillableMetrics.Archive(context.TODO(), metronome.V1BillableMetricArchiveParams{\n\t\tID: shared.IDParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.billable_metrics.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.billable_metrics.archive(id: "8deed800-1b7a-495d-a207-6c52bac54dc9")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/billable-metrics/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "8deed800-1b7a-495d-a207-6c52bac54dc9"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/billable-metrics/{billable_metric_id}', httpMethod: 'get', summary: 'Get a billable metric', description: "Retrieves the complete configuration for a specific billable metric by its ID. Use this to review billable metric setup before associating it with products. Returns the metric's `name`, `event_type_filter`, `property_filters`, `aggregation_type`, `aggregation_key`, `group_keys`, `custom fields`, and `SQL query` (if it's a SQL billable metric). \n\nImportant: \n- Archived billable metrics will include an `archived_at` timestamp; they no longer process new usage events but remain accessible for historical reference.\n", stainlessPath: '(resource) v1.billable_metrics > (method) retrieve', qualified: 'client.v1.billableMetrics.retrieve', params: ['billable_metric_id: string;'], response: "{ data: { id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: object; group_keys?: string[][]; property_filters?: object[]; sql?: string; }; }", markdown: "## retrieve\n\n`client.v1.billableMetrics.retrieve(billable_metric_id: string): { data: object; }`\n\n**get** `/v1/billable-metrics/{billable_metric_id}`\n\nRetrieves the complete configuration for a specific billable metric by its ID. Use this to review billable metric setup before associating it with products. Returns the metric's `name`, `event_type_filter`, `property_filters`, `aggregation_type`, `aggregation_key`, `group_keys`, `custom fields`, and `SQL query` (if it's a SQL billable metric). \n\nImportant: \n- Archived billable metrics will include an `archived_at` timestamp; they no longer process new usage events but remain accessible for historical reference.\n\n\n### Parameters\n\n- `billable_metric_id: string`\n\n### Returns\n\n- `{ data: { id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: object; group_keys?: string[][]; property_filters?: object[]; sql?: string; }; }`\n\n - `data: { id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }; group_keys?: string[][]; property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]; sql?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst billableMetric = await client.v1.billableMetrics.retrieve({ billable_metric_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(billableMetric);\n```", perLanguage: { typescript: { method: 'client.v1.billableMetrics.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst billableMetric = await client.v1.billableMetrics.retrieve({\n billable_metric_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(billableMetric.data);", }, python: { method: 'v1.billable_metrics.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nbillable_metric = client.v1.billable_metrics.retrieve(\n billable_metric_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(billable_metric.data)', }, java: { method: 'v1().billableMetrics().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricRetrieveParams;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillableMetricRetrieveParams params = BillableMetricRetrieveParams.builder()\n .billableMetricId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n BillableMetricRetrieveResponse billableMetric = client.v1().billableMetrics().retrieve(params);\n }\n}', }, go: { method: 'client.V1.BillableMetrics.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tbillableMetric, err := client.V1.BillableMetrics.Get(context.TODO(), metronome.V1BillableMetricGetParams{\n\t\tBillableMetricID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", billableMetric.Data)\n}\n', }, ruby: { method: 'v1.billable_metrics.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nbillable_metric = metronome.v1.billable_metrics.retrieve(billable_metric_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(billable_metric)', }, http: { example: 'curl https://api.metronome.com/v1/billable-metrics/$BILLABLE_METRIC_ID \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/billable-metrics', httpMethod: 'get', summary: 'List all billable metrics', description: 'Retrieves all billable metrics with their complete configurations. Use this for programmatic discovery and management of billable metrics, such as associating metrics to products and auditing for orphaned or archived metrics. \nImportant: Archived metrics are excluded by default; use `include_archived`=`true` parameter to include them.\n', stainlessPath: '(resource) v1.billable_metrics > (method) list', qualified: 'client.v1.billableMetrics.list', params: ['include_archived?: boolean;', 'limit?: number;', 'next_page?: string;'], response: "{ id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }; group_keys?: string[][]; property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]; sql?: string; }", markdown: "## list\n\n`client.v1.billableMetrics.list(include_archived?: boolean, limit?: number, next_page?: string): { id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: event_type_filter; group_keys?: string[][]; property_filters?: property_filter[]; sql?: string; }`\n\n**get** `/v1/billable-metrics`\n\nRetrieves all billable metrics with their complete configurations. Use this for programmatic discovery and management of billable metrics, such as associating metrics to products and auditing for orphaned or archived metrics. \nImportant: Archived metrics are excluded by default; use `include_archived`=`true` parameter to include them.\n\n\n### Parameters\n\n- `include_archived?: boolean`\n If true, the list of returned metrics will include archived metrics\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n### Returns\n\n- `{ id: string; name: string; aggregation_key?: string; aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'; archived_at?: string; custom_fields?: object; event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }; group_keys?: string[][]; property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]; sql?: string; }`\n\n - `id: string`\n - `name: string`\n - `aggregation_key?: string`\n - `aggregation_type?: 'COUNT' | 'LATEST' | 'MAX' | 'SUM' | 'UNIQUE'`\n - `archived_at?: string`\n - `custom_fields?: object`\n - `event_type_filter?: { in_values?: string[]; not_in_values?: string[]; }`\n - `group_keys?: string[][]`\n - `property_filters?: { name: string; exists?: boolean; in_values?: string[]; not_in_values?: string[]; }[]`\n - `sql?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const billableMetricListResponse of client.v1.billableMetrics.list()) {\n console.log(billableMetricListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.billableMetrics.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const billableMetricListResponse of client.v1.billableMetrics.list()) {\n console.log(billableMetricListResponse.id);\n}", }, python: { method: 'v1.billable_metrics.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.billable_metrics.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().billableMetrics().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricListPage;\nimport com.metronome.api.models.v1.billablemetrics.BillableMetricListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillableMetricListPage page = client.v1().billableMetrics().list();\n }\n}', }, go: { method: 'client.V1.BillableMetrics.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.BillableMetrics.List(context.TODO(), metronome.V1BillableMetricListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.billable_metrics.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.billable_metrics.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/billable-metrics \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list', endpoint: '/v1/services', httpMethod: 'get', summary: 'Get services', description: "Gets Metronome's service registry with associated IP addresses for security allowlisting and firewall configuration. Use this endpoint to maintain an up-to-date list of IPs that your systems should trust for Metronome communications. Returns service names and their current IP ranges, with new IPs typically appearing 30+ days before first use to ensure smooth allowlist updates.\n", stainlessPath: '(resource) v1.services > (method) list', qualified: 'client.v1.services.list', response: "{ services: { ips: string[]; name: string; usage: 'makes_connections_from' | 'accepts_connections_at'; }[]; }", markdown: "## list\n\n`client.v1.services.list(): { services: object[]; }`\n\n**get** `/v1/services`\n\nGets Metronome's service registry with associated IP addresses for security allowlisting and firewall configuration. Use this endpoint to maintain an up-to-date list of IPs that your systems should trust for Metronome communications. Returns service names and their current IP ranges, with new IPs typically appearing 30+ days before first use to ensure smooth allowlist updates.\n\n\n### Returns\n\n- `{ services: { ips: string[]; name: string; usage: 'makes_connections_from' | 'accepts_connections_at'; }[]; }`\n\n - `services: { ips: string[]; name: string; usage: 'makes_connections_from' | 'accepts_connections_at'; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst services = await client.v1.services.list();\n\nconsole.log(services);\n```", perLanguage: { typescript: { method: 'client.v1.services.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst services = await client.v1.services.list();\n\nconsole.log(services.services);", }, python: { method: 'v1.services.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nservices = client.v1.services.list()\nprint(services.services)', }, java: { method: 'v1().services().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.services.ServiceListParams;\nimport com.metronome.api.models.v1.services.ServiceListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ServiceListResponse services = client.v1().services().list();\n }\n}', }, go: { method: 'client.V1.Services.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tservices, err := client.V1.Services.List(context.TODO())\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", services.Services)\n}\n', }, ruby: { method: 'v1.services.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nservices = metronome.v1.services.list\n\nputs(services)', }, http: { example: 'curl https://api.metronome.com/v1/services \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'void', endpoint: '/v1/invoices/void', httpMethod: 'post', summary: 'Void an invoice', description: 'Permanently cancels an invoice by setting its status to voided, preventing collection and removing it from customer billing. Use this to correct billing errors, cancel incorrect charges, or handle disputed invoices that should not be collected. Returns the voided invoice ID with the status change applied immediately to stop any payment processing.\n', stainlessPath: '(resource) v1.invoices > (method) void', qualified: 'client.v1.invoices.void', params: ['id: string;'], response: '{ data?: { id: string; }; }', markdown: "## void\n\n`client.v1.invoices.void(id: string): { data?: object; }`\n\n**post** `/v1/invoices/void`\n\nPermanently cancels an invoice by setting its status to voided, preventing collection and removing it from customer billing. Use this to correct billing errors, cancel incorrect charges, or handle disputed invoices that should not be collected. Returns the voided invoice ID with the status change applied immediately to stop any payment processing.\n\n\n### Parameters\n\n- `id: string`\n The invoice id to void\n\n### Returns\n\n- `{ data?: { id: string; }; }`\n\n - `data?: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.invoices.void({ id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.invoices.void', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.invoices.void({ id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(response.data);", }, python: { method: 'v1.invoices.void', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.invoices.void(\n id="6a37bb88-8538-48c5-b37b-a41c836328bd",\n)\nprint(response.data)', }, java: { method: 'v1().invoices().void_', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.invoices.InvoiceVoidParams;\nimport com.metronome.api.models.v1.invoices.InvoiceVoidResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceVoidParams params = InvoiceVoidParams.builder()\n .id("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\n InvoiceVoidResponse response = client.v1().invoices().void_(params);\n }\n}', }, go: { method: 'client.V1.Invoices.Void', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Invoices.Void(context.TODO(), metronome.V1InvoiceVoidParams{\n\t\tID: "6a37bb88-8538-48c5-b37b-a41c836328bd",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.invoices.void', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.invoices.void(id: "6a37bb88-8538-48c5-b37b-a41c836328bd")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/invoices/void \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "6a37bb88-8538-48c5-b37b-a41c836328bd"\n }\'', }, }, }, { name: 'regenerate', endpoint: '/v1/invoices/regenerate', httpMethod: 'post', summary: 'Regenerate an invoice', description: 'This endpoint regenerates a voided invoice and recalculates the invoice based on up-to-date rates, available balances, and other fees regardless of the billing period.\n\n### Use this endpoint to:\nRecalculate an invoice with updated rate terms, available balance, and fees to correct billing disputes or discrepancies\n\n### Key response fields:\nThe regenerated invoice id, which is distinct from the previously voided invoice.\n\n### Usage guidelines:\nIf an invoice is attached to a contract with a billing provider on it, the regenerated invoice will be distributed based on the configuration.\n', stainlessPath: '(resource) v1.invoices > (method) regenerate', qualified: 'client.v1.invoices.regenerate', params: ['id: string;'], response: '{ data?: { id: string; }; }', markdown: "## regenerate\n\n`client.v1.invoices.regenerate(id: string): { data?: object; }`\n\n**post** `/v1/invoices/regenerate`\n\nThis endpoint regenerates a voided invoice and recalculates the invoice based on up-to-date rates, available balances, and other fees regardless of the billing period.\n\n### Use this endpoint to:\nRecalculate an invoice with updated rate terms, available balance, and fees to correct billing disputes or discrepancies\n\n### Key response fields:\nThe regenerated invoice id, which is distinct from the previously voided invoice.\n\n### Usage guidelines:\nIf an invoice is attached to a contract with a billing provider on it, the regenerated invoice will be distributed based on the configuration.\n\n\n### Parameters\n\n- `id: string`\n The invoice id to regenerate\n\n### Returns\n\n- `{ data?: { id: string; }; }`\n\n - `data?: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.invoices.regenerate({ id: '6a37bb88-8538-48c5-b37b-a41c836328bd' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.invoices.regenerate', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.invoices.regenerate({\n id: '6a37bb88-8538-48c5-b37b-a41c836328bd',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.invoices.regenerate', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.invoices.regenerate(\n id="6a37bb88-8538-48c5-b37b-a41c836328bd",\n)\nprint(response.data)', }, java: { method: 'v1().invoices().regenerate', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.invoices.InvoiceRegenerateParams;\nimport com.metronome.api.models.v1.invoices.InvoiceRegenerateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n InvoiceRegenerateParams params = InvoiceRegenerateParams.builder()\n .id("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\n InvoiceRegenerateResponse response = client.v1().invoices().regenerate(params);\n }\n}', }, go: { method: 'client.V1.Invoices.Regenerate', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Invoices.Regenerate(context.TODO(), metronome.V1InvoiceRegenerateParams{\n\t\tID: "6a37bb88-8538-48c5-b37b-a41c836328bd",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.invoices.regenerate', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.invoices.regenerate(id: "6a37bb88-8538-48c5-b37b-a41c836328bd")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/invoices/regenerate \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "6a37bb88-8538-48c5-b37b-a41c836328bd"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/contracts/get', httpMethod: 'post', summary: 'Get a contract (v1)', description: 'This is the v1 endpoint to get a contract. New clients should implement using the v2 endpoint.\n', stainlessPath: '(resource) v1.contracts > (method) retrieve', qualified: 'client.v1.contracts.retrieve', params: [ 'contract_id: string;', 'customer_id: string;', 'include_balance?: boolean;', 'include_ledgers?: boolean;', ], response: "{ data: { id: string; amendments: object[]; current: contract_without_amendments; customer_id: string; initial: contract_without_amendments; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: object; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: subscription[]; uniqueness_key?: string; }; }", markdown: "## retrieve\n\n`client.v1.contracts.retrieve(contract_id: string, customer_id: string, include_balance?: boolean, include_ledgers?: boolean): { data: contract; }`\n\n**post** `/v1/contracts/get`\n\nThis is the v1 endpoint to get a contract. New clients should implement using the v2 endpoint.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `include_balance?: boolean`\n Include the balance of credits and commits in the response. Setting this flag may cause the query to be slower.\n\n- `include_ledgers?: boolean`\n Include commit ledgers in the response. Setting this flag may cause the query to be slower.\n\n### Returns\n\n- `{ data: { id: string; amendments: object[]; current: contract_without_amendments; customer_id: string; initial: contract_without_amendments; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: object; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: subscription[]; uniqueness_key?: string; }; }`\n\n - `data: { id: string; amendments: { id: string; commits: object[]; created_at: string; created_by: string; overrides: object[]; scheduled_charges: object[]; starting_at: string; credits?: object[]; discounts?: object[]; netsuite_sales_order_id?: string; professional_services?: object[]; reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; fraction?: number; gcp_account_id?: string; gcp_offer_id?: string; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]; salesforce_opportunity_id?: string; }[]; current: { commits: commit[]; created_at: string; created_by: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_statement_schedule: object; credits?: credit[]; discounts?: discount[]; ending_before?: string; hierarchy_configuration?: hierarchy_configuration; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; total_contract_value?: number; usage_filter?: object; }; customer_id: string; initial: { commits: commit[]; created_at: string; created_by: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_statement_schedule: object; credits?: credit[]; discounts?: discount[]; ending_before?: string; hierarchy_configuration?: hierarchy_configuration; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; total_contract_value?: number; usage_filter?: object; }; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; package_id?: string; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; accumulated_spend?: { amount: number; period_ending_before: string; period_starting_at: string; }; }[]; subscriptions?: { billing_periods: object; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: object; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: object[]; starting_at: string; subscription_rate: object; id?: string; billing_cycle_config?: object; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: object; }[]; uniqueness_key?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst contract = await client.v1.contracts.retrieve({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(contract);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst contract = await client.v1.contracts.retrieve({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(contract.data);", }, python: { method: 'v1.contracts.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncontract = client.v1.contracts.retrieve(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(contract.data)', }, java: { method: 'v1().contracts().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveParams;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractRetrieveParams params = ContractRetrieveParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractRetrieveResponse contract = client.v1().contracts().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcontract, err := client.V1.Contracts.Get(context.TODO(), metronome.V1ContractGetParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", contract.Data)\n}\n', }, ruby: { method: 'v1.contracts.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncontract = metronome.v1.contracts.retrieve(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(contract)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/contracts/list', httpMethod: 'post', summary: 'List customer contracts (v1)', description: "Retrieves all contracts for a specific customer, including pricing, terms, credits, and commitments. Use this to view a customer's contract history and current agreements for billing management. Returns contract details with optional ledgers and balance information. \n\n⚠️ Note: This is the legacy v1 endpoint - new integrations should use the v2 endpoint for enhanced features.\n", stainlessPath: '(resource) v1.contracts > (method) list', qualified: 'client.v1.contracts.list', params: [ 'customer_id: string;', 'covering_date?: string;', 'include_archived?: boolean;', 'include_balance?: boolean;', 'include_ledgers?: boolean;', 'starting_at?: string;', ], response: "{ data: { id: string; amendments: object[]; current: contract_without_amendments; customer_id: string; initial: contract_without_amendments; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: object; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: subscription[]; uniqueness_key?: string; }[]; }", markdown: "## list\n\n`client.v1.contracts.list(customer_id: string, covering_date?: string, include_archived?: boolean, include_balance?: boolean, include_ledgers?: boolean, starting_at?: string): { data: contract[]; }`\n\n**post** `/v1/contracts/list`\n\nRetrieves all contracts for a specific customer, including pricing, terms, credits, and commitments. Use this to view a customer's contract history and current agreements for billing management. Returns contract details with optional ledgers and balance information. \n\n⚠️ Note: This is the legacy v1 endpoint - new integrations should use the v2 endpoint for enhanced features.\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `covering_date?: string`\n Optional RFC 3339 timestamp. If provided, the response will include only contracts effective on the provided date. This cannot be provided if the starting_at filter is provided.\n\n- `include_archived?: boolean`\n Include archived contracts in the response\n\n- `include_balance?: boolean`\n Include the balance of credits and commits in the response. Setting this flag may cause the query to be slower.\n\n- `include_ledgers?: boolean`\n Include commit ledgers in the response. Setting this flag may cause the query to be slower.\n\n- `starting_at?: string`\n Optional RFC 3339 timestamp. If provided, the response will include only contracts where effective_at is on or after the provided date. This cannot be provided if the covering_date filter is provided.\n\n### Returns\n\n- `{ data: { id: string; amendments: object[]; current: contract_without_amendments; customer_id: string; initial: contract_without_amendments; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: object; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: subscription[]; uniqueness_key?: string; }[]; }`\n\n - `data: { id: string; amendments: { id: string; commits: object[]; created_at: string; created_by: string; overrides: object[]; scheduled_charges: object[]; starting_at: string; credits?: object[]; discounts?: object[]; netsuite_sales_order_id?: string; professional_services?: object[]; reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; ending_before?: string; fraction?: number; gcp_account_id?: string; gcp_offer_id?: string; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]; salesforce_opportunity_id?: string; }[]; current: { commits: commit[]; created_at: string; created_by: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_statement_schedule: object; credits?: credit[]; discounts?: discount[]; ending_before?: string; hierarchy_configuration?: hierarchy_configuration; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; total_contract_value?: number; usage_filter?: object; }; customer_id: string; initial: { commits: commit[]; created_at: string; created_by: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_statement_schedule: object; credits?: credit[]; discounts?: discount[]; ending_before?: string; hierarchy_configuration?: hierarchy_configuration; name?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; professional_services?: pro_service[]; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; reseller_royalties?: object[]; salesforce_opportunity_id?: string; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; total_contract_value?: number; usage_filter?: object; }; archived_at?: string; custom_fields?: object; customer_billing_provider_configuration?: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; package_id?: string; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; accumulated_spend?: { amount: number; period_ending_before: string; period_starting_at: string; }; }[]; subscriptions?: { billing_periods: object; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: object; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: object[]; starting_at: string; subscription_rate: object; id?: string; billing_cycle_config?: object; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: object; }[]; uniqueness_key?: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst contracts = await client.v1.contracts.list({ customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1' });\n\nconsole.log(contracts);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst contracts = await client.v1.contracts.list({\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n});\n\nconsole.log(contracts.data);", }, python: { method: 'v1.contracts.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncontracts = client.v1.contracts.list(\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n)\nprint(contracts.data)', }, java: { method: 'v1().contracts().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractListParams;\nimport com.metronome.api.models.v1.contracts.ContractListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractListParams params = ContractListParams.builder()\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .build();\n ContractListResponse contracts = client.v1().contracts().list(params);\n }\n}', }, go: { method: 'client.V1.Contracts.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcontracts, err := client.V1.Contracts.List(context.TODO(), metronome.V1ContractListParams{\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", contracts.Data)\n}\n', }, ruby: { method: 'v1.contracts.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncontracts = metronome.v1.contracts.list(customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1")\n\nputs(contracts)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1"\n }\'', }, }, }, { name: 'create', endpoint: '/v1/contracts/create', httpMethod: 'post', summary: 'Create a contract', description: "Contracts define a customer's products, pricing, discounts, access duration, and billing configuration. Contracts serve as the central billing agreement for both PLG and Enterprise customers. You can automatically grant customers access to your products and services directly from your product or CRM.\n\n### Use this endpoint to:\n- PLG onboarding: Automatically provision new self-serve customers with contracts when they sign up.\n- Enterprise sales: Push negotiated contracts from Salesforce with custom pricing and commitments\n- Promotional pricing: Implement time-limited discounts and free trials through overrides\n\n### Key components:\n#### Contract Term and Billing Schedule\n- Set contract duration using `starting_at` and `ending_before` fields. PLG contracts typically use perpetual agreements (no end date), while Enterprise contracts have fixed end dates which can be edited over time in the case of co-term upsells.\n\n#### Rate Card\nIf you are offering usage based pricing, you can set a rate card for the contract to reference through `rate_card_id` or `rate_card_alias`. The rate card is a store of all of your usage based products and their centralized pricing. Any new products or price changes on the rate card can be set to automatically propagate to all associated contracts - this ensures consistent pricing and product launches flow to contracts without manual updates and migrations. The `usage_statement_schedule` determines the cadence on which Metronome will finalize a usage invoice for the customer. This defaults to monthly on the 1st, with options for custom dates, quarterly, or annual cadences. Note: Most usage based billing companies align usage statements to be evaluated aligned to the first of the month.\nRead more about [Rate Cards](https://docs.metronome.com/pricing-packaging/create-manage-rate-cards/).\n\n#### Overrides and discounts\nCustomize pricing on the contract through time-bounded overrides that can target specific products, product families, or complex usage scenarios. Overrides enable two key capabilities:\n- Discounts: Apply percentage discounts, fixed rate reductions, or quantity-based pricing tiers\n- Entitlements: Provide special pricing or access to specific products for negotiated deals\n\nRead more about [Contract Overrides](https://docs.metronome.com/manage-product-access/add-contract-override/).\n\n#### Commits and Credits\nUsing commits, configure prepaid or postpaid spending commitments where customers promise to spend a certain amount over the contract period paid in advance or in arrears. Use credits to provide free spending allowances. Under the hood these are the same mechanisms, however, credits are typically offered for free (SLA or promotional) or as a part of an allotment associated with a Subscription.\n\nIn Metronome, you can set commits and credits to only be applicable for a subset of usage. Use `applicable_product_ids` or `applicable_product_tags` to create product or product-family specific commits or credits, or you can build complex boolean logic specifiers to target usage based on pricing and presentation group values using `override_specifiers`.\n\nThese objects can also also be configured to have a recurrence schedule to easily model customer packaging which includes recurring monthly or quarterly allotments.\n\nCommits support rollover settings (`rollover_fraction`) to transfer unused balances between contract periods, either entirely or as a percentage.\n\nRead more about [Credits and Commits](https://docs.metronome.com/pricing-packaging/apply-credits-commits/).\n\n#### Subscriptions\nYou can add a fixed recurring charge to a contract, like monthly licenses or seat-based fees, using the subscription charge. Subscription charges are defined on your rate card and you can select which subscription is applicable to add to each contract. When you add a subscription to a contract you need to:\n- Define whether the subscription is paid for in-advance or in-arrears (`collection_schedule`)\n- Define the proration behavior (`proration`)\n- Specify an initial quantity (`initial_quantity`)\n- Define which subscription rate on the rate card should be used (`subscription_rate`)\n\nRead more about [Subscriptions](https://docs.metronome.com/manage-product-access/create-subscription/).\n\n#### Scheduled Charges\nSet up one-time, recurring, or entirely custom charges that occur on specific dates, separate from usage-based billing or commitments. These can be used to model non-recurring platform charges or professional services.\n\n#### Threshold Billing\nMetronome allows you to configure automatic billing triggers when customers reach spending thresholds to prevent fraud and manage risk. You can use `spend_threshold_configuration` to trigger an invoice to cover current charges whenever the threshold is reached or you can ensure the customer maintains a minimum prepaid balance using the `prepaid_balance_configuration`.\n\nRead more about [Spend Threshold](https://docs.metronome.com/manage-product-access/spend-thresholds/) and [Prepaid Balance Thresholds](https://docs.metronome.com/manage-product-access/prepaid-balance-thresholds/).\n\n### Usage guidelines:\n- You can always [Edit Contracts](https://docs.metronome.com/manage-product-access/edit-contract/) after it has been created, using the `editContract` endpoint. Metronome keeps track of all edits, both in the audit log and over the `getEditHistory` endpoint.\n- Customers in Metronome can have multiple concurrent contracts at one time. Use `usage_filters` to route the correct usage to each contract. [Read more about usage filters](https://docs.metronome.com/manage-product-access/provision-customer/#create-a-usage-filter).\n", stainlessPath: '(resource) v1.contracts > (method) create', qualified: 'client.v1.contracts.create', params: [ 'customer_id: string;', 'starting_at: string;', "billing_provider_configuration?: { billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; };", "commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[];", "credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[];", 'custom_fields?: object;', "discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", 'ending_before?: string;', "hierarchy_configuration?: { parent?: { contract_id: string; customer_id: string; }; parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; };", "multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT';", 'name?: string;', 'net_payment_terms_days?: number;', 'netsuite_sales_order_id?: string;', "overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[];", 'package_alias?: string;', 'package_id?: string;', "prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; };", 'professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[];', 'rate_card_alias?: string;', 'rate_card_id?: string;', "recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[];", "recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[];", "reseller_royalties?: { fraction: number; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; reseller_contract_value?: number; }[];", "revenue_system_configuration?: { delivery_method?: 'direct_to_billing_provider'; provider?: 'netsuite'; revenue_system_configuration_id?: string; };", 'salesforce_opportunity_id?: string;', "scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", "scheduled_charges_on_usage_invoices?: 'ALL';", "spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; };", "spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[];", "subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[];", 'total_contract_value?: number;', "transition?: { from_contract_id: string; type: 'RENEWAL'; future_invoice_behavior?: { trueup?: 'REMOVE' | 'AS_IS'; }; };", 'uniqueness_key?: string;', 'usage_filter?: { group_key: string; group_values: string[]; starting_at?: string; };', "usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; billing_anchor_date?: string; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START' | 'CUSTOM_DATE'; invoice_generation_starting_at?: string; };", ], response: "{ data: { id: string; contract?: { id: string; commits: commit[]; created_at: string; created_by: string; customer_id: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_filter: object[]; usage_statement_schedule: object; credits?: credit[]; custom_fields?: object; customer_billing_provider_configuration?: object; ending_before?: string; has_more?: object; hierarchy_configuration?: hierarchy_configuration; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; subscriptions?: subscription[]; uniqueness_key?: string; }; }; }", markdown: "## create\n\n`client.v1.contracts.create(customer_id: string, starting_at: string, billing_provider_configuration?: { billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }, commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: object[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[], credits?: { access_schedule: { schedule_items: object[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; }[], custom_fields?: object, discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], ending_before?: string, hierarchy_configuration?: { parent?: { contract_id: string; customer_id: string; }; parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; }, multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT', name?: string, net_payment_terms_days?: number, netsuite_sales_order_id?: string, overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[], package_alias?: string, package_id?: string, prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }, professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[], rate_card_alias?: string, rate_card_id?: string, recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[], recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[], reseller_royalties?: { fraction: number; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; reseller_contract_value?: number; }[], revenue_system_configuration?: { delivery_method?: 'direct_to_billing_provider'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }, salesforce_opportunity_id?: string, scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], scheduled_charges_on_usage_invoices?: 'ALL', spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }, spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[], subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: object; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[], total_contract_value?: number, transition?: { from_contract_id: string; type: 'RENEWAL'; future_invoice_behavior?: { trueup?: 'REMOVE' | 'AS_IS'; }; }, uniqueness_key?: string, usage_filter?: { group_key: string; group_values: string[]; starting_at?: string; }, usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; billing_anchor_date?: string; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START' | 'CUSTOM_DATE'; invoice_generation_starting_at?: string; }): { data: object; }`\n\n**post** `/v1/contracts/create`\n\nContracts define a customer's products, pricing, discounts, access duration, and billing configuration. Contracts serve as the central billing agreement for both PLG and Enterprise customers. You can automatically grant customers access to your products and services directly from your product or CRM.\n\n### Use this endpoint to:\n- PLG onboarding: Automatically provision new self-serve customers with contracts when they sign up.\n- Enterprise sales: Push negotiated contracts from Salesforce with custom pricing and commitments\n- Promotional pricing: Implement time-limited discounts and free trials through overrides\n\n### Key components:\n#### Contract Term and Billing Schedule\n- Set contract duration using `starting_at` and `ending_before` fields. PLG contracts typically use perpetual agreements (no end date), while Enterprise contracts have fixed end dates which can be edited over time in the case of co-term upsells.\n\n#### Rate Card\nIf you are offering usage based pricing, you can set a rate card for the contract to reference through `rate_card_id` or `rate_card_alias`. The rate card is a store of all of your usage based products and their centralized pricing. Any new products or price changes on the rate card can be set to automatically propagate to all associated contracts - this ensures consistent pricing and product launches flow to contracts without manual updates and migrations. The `usage_statement_schedule` determines the cadence on which Metronome will finalize a usage invoice for the customer. This defaults to monthly on the 1st, with options for custom dates, quarterly, or annual cadences. Note: Most usage based billing companies align usage statements to be evaluated aligned to the first of the month.\nRead more about [Rate Cards](https://docs.metronome.com/pricing-packaging/create-manage-rate-cards/).\n\n#### Overrides and discounts\nCustomize pricing on the contract through time-bounded overrides that can target specific products, product families, or complex usage scenarios. Overrides enable two key capabilities:\n- Discounts: Apply percentage discounts, fixed rate reductions, or quantity-based pricing tiers\n- Entitlements: Provide special pricing or access to specific products for negotiated deals\n\nRead more about [Contract Overrides](https://docs.metronome.com/manage-product-access/add-contract-override/).\n\n#### Commits and Credits\nUsing commits, configure prepaid or postpaid spending commitments where customers promise to spend a certain amount over the contract period paid in advance or in arrears. Use credits to provide free spending allowances. Under the hood these are the same mechanisms, however, credits are typically offered for free (SLA or promotional) or as a part of an allotment associated with a Subscription.\n\nIn Metronome, you can set commits and credits to only be applicable for a subset of usage. Use `applicable_product_ids` or `applicable_product_tags` to create product or product-family specific commits or credits, or you can build complex boolean logic specifiers to target usage based on pricing and presentation group values using `override_specifiers`.\n\nThese objects can also also be configured to have a recurrence schedule to easily model customer packaging which includes recurring monthly or quarterly allotments.\n\nCommits support rollover settings (`rollover_fraction`) to transfer unused balances between contract periods, either entirely or as a percentage.\n\nRead more about [Credits and Commits](https://docs.metronome.com/pricing-packaging/apply-credits-commits/).\n\n#### Subscriptions\nYou can add a fixed recurring charge to a contract, like monthly licenses or seat-based fees, using the subscription charge. Subscription charges are defined on your rate card and you can select which subscription is applicable to add to each contract. When you add a subscription to a contract you need to:\n- Define whether the subscription is paid for in-advance or in-arrears (`collection_schedule`)\n- Define the proration behavior (`proration`)\n- Specify an initial quantity (`initial_quantity`)\n- Define which subscription rate on the rate card should be used (`subscription_rate`)\n\nRead more about [Subscriptions](https://docs.metronome.com/manage-product-access/create-subscription/).\n\n#### Scheduled Charges\nSet up one-time, recurring, or entirely custom charges that occur on specific dates, separate from usage-based billing or commitments. These can be used to model non-recurring platform charges or professional services.\n\n#### Threshold Billing\nMetronome allows you to configure automatic billing triggers when customers reach spending thresholds to prevent fraud and manage risk. You can use `spend_threshold_configuration` to trigger an invoice to cover current charges whenever the threshold is reached or you can ensure the customer maintains a minimum prepaid balance using the `prepaid_balance_configuration`.\n\nRead more about [Spend Threshold](https://docs.metronome.com/manage-product-access/spend-thresholds/) and [Prepaid Balance Thresholds](https://docs.metronome.com/manage-product-access/prepaid-balance-thresholds/).\n\n### Usage guidelines:\n- You can always [Edit Contracts](https://docs.metronome.com/manage-product-access/edit-contract/) after it has been created, using the `editContract` endpoint. Metronome keeps track of all edits, both in the audit log and over the `getEditHistory` endpoint.\n- Customers in Metronome can have multiple concurrent contracts at one time. Use `usage_filters` to route the correct usage to each contract. [Read more about usage filters](https://docs.metronome.com/manage-product-access/provision-customer/#create-a-usage-filter).\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `starting_at: string`\n inclusive contract start time\n\n- `billing_provider_configuration?: { billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'; billing_provider_configuration_id?: string; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; }`\n The billing provider configuration associated with a contract. Provide either an ID or the provider and delivery method.\n - `billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'`\n Do not specify if using billing_provider_configuration_id.\n - `billing_provider_configuration_id?: string`\n The Metronome ID of the billing provider configuration. Use when a customer has multiple configurations with the same billing provider and delivery method. Otherwise, specify the billing_provider and delivery_method.\n - `delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'`\n Do not specify if using billing_provider_configuration_id.\n\n- `commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[]`\n\n- `credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `ending_before?: string`\n exclusive contract end time\n\n- `hierarchy_configuration?: { parent?: { contract_id: string; customer_id: string; }; parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; }`\n - `parent?: { contract_id: string; customer_id: string; }`\n - `parent_behavior?: { invoice_consolidation_type?: 'CONCATENATE' | 'NONE'; }`\n - `payer?: 'SELF' | 'PARENT'`\n Indicates which customer should pay for the child's invoice charges\n\n**SELF**: The child pays for its own invoice charges\n\n**PARENT**: The parent pays for the child's invoice charges\n - `usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'`\n Indicates the behavior of the child's invoice statements on the parent's invoices.\n\n**CONSOLIDATE**: Child's invoice statements will be added to parent's consolidated invoices\n\n**SEPARATE**: Child's invoice statements will appear not appear on parent's consolidated invoices\n\n- `multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'`\n Defaults to LOWEST_MULTIPLIER, which applies the greatest discount to list prices automatically. EXPLICIT prioritization requires specifying priorities for each multiplier; the one with the lowest priority value will be prioritized first. If tiered overrides are used, prioritization must be explicit.\n\n- `name?: string`\n\n- `net_payment_terms_days?: number`\n\n- `netsuite_sales_order_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]`\n\n- `package_alias?: string`\n Selects the package linked to the specified alias as of the contract's start date. Mutually exclusive with package_id.\n\n- `package_id?: string`\n If provided, provisions a customer on a package instead of creating a traditional contract. When specified, only customer_id, starting_at, package_id, uniqueness_key, transition, and custom_fields are allowed.\n\n- `prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `recharge_to_amount: number`\n Specify the amount the balance should be recharged to.\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's prepaid balance lowers to this amount, a threshold charge will be initiated.\n - `custom_credit_type_id?: string`\n If provided, the threshold, recharge-to amount, and the resulting threshold commit amount will be in terms of this credit type instead of the fiat currency.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n - `threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Determines which balances are excluded from remaining balance calculation for threshold billing.\n\n- `professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `rate_card_alias?: string`\n Selects the rate card linked to the specified alias as of the contract's start date.\n\n- `rate_card_id?: string`\n\n- `recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[]`\n\n- `recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; ending_before?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[]`\n\n- `reseller_royalties?: { fraction: number; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; reseller_contract_value?: number; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `revenue_system_configuration?: { delivery_method?: 'direct_to_billing_provider'; provider?: 'netsuite'; revenue_system_configuration_id?: string; }`\n The revenue system configuration associated with a contract. Provide either an ID or the provider and delivery method.\n - `delivery_method?: 'direct_to_billing_provider'`\n How revenue recognition records should be delivered to the revenue system. Do not specify if using revenue_system_configuration_id.\n - `provider?: 'netsuite'`\n The system that is providing services for revenue recognition. Do not specify if using revenue_system_configuration_id.\n - `revenue_system_configuration_id?: string`\n The Metronome ID of the revenue system configuration. Use when a customer has multiple configurations with the same provider and delivery method. Otherwise, specify the provider and delivery_method.\n\n- `salesforce_opportunity_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n\n- `scheduled_charges_on_usage_invoices?: 'ALL'`\n Determines which scheduled and commit charges to consolidate onto the Contract's usage invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for consolidation to occur. This field cannot be modified after a Contract has been created. If this field is omitted, charges will appear on a separate invoice from usage charges.\n\n- `spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's usage hits this amount, a threshold charge will be initiated.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n\n- `spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]`\n Spend trackers to attach to this contract. Aliases must be unique within a contract.\n\n- `subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { anchor_date?: string; invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; ending_before?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { initial_seat_ids: string[]; seat_group_key: string; initial_unassigned_seats?: number; }; starting_at?: string; temporary_id?: string; }[]`\n Optional list of [subscriptions](https://docs.metronome.com/manage-product-access/create-subscription/) to add to the contract.\n\n- `total_contract_value?: number`\n This field's availability is dependent on your client's configuration.\n\n- `transition?: { from_contract_id: string; type: 'RENEWAL'; future_invoice_behavior?: { trueup?: 'REMOVE' | 'AS_IS'; }; }`\n - `from_contract_id: string`\n - `type: 'RENEWAL'`\n This field's available values may vary based on your client's configuration.\n - `future_invoice_behavior?: { trueup?: 'REMOVE' | 'AS_IS'; }`\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.\n\n- `usage_filter?: { group_key: string; group_values: string[]; starting_at?: string; }`\n - `group_key: string`\n - `group_values: string[]`\n - `starting_at?: string`\n\n- `usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; billing_anchor_date?: string; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START' | 'CUSTOM_DATE'; invoice_generation_starting_at?: string; }`\n - `frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'`\n - `billing_anchor_date?: string`\n Required when using CUSTOM_DATE. This option lets you set a historical billing anchor date, aligning future billing cycles with a chosen cadence. For example, if a contract starts on 2024-09-15 and you set the anchor date to 2024-09-10 with a MONTHLY frequency, the first usage statement will cover 09-15 to 10-10. Subsequent statements will follow the 10th of each month.\n - `day?: 'FIRST_OF_MONTH' | 'CONTRACT_START' | 'CUSTOM_DATE'`\n If not provided, defaults to the first day of the month.\n - `invoice_generation_starting_at?: string`\n The date Metronome should start generating usage invoices. If unspecified, contract start date will be used. This is useful to set if you want to import historical invoices via our 'Create Historical Invoices' API rather than having Metronome automatically generate them.\n\n### Returns\n\n- `{ data: { id: string; contract?: { id: string; commits: commit[]; created_at: string; created_by: string; customer_id: string; overrides: override[]; scheduled_charges: scheduled_charge[]; starting_at: string; transitions: object[]; usage_filter: object[]; usage_statement_schedule: object; credits?: credit[]; custom_fields?: object; customer_billing_provider_configuration?: object; ending_before?: string; has_more?: object; hierarchy_configuration?: hierarchy_configuration; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; package_id?: string; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; subscriptions?: subscription[]; uniqueness_key?: string; }; }; }`\n\n - `data: { id: string; contract?: { id: string; commits: { id: string; created_at: string; product: object; type: 'PREPAID' | 'POSTPAID'; access_schedule?: schedule_duration; amount?: number; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: object; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; invoice_contract?: object; invoice_schedule?: schedule_point_in_time; ledger?: object | object | object | object | object | object | object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: object; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; spend_tracker_attributes?: object; subscription_config?: object; uniqueness_key?: string; }[]; created_at: string; created_by: string; customer_id: string; overrides: { id: string; created_at: string; starting_at: string; applicable_product_tags?: string[]; credit_type?: credit_type_data; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; is_prorated?: boolean; multiplier?: number; override_specifiers?: object[]; override_tiers?: override_tier[]; overwrite_rate?: overwrite_rate; price?: number; priority?: number; product?: object; quantity?: number; rate_type?: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: tier[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; value?: object; }[]; scheduled_charges: { id: string; product: object; schedule: schedule_point_in_time; archived_at?: string; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]; starting_at: string; transitions: { from_contract_id: string; to_contract_id: string; type: 'RENEWAL'; }[]; usage_filter: { group_key: string; group_values: string[]; starting_at: string; ending_before?: string; }[]; usage_statement_schedule: { billing_anchor_date: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; }; credits?: { id: string; product: object; type: 'CREDIT'; access_schedule?: schedule_duration; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; balance?: number; contract?: object; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: commit_hierarchy_configuration; ledger?: object | object | object | object | object | object | object | object[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_credit_id?: string; rolled_over_from?: object; salesforce_opportunity_id?: string; specifiers?: commit_specifier[]; subscription_config?: object; uniqueness_key?: string; }[]; custom_fields?: object; customer_billing_provider_configuration?: { id: string; archived_at: string; billing_provider: string; configuration: object; customer_id: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }; ending_before?: string; has_more?: { commits: boolean; credits: boolean; }; hierarchy_configuration?: { children: object[]; parent_behavior?: object; } | { parent: object; payer?: 'SELF' | 'PARENT'; usage_statement_behavior?: 'CONSOLIDATE' | 'SEPARATE'; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; package_id?: string; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; rate_card_id?: string; recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; contract?: { id: string; }; description?: string; ending_before?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: object; }[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }; subscriptions?: { billing_periods: object; collection_schedule: 'ADVANCE' | 'ARREARS'; proration: object; quantity_management_mode: 'SEAT_BASED' | 'QUANTITY_ONLY'; quantity_schedule: object[]; starting_at: string; subscription_rate: object; id?: string; billing_cycle_config?: object; custom_fields?: object; description?: string; ending_before?: string; fiat_credit_type_id?: string; name?: string; seat_config?: object; }[]; uniqueness_key?: string; }; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst contract = await client.v1.contracts.create({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', starting_at: '2020-01-01T00:00:00.000Z' });\n\nconsole.log(contract);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst contract = await client.v1.contracts.create({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n billing_provider_configuration: {\n billing_provider: 'stripe',\n delivery_method: 'direct_to_billing_provider',\n },\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(contract.data);", }, python: { method: 'v1.contracts.create', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\ncontract = client.v1.contracts.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n billing_provider_configuration={\n "billing_provider": "stripe",\n "delivery_method": "direct_to_billing_provider",\n },\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(contract.data)', }, java: { method: 'v1().contracts().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractCreateParams;\nimport com.metronome.api.models.v1.contracts.ContractCreateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractCreateParams params = ContractCreateParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\n ContractCreateResponse contract = client.v1().contracts().create(params);\n }\n}', }, go: { method: 'client.V1.Contracts.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tcontract, err := client.V1.Contracts.New(context.TODO(), metronome.V1ContractNewParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tStartingAt: time.Now(),\n\t\tBillingProviderConfiguration: metronome.V1ContractNewParamsBillingProviderConfiguration{\n\t\t\tBillingProvider: "stripe",\n\t\t\tDeliveryMethod: "direct_to_billing_provider",\n\t\t},\n\t\tRateCardID: metronome.String("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", contract.Data)\n}\n', }, ruby: { method: 'v1.contracts.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\ncontract = metronome.v1.contracts.create(\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z"\n)\n\nputs(contract)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "starting_at": "2020-01-01T00:00:00.000Z",\n "billing_provider_configuration": {\n "billing_provider": "stripe",\n "delivery_method": "direct_to_billing_provider"\n },\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'amend', endpoint: '/v1/contracts/amend', httpMethod: 'post', summary: 'Amend a contract', description: 'Amendments will be replaced by Contract editing. New clients should implement using the `editContract` endpoint. Read more about the migration to contract editing [here](/guides/implement-metronome/migrate-amendments-to-edits/) and reach out to your Metronome representative for more details. Once contract editing is enabled, access to this endpoint will be removed.\n', stainlessPath: '(resource) v1.contracts > (method) amend', qualified: 'client.v1.contracts.amend', params: [ 'contract_id: string;', 'customer_id: string;', 'starting_at: string;', "commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[];", "credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[];", 'custom_fields?: object;', "discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", 'netsuite_sales_order_id?: string;', "overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[];", 'professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[];', "reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[];", 'salesforce_opportunity_id?: string;', "scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[];", 'total_contract_value?: number;', ], response: '{ data: { id: string; }; }', markdown: "## amend\n\n`client.v1.contracts.amend(contract_id: string, customer_id: string, starting_at: string, commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: object[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[], credits?: { access_schedule: { schedule_items: object[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: object; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; }[], custom_fields?: object, discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], netsuite_sales_order_id?: string, overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[], professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[], reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[], salesforce_opportunity_id?: string, scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: object; schedule_items?: object[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[], total_contract_value?: number): { data: id; }`\n\n**post** `/v1/contracts/amend`\n\nAmendments will be replaced by Contract editing. New clients should implement using the `editContract` endpoint. Read more about the migration to contract editing [here](/guides/implement-metronome/migrate-amendments-to-edits/) and reach out to your Metronome representative for more details. Once contract editing is enabled, access to this endpoint will be removed.\n\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract to amend\n\n- `customer_id: string`\n ID of the customer whose contract is to be amended\n\n- `starting_at: string`\n inclusive start time for the amendment\n\n- `commits?: { product_id: string; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; amount?: number; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; invoice_schedule?: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; temporary_id?: string; }[]`\n\n- `credits?: { access_schedule: { schedule_items: { amount: number; ending_before: string; starting_at: string; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; hierarchy_configuration?: { child_access: { type: 'ALL'; } | { type: 'NONE'; } | { contract_ids: string[]; type: 'CONTRACT_IDS'; }; }; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `discounts?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `netsuite_sales_order_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `overrides?: { starting_at: string; applicable_product_tags?: string[]; ending_before?: string; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_specifiers?: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; product_id?: string; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]`\n\n- `professional_services?: { max_amount: number; product_id: string; quantity: number; unit_price: number; custom_fields?: object; description?: string; netsuite_sales_order_id?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `reseller_royalties?: { reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; ending_before?: string; fraction?: number; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; netsuite_reseller_id?: string; reseller_contract_value?: number; starting_at?: string; }[]`\n This field's availability is dependent on your client's configuration.\n\n- `salesforce_opportunity_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `scheduled_charges?: { product_id: string; schedule: { credit_type_id?: string; do_not_invoice?: boolean; recurring_schedule?: { amount_distribution: 'DIVIDED' | 'DIVIDED_ROUNDED' | 'EACH'; ending_before: string; frequency: 'MONTHLY' | 'QUARTERLY' | 'SEMI_ANNUAL' | 'ANNUAL'; starting_at: string; amount?: number; quantity?: number; unit_price?: number; }; schedule_items?: { timestamp: string; amount?: number; quantity?: number; unit_price?: number; }[]; }; custom_fields?: object; name?: string; netsuite_sales_order_id?: string; }[]`\n\n- `total_contract_value?: number`\n This field's availability is dependent on your client's configuration.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.amend({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.amend', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.amend({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.amend', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.amend(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\nprint(response.data)', }, java: { method: 'v1().contracts().amend', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractAmendParams;\nimport com.metronome.api.models.v1.contracts.ContractAmendResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractAmendParams params = ContractAmendParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\n ContractAmendResponse response = client.v1().contracts().amend(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Amend', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.Amend(context.TODO(), metronome.V1ContractAmendParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tStartingAt: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.amend', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.amend(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/amend \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "starting_at": "2020-01-01T00:00:00.000Z"\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/contracts/archive', httpMethod: 'post', summary: 'Archive a contract', description: 'Permanently end and archive a contract along with all its terms. Any draft invoices will be canceled, and all upcoming scheduled invoices will be voided–also all finalized invoices can optionally be voided. Use this in the event a contract was incorrectly created and needed to be removed from a customer.\n\n#### Impact on commits and credits:\nWhen archiving a contract, all associated commits and credits are also archived. For prepaid commits with active segments, Metronome automatically generates expiration ledger entries to close out any remaining balances, ensuring accurate accounting of unused prepaid amounts. These ledger entries will appear in the commit\'s transaction history with type `PREPAID_COMMIT_EXPIRATION`.\n\n#### Archived contract visibility: \nArchived contracts remain accessible for historical reporting and audit purposes. They can be retrieved using the `ListContracts` endpoint by setting the `include_archived` parameter to `true` or in the Metronome UI when the "Show archived" option is enabled.\n', stainlessPath: '(resource) v1.contracts > (method) archive', qualified: 'client.v1.contracts.archive', params: ['contract_id: string;', 'customer_id: string;', 'void_invoices: boolean;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.contracts.archive(contract_id: string, customer_id: string, void_invoices: boolean): { data: id; }`\n\n**post** `/v1/contracts/archive`\n\nPermanently end and archive a contract along with all its terms. Any draft invoices will be canceled, and all upcoming scheduled invoices will be voided–also all finalized invoices can optionally be voided. Use this in the event a contract was incorrectly created and needed to be removed from a customer.\n\n#### Impact on commits and credits:\nWhen archiving a contract, all associated commits and credits are also archived. For prepaid commits with active segments, Metronome automatically generates expiration ledger entries to close out any remaining balances, ensuring accurate accounting of unused prepaid amounts. These ledger entries will appear in the commit's transaction history with type `PREPAID_COMMIT_EXPIRATION`.\n\n#### Archived contract visibility: \nArchived contracts remain accessible for historical reporting and audit purposes. They can be retrieved using the `ListContracts` endpoint by setting the `include_archived` parameter to `true` or in the Metronome UI when the \"Show archived\" option is enabled.\n\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract to archive\n\n- `customer_id: string`\n ID of the customer whose contract is to be archived\n\n- `void_invoices: boolean`\n If false, the existing finalized invoices will remain after the contract is archived.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.archive({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n void_invoices: true,\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.archive({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n void_invoices: true,\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.archive(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n void_invoices=True,\n)\nprint(response.data)', }, java: { method: 'v1().contracts().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractArchiveParams;\nimport com.metronome.api.models.v1.contracts.ContractArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractArchiveParams params = ContractArchiveParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .voidInvoices(true)\n .build();\n ContractArchiveResponse response = client.v1().contracts().archive(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.Archive(context.TODO(), metronome.V1ContractArchiveParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tVoidInvoices: true,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.archive(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n void_invoices: true\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "void_invoices": true\n }\'', }, }, }, { name: 'set_usage_filter', endpoint: '/v1/contracts/setUsageFilter', httpMethod: 'post', summary: 'Set a contract usage filter', description: 'If a customer has multiple contracts with overlapping rates, the usage filter routes usage to the appropriate contract based on a predefined group key. \n\nAs an example, imagine you have a customer associated with two projects. Each project is associated with its own contract. You can create a usage filter with group key `project_id`\non each contract, and route usage for `project_1` to the first contract and `project_2` to the second contract. \n\n### Use this endpoint to:\n- Support enterprise contracting scenarios where multiple contracts are associated to the same customer with the same rates.\n- Update the usage filter associated with the contract over time. \n\n### Usage guidelines:\nTo use usage filters, the `group_key` must be defined on the billable metrics underlying the rate card on the contracts.\n', stainlessPath: '(resource) v1.contracts > (method) set_usage_filter', qualified: 'client.v1.contracts.setUsageFilter', params: [ 'contract_id: string;', 'customer_id: string;', 'group_key: string;', 'group_values: string[];', 'starting_at: string;', ], markdown: "## set_usage_filter\n\n`client.v1.contracts.setUsageFilter(contract_id: string, customer_id: string, group_key: string, group_values: string[], starting_at: string): void`\n\n**post** `/v1/contracts/setUsageFilter`\n\nIf a customer has multiple contracts with overlapping rates, the usage filter routes usage to the appropriate contract based on a predefined group key. \n\nAs an example, imagine you have a customer associated with two projects. Each project is associated with its own contract. You can create a usage filter with group key `project_id`\non each contract, and route usage for `project_1` to the first contract and `project_2` to the second contract. \n\n### Use this endpoint to:\n- Support enterprise contracting scenarios where multiple contracts are associated to the same customer with the same rates.\n- Update the usage filter associated with the contract over time. \n\n### Usage guidelines:\nTo use usage filters, the `group_key` must be defined on the billable metrics underlying the rate card on the contracts.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `group_key: string`\n\n- `group_values: string[]`\n\n- `starting_at: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.contracts.setUsageFilter({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n group_key: 'business_subscription_id',\n group_values: ['ID-1', 'ID-2'],\n starting_at: '2020-01-01T00:00:00.000Z',\n})\n```", perLanguage: { typescript: { method: 'client.v1.contracts.setUsageFilter', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.contracts.setUsageFilter({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n group_key: 'business_subscription_id',\n group_values: ['ID-1', 'ID-2'],\n starting_at: '2020-01-01T00:00:00.000Z',\n});", }, python: { method: 'v1.contracts.set_usage_filter', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.contracts.set_usage_filter(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n group_key="business_subscription_id",\n group_values=["ID-1", "ID-2"],\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)', }, java: { method: 'v1().contracts().setUsageFilter', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractSetUsageFilterParams;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractSetUsageFilterParams params = ContractSetUsageFilterParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .groupKey("business_subscription_id")\n .addGroupValue("ID-1")\n .addGroupValue("ID-2")\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\n client.v1().contracts().setUsageFilter(params);\n }\n}', }, go: { method: 'client.V1.Contracts.SetUsageFilter', example: 'package main\n\nimport (\n\t"context"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Contracts.SetUsageFilter(context.TODO(), metronome.V1ContractSetUsageFilterParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tGroupKey: "business_subscription_id",\n\t\tGroupValues: []string{"ID-1", "ID-2"},\n\t\tStartingAt: time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.contracts.set_usage_filter', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.contracts.set_usage_filter(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n group_key: "business_subscription_id",\n group_values: ["ID-1", "ID-2"],\n starting_at: "2020-01-01T00:00:00.000Z"\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/setUsageFilter \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "group_key": "business_subscription_id",\n "group_values": [\n "ID-1",\n "ID-2"\n ],\n "starting_at": "2020-01-01T00:00:00.000Z"\n }\'', }, }, }, { name: 'add_manual_balance_entry', endpoint: '/v1/contracts/addManualBalanceLedgerEntry', httpMethod: 'post', summary: 'Add a manual balance entry', description: 'Manually adjust the available balance on a commit or credit. This entry is appended to the commit ledger as a new event. Optionally include a description that provides the reasoning for the entry.\n\n### Use this endpoint to:\n- Address incorrect usage burn-down caused by malformed usage or invalid config\n- Decrease available balance to account for outages where usage may have not been tracked or sent to Metronome\n- Issue credits to customers in the form of increased balance on existing commit or credit\n\n### Usage guidelines:\nManual ledger entries can be extremely useful for resolving discrepancies in Metronome. However, most corrections to inaccurate billings can be modified upstream of the commit, whether that is via contract editing, rate editing, or other actions that cause an invoice to be recalculated.\n', stainlessPath: '(resource) v1.contracts > (method) add_manual_balance_entry', qualified: 'client.v1.contracts.addManualBalanceEntry', params: [ 'id: string;', 'amount: number;', 'customer_id: string;', 'reason: string;', 'segment_id: string;', 'contract_id?: string;', 'per_group_amounts?: object;', 'timestamp?: string;', ], markdown: "## add_manual_balance_entry\n\n`client.v1.contracts.addManualBalanceEntry(id: string, amount: number, customer_id: string, reason: string, segment_id: string, contract_id?: string, per_group_amounts?: object, timestamp?: string): void`\n\n**post** `/v1/contracts/addManualBalanceLedgerEntry`\n\nManually adjust the available balance on a commit or credit. This entry is appended to the commit ledger as a new event. Optionally include a description that provides the reasoning for the entry.\n\n### Use this endpoint to:\n- Address incorrect usage burn-down caused by malformed usage or invalid config\n- Decrease available balance to account for outages where usage may have not been tracked or sent to Metronome\n- Issue credits to customers in the form of increased balance on existing commit or credit\n\n### Usage guidelines:\nManual ledger entries can be extremely useful for resolving discrepancies in Metronome. However, most corrections to inaccurate billings can be modified upstream of the commit, whether that is via contract editing, rate editing, or other actions that cause an invoice to be recalculated.\n\n\n### Parameters\n\n- `id: string`\n ID of the balance (commit or credit) to update.\n\n- `amount: number`\n Amount to add to the segment. A negative number will draw down from the balance.\n\n- `customer_id: string`\n ID of the customer whose balance is to be updated.\n\n- `reason: string`\n Reason for the manual adjustment. This will be displayed in the ledger.\n\n- `segment_id: string`\n ID of the segment to update.\n\n- `contract_id?: string`\n ID of the contract to update. Leave blank to update a customer level balance.\n\n- `per_group_amounts?: object`\n If using individually configured commits/credits attached to seat managed subscriptions, the amount to add for each seat. Must sum to total amount.\n\n- `timestamp?: string`\n RFC 3339 timestamp indicating when the manual adjustment takes place. If not provided, it will default to the start of the segment.\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.contracts.addManualBalanceEntry({\n id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n amount: -1000,\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n reason: 'Reason for entry',\n segment_id: '66368e29-3f97-4d15-a6e9-120897f0070a',\n})\n```", perLanguage: { typescript: { method: 'client.v1.contracts.addManualBalanceEntry', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.contracts.addManualBalanceEntry({\n id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n amount: -1000,\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n reason: 'Reason for entry',\n segment_id: '66368e29-3f97-4d15-a6e9-120897f0070a',\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});", }, python: { method: 'v1.contracts.add_manual_balance_entry', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.contracts.add_manual_balance_entry(\n id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n amount=-1000,\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n reason="Reason for entry",\n segment_id="66368e29-3f97-4d15-a6e9-120897f0070a",\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)', }, java: { method: 'v1().contracts().addManualBalanceEntry', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractAddManualBalanceEntryParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractAddManualBalanceEntryParams params = ContractAddManualBalanceEntryParams.builder()\n .id("6162d87b-e5db-4a33-b7f2-76ce6ead4e85")\n .amount(-1000.0)\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .reason("Reason for entry")\n .segmentId("66368e29-3f97-4d15-a6e9-120897f0070a")\n .build();\n client.v1().contracts().addManualBalanceEntry(params);\n }\n}', }, go: { method: 'client.V1.Contracts.AddManualBalanceEntry', example: 'package main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Contracts.AddManualBalanceEntry(context.TODO(), metronome.V1ContractAddManualBalanceEntryParams{\n\t\tID: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n\t\tAmount: -1000,\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tReason: "Reason for entry",\n\t\tSegmentID: "66368e29-3f97-4d15-a6e9-120897f0070a",\n\t\tContractID: metronome.String("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.contracts.add_manual_balance_entry', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.contracts.add_manual_balance_entry(\n id: "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n amount: -1000,\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n reason: "Reason for entry",\n segment_id: "66368e29-3f97-4d15-a6e9-120897f0070a"\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/addManualBalanceLedgerEntry \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "amount": -1000,\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "reason": "Reason for entry",\n "segment_id": "66368e29-3f97-4d15-a6e9-120897f0070a",\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'update_end_date', endpoint: '/v1/contracts/updateEndDate', httpMethod: 'post', summary: 'Update the contract end date', description: "Update or add an end date to a contract. Ending a contract early will impact draft usage statements, truncate any terms, and remove upcoming scheduled invoices. Moving the date into the future will only extend the contract length. Terms and scheduled invoices are not extended. In-advance subscriptions will not be extended. Use this if a contract's end date has changed or if a perpetual contract ends.\n", stainlessPath: '(resource) v1.contracts > (method) update_end_date', qualified: 'client.v1.contracts.updateEndDate', params: [ 'contract_id: string;', 'customer_id: string;', 'allow_ending_before_finalized_invoice?: boolean;', 'ending_before?: string;', ], response: '{ data: { id: string; }; }', markdown: "## update_end_date\n\n`client.v1.contracts.updateEndDate(contract_id: string, customer_id: string, allow_ending_before_finalized_invoice?: boolean, ending_before?: string): { data: id; }`\n\n**post** `/v1/contracts/updateEndDate`\n\nUpdate or add an end date to a contract. Ending a contract early will impact draft usage statements, truncate any terms, and remove upcoming scheduled invoices. Moving the date into the future will only extend the contract length. Terms and scheduled invoices are not extended. In-advance subscriptions will not be extended. Use this if a contract's end date has changed or if a perpetual contract ends.\n\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract to update\n\n- `customer_id: string`\n ID of the customer whose contract is to be updated\n\n- `allow_ending_before_finalized_invoice?: boolean`\n If true, allows setting the contract end date earlier than the end_timestamp of existing finalized invoices. Finalized invoices will be unchanged; if you want to incorporate the new end date, you can void and regenerate finalized usage invoices. Defaults to true.\n\n- `ending_before?: string`\n RFC 3339 timestamp indicating when the contract will end (exclusive). If not provided, the contract will be updated to be open-ended.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.updateEndDate({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.updateEndDate', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.updateEndDate({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n ending_before: '2020-01-01T00:00:00.000Z',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.update_end_date', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.update_end_date(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n ending_before=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\nprint(response.data)', }, java: { method: 'v1().contracts().updateEndDate', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractUpdateEndDateParams;\nimport com.metronome.api.models.v1.contracts.ContractUpdateEndDateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractUpdateEndDateParams params = ContractUpdateEndDateParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractUpdateEndDateResponse response = client.v1().contracts().updateEndDate(params);\n }\n}', }, go: { method: 'client.V1.Contracts.UpdateEndDate', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.UpdateEndDate(context.TODO(), metronome.V1ContractUpdateEndDateParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.update_end_date', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.update_end_date(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/updateEndDate \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "ending_before": "2020-01-01T00:00:00.000Z"\n }\'', }, }, }, { name: 'retrieve_rate_schedule', endpoint: '/v1/contracts/getContractRateSchedule', httpMethod: 'post', summary: 'Get the rate schedule for a contract', description: "For a specific customer and contract, get the rates at a specific point in time. This endpoint takes the contract's rate card into consideration, including scheduled changes. It also takes into account overrides on the contract. \n\nFor example, if you want to show your customer a summary of the prices they are paying, inclusive of any negotiated discounts or promotions, use this endpoint. This endpoint only returns rates that are entitled.\n", stainlessPath: '(resource) v1.contracts > (method) retrieve_rate_schedule', qualified: 'client.v1.contracts.retrieveRateSchedule', params: [ 'contract_id: string;', 'customer_id: string;', 'limit?: number;', 'next_page?: string;', 'at?: string;', "selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];", ], response: "{ data: { entitled: boolean; list_rate: object; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate_card_id: string; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: object; ending_before?: string; override_rate?: object; pricing_group_values?: object; }[]; next_page?: string; }", markdown: "## retrieve_rate_schedule\n\n`client.v1.contracts.retrieveRateSchedule(contract_id: string, customer_id: string, limit?: number, next_page?: string, at?: string, selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]): { data: object[]; next_page?: string; }`\n\n**post** `/v1/contracts/getContractRateSchedule`\n\nFor a specific customer and contract, get the rates at a specific point in time. This endpoint takes the contract's rate card into consideration, including scheduled changes. It also takes into account overrides on the contract. \n\nFor example, if you want to show your customer a summary of the prices they are paying, inclusive of any negotiated discounts or promotions, use this endpoint. This endpoint only returns rates that are entitled.\n\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract to get the rate schedule for.\n\n- `customer_id: string`\n ID of the customer for whose contract to get the rate schedule for.\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `at?: string`\n optional timestamp which overlaps with the returned rate schedule segments. When not specified, the current timestamp will be used.\n\n- `selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of rate selectors, rates matching ANY of the selectors will be included in the response. Passing no selectors will result in all rates being returned.\n\n### Returns\n\n- `{ data: { entitled: boolean; list_rate: object; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate_card_id: string; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: object; ending_before?: string; override_rate?: object; pricing_group_values?: object; }[]; next_page?: string; }`\n\n - `data: { entitled: boolean; list_rate: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate_card_id: string; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: object[]; }; ending_before?: string; override_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; pricing_group_values?: object; }[]`\n - `next_page?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.retrieveRateSchedule({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.retrieveRateSchedule', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.retrieveRateSchedule({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n at: '2020-01-01T00:00:00.000Z',\n selectors: [\n {\n product_id: 'd6300dbb-882e-4d2d-8dec-5125d16b65d0',\n partial_pricing_group_values: { region: 'us-west-2', cloud: 'aws' },\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.retrieve_rate_schedule', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.retrieve_rate_schedule(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n selectors=[{\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0",\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws",\n },\n }],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().retrieveRateSchedule', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveRateScheduleParams;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveRateScheduleResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractRetrieveRateScheduleParams params = ContractRetrieveRateScheduleParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractRetrieveRateScheduleResponse response = client.v1().contracts().retrieveRateSchedule(params);\n }\n}', }, go: { method: 'client.V1.Contracts.GetRateSchedule', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.GetRateSchedule(context.TODO(), metronome.V1ContractGetRateScheduleParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tAt: metronome.Time(time.Now()),\n\t\tSelectors: []metronome.V1ContractGetRateScheduleParamsSelector{{\n\t\t\tProductID: metronome.String("d6300dbb-882e-4d2d-8dec-5125d16b65d0"),\n\t\t\tPartialPricingGroupValues: map[string]string{\n\t\t\t\t"region": "us-west-2",\n\t\t\t\t"cloud": "aws",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.retrieve_rate_schedule', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.retrieve_rate_schedule(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/getContractRateSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "at": "2020-01-01T00:00:00.000Z",\n "selectors": [\n {\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws"\n },\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0"\n }\n ]\n }\'', }, }, }, { name: 'list_balances', endpoint: '/v1/contracts/customerBalances/list', httpMethod: 'post', summary: 'List balances', description: 'Retrieve a comprehensive view of all available balances (commits and credits) for a customer. This endpoint provides real-time visibility into prepaid funds, postpaid commitments, promotional credits, and other balance types that can offset usage charges, helping you build transparent billing experiences.\n\n### Use this endpoint to:\n- Display current available balances in customer dashboards\n- Verify available funds before approving high-usage operations\n- Generate balance reports for finance teams\n- Filter balances by contract or date ranges\n\n### Key response fields:\nAn array of balance objects (all credits and commits) containing:\n\n- Balance details: Current available amount for each commit or credit\n- Metadata: Product associations, priorities, applicable date ranges\n- Optional ledger entries: Detailed transaction history (if `include_ledgers=true`)\n- Balance calculations: Including pending transactions and future-dated entries\n- Custom fields: Any additional metadata attached to balances\n\n### Usage guidelines:\n- Use the [getNetBalance](https://docs.metronome.com/api-reference/credits-and-commits/get-the-net-balance-of-a-customer) endpoint to retrieve a single combined current balance\n- Date filtering: Use `effective_before` to include only balances with access before a specific date (exclusive)\n- Set `include_balance=true` for calculated balance amounts on each commit or credit\n- Set `include_ledgers=true` for full transaction history\n- Set `include_contract_balances = true` to see contract level balances\n- Balance logic: Reflects currently accessible amounts, excluding expired/future segments\n- Manual adjustments: Includes all manual ledger entries, even future-dated ones\n', stainlessPath: '(resource) v1.contracts > (method) list_balances', qualified: 'client.v1.contracts.listBalances', params: [ 'customer_id: string;', 'id?: string;', 'covering_date?: string;', 'effective_before?: string;', 'exclude_zero_balances?: boolean;', 'include_archived?: boolean;', 'include_balance?: boolean;', 'include_contract_balances?: boolean;', 'include_ledgers?: boolean;', 'limit?: number;', 'next_page?: string;', 'starting_at?: string;', ], response: 'object | object', markdown: "## list_balances\n\n`client.v1.contracts.listBalances(customer_id: string, id?: string, covering_date?: string, effective_before?: string, exclude_zero_balances?: boolean, include_archived?: boolean, include_balance?: boolean, include_contract_balances?: boolean, include_ledgers?: boolean, limit?: number, next_page?: string, starting_at?: string): object | object`\n\n**post** `/v1/contracts/customerBalances/list`\n\nRetrieve a comprehensive view of all available balances (commits and credits) for a customer. This endpoint provides real-time visibility into prepaid funds, postpaid commitments, promotional credits, and other balance types that can offset usage charges, helping you build transparent billing experiences.\n\n### Use this endpoint to:\n- Display current available balances in customer dashboards\n- Verify available funds before approving high-usage operations\n- Generate balance reports for finance teams\n- Filter balances by contract or date ranges\n\n### Key response fields:\nAn array of balance objects (all credits and commits) containing:\n\n- Balance details: Current available amount for each commit or credit\n- Metadata: Product associations, priorities, applicable date ranges\n- Optional ledger entries: Detailed transaction history (if `include_ledgers=true`)\n- Balance calculations: Including pending transactions and future-dated entries\n- Custom fields: Any additional metadata attached to balances\n\n### Usage guidelines:\n- Use the [getNetBalance](https://docs.metronome.com/api-reference/credits-and-commits/get-the-net-balance-of-a-customer) endpoint to retrieve a single combined current balance\n- Date filtering: Use `effective_before` to include only balances with access before a specific date (exclusive)\n- Set `include_balance=true` for calculated balance amounts on each commit or credit\n- Set `include_ledgers=true` for full transaction history\n- Set `include_contract_balances = true` to see contract level balances\n- Balance logic: Reflects currently accessible amounts, excluding expired/future segments\n- Manual adjustments: Includes all manual ledger entries, even future-dated ones\n\n\n### Parameters\n\n- `customer_id: string`\n\n- `id?: string`\n\n- `covering_date?: string`\n Return only balances that have access schedules that \"cover\" the provided date\n\n- `effective_before?: string`\n Include only balances that have any access before the provided date (exclusive)\n\n- `exclude_zero_balances?: boolean`\n Exclude balances with zero amounts from the response.\n\n- `include_archived?: boolean`\n Include archived credits and credits from archived contracts.\n\n- `include_balance?: boolean`\n Include the balance of credits and commits in the response. Setting this flag may cause the query to be slower.\n\n- `include_contract_balances?: boolean`\n Include balances on the contract level.\n\n- `include_ledgers?: boolean`\n Include ledgers in the response. Setting this flag may cause the query to be slower.\n\n- `limit?: number`\n The maximum number of commits to return. Defaults to 25.\n\n- `next_page?: string`\n The next page token from a previous response.\n\n- `starting_at?: string`\n Include only balances that have any access on or after the provided date\n\n### Returns\n\n- `{ id: string; created_at: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: object; amount?: number; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; archived_at?: string; balance?: number; contract?: { id: string; }; cost_basis?: number; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; invoice_contract?: { id: string; }; invoice_schedule?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_ROLLOVER'; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_CREDITED'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'PREPAID_COMMIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_INITIAL_BALANCE'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'POSTPAID_COMMIT_ROLLOVER'; } | { amount: number; invoice_id: string; timestamp: string; type: 'POSTPAID_COMMIT_TRUEUP'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'PREPAID_COMMIT_MANUAL'; } | { amount: number; reason: string; timestamp: string; type: 'POSTPAID_COMMIT_MANUAL'; } | { amount: number; timestamp: string; type: 'POSTPAID_COMMIT_EXPIRATION'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_commit_id?: string; rolled_over_from?: { commit_id: string; contract_id: string; }; rollover_fraction?: number; salesforce_opportunity_id?: string; specifiers?: object[]; spend_tracker_attributes?: { counts_as_discounted: boolean; }; subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: object; subscription_id?: string; }; uniqueness_key?: string; } | { id: string; product: { id: string; name: string; }; type: 'CREDIT'; access_schedule?: object; applicable_contract_ids?: string[]; applicable_product_ids?: string[]; applicable_product_tags?: string[]; balance?: number; contract?: { id: string; }; created_by?: string; custom_fields?: object; description?: string; hierarchy_configuration?: object; ledger?: { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEGMENT_START'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_AUTOMATED_INVOICE_DEDUCTION'; contract_id?: string; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_EXPIRATION'; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CANCELED'; contract_id?: string; } | { amount: number; invoice_id: string; segment_id: string; timestamp: string; type: 'CREDIT_CREDITED'; contract_id?: string; } | { amount: number; reason: string; timestamp: string; type: 'CREDIT_MANUAL'; } | { amount: number; segment_id: string; timestamp: string; type: 'CREDIT_SEAT_BASED_ADJUSTMENT'; } | { amount: number; new_contract_id: string; segment_id: string; timestamp: string; type: 'CREDIT_ROLLOVER'; }[]; name?: string; netsuite_sales_order_id?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurring_credit_id?: string; rolled_over_from?: { contract_id: string; credit_id: string; }; salesforce_opportunity_id?: string; specifiers?: object[]; subscription_config?: { allocation?: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config?: object; subscription_id?: string; }; uniqueness_key?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const contractListBalancesResponse of client.v1.contracts.listBalances({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' })) {\n console.log(contractListBalancesResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.contracts.listBalances', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const contractListBalancesResponse of client.v1.contracts.listBalances({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n id: '6162d87b-e5db-4a33-b7f2-76ce6ead4e85',\n include_ledgers: true,\n})) {\n console.log(contractListBalancesResponse);\n}", }, python: { method: 'v1.contracts.list_balances', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.contracts.list_balances(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n id="6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n include_ledgers=True,\n)\npage = page.data[0]\nprint(page)', }, java: { method: 'v1().contracts().listBalances', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractListBalancesPage;\nimport com.metronome.api.models.v1.contracts.ContractListBalancesParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractListBalancesParams params = ContractListBalancesParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractListBalancesPage page = client.v1().contracts().listBalances(params);\n }\n}', }, go: { method: 'client.V1.Contracts.ListBalances', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Contracts.ListBalances(context.TODO(), metronome.V1ContractListBalancesParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tID: metronome.String("6162d87b-e5db-4a33-b7f2-76ce6ead4e85"),\n\t\tIncludeLedgers: metronome.Bool(true),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.contracts.list_balances', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.contracts.list_balances(customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerBalances/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "id": "6162d87b-e5db-4a33-b7f2-76ce6ead4e85",\n "include_ledgers": true\n }\'', }, }, }, { name: 'list_seat_balances', endpoint: '/v1/contracts/seatBalances/list', httpMethod: 'post', summary: 'List seat balances', description: "Retrieve detailed balance for seat-based credits and commits from the contract's subscriptions, broken down by individual seats.\n\n### Use this endpoint to:\n- Display per-seat balance information in customer dashboards\n- Filter balance data by subscription or specific seats\n\n### Key response fields:\nAn array of seat balance objects containing:\n- Seat id\n- Balance: current total balance across all commits and credits\n\n### Usage guidelines:\n- Date filtering: use `covering_date` OR `starting_at`/`ending_before` to filter balance data by time range\n- Set `include_credits_and_commits=true` for detailed commits and credits breakdown per seat\n- Set `include_ledgers=true` for detailed transaction history per commit/credit per seat\n", stainlessPath: '(resource) v1.contracts > (method) list_seat_balances', qualified: 'client.v1.contracts.listSeatBalances', params: [ 'contract_id: string;', 'customer_id: string;', 'covering_date?: string;', 'cursor?: string;', 'effective_before?: string;', 'include_credits_and_commits?: boolean;', 'include_ledgers?: boolean;', 'limit?: number;', 'seat_ids?: string[];', 'skip_missing_seat_ids?: boolean;', 'starting_at?: string;', 'subscription_ids?: string[];', ], response: '{ data: { balances: { balance: number; credit_type_id: string; starting_balance: number; }[]; seat_id: string; commits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: object[]; }[]; credits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: object[]; }[]; }[]; pagination: { seats_available_for_next_page: number; seats_included: number; next_page?: string; }; }', markdown: "## list_seat_balances\n\n`client.v1.contracts.listSeatBalances(contract_id: string, customer_id: string, covering_date?: string, cursor?: string, effective_before?: string, include_credits_and_commits?: boolean, include_ledgers?: boolean, limit?: number, seat_ids?: string[], skip_missing_seat_ids?: boolean, starting_at?: string, subscription_ids?: string[]): { data: object[]; pagination: object; }`\n\n**post** `/v1/contracts/seatBalances/list`\n\nRetrieve detailed balance for seat-based credits and commits from the contract's subscriptions, broken down by individual seats.\n\n### Use this endpoint to:\n- Display per-seat balance information in customer dashboards\n- Filter balance data by subscription or specific seats\n\n### Key response fields:\nAn array of seat balance objects containing:\n- Seat id\n- Balance: current total balance across all commits and credits\n\n### Usage guidelines:\n- Date filtering: use `covering_date` OR `starting_at`/`ending_before` to filter balance data by time range\n- Set `include_credits_and_commits=true` for detailed commits and credits breakdown per seat\n- Set `include_ledgers=true` for detailed transaction history per commit/credit per seat\n\n\n### Parameters\n\n- `contract_id: string`\n The contract ID to retrieve seat balances for\n\n- `customer_id: string`\n The customer ID to retrieve seat balances for\n\n- `covering_date?: string`\n Include only commits or credits with access that cover this specific date (cannot be used with starting_at or ending_before).\n\n- `cursor?: string`\n Page token from a previous response to retrieve the next page\n\n- `effective_before?: string`\n Include only commits or credits with access effective on or before this date (cannot be used with covering_date).\n\n- `include_credits_and_commits?: boolean`\n Include credits and commits in the response\n\n- `include_ledgers?: boolean`\n Include ledger entries for each commit and commit. `include_credits_and_commits` must be set to `true` for `include_ledgers=true` to apply.\n\n- `limit?: number`\n Maximum number of seats to return. Range: 1-100. Default: 25.\nWhen `include_credits_and_commits = true`, if the total commits/credits across all seats exceeds 100, a limit of 100 applies to the total credits and commits. Seats are included greedily to maximize the number of seats returned.\nExample: if seat 1 has 98 commits and seat 2 has 10 commits, both seats will be returned (total: 108 commits). Each returned seat includes all of its associated credits and commits.\n\n\n- `seat_ids?: string[]`\n Optional filter to only include specific seats.\n\n- `skip_missing_seat_ids?: boolean`\n When true, any seat_ids not found in contract subscriptions will be silently omitted from the response instead of returning a 400 error.\n\n- `starting_at?: string`\n Include only commits or credits with access effective on or after this date (cannot be used with covering_date).\n\n- `subscription_ids?: string[]`\n Optional filter to only include seats from specific subscriptions. If subscriptions ids are not mapped to SEAT_BASED subscriptions, error will be returned.\n\n### Returns\n\n- `{ data: { balances: { balance: number; credit_type_id: string; starting_balance: number; }[]; seat_id: string; commits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: object[]; }[]; credits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: object[]; }[]; }[]; pagination: { seats_available_for_next_page: number; seats_included: number; next_page?: string; }; }`\n\n - `data: { balances: { balance: number; credit_type_id: string; starting_balance: number; }[]; seat_id: string; commits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: { amount: number; timestamp: string; type: string; }[]; }[]; credits?: { id: string; balance: number; start_date: string; end_date?: string; ledger_entries?: { amount: number; timestamp: string; type: string; }[]; }[]; }[]`\n - `pagination: { seats_available_for_next_page: number; seats_included: number; next_page?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.listSeatBalances({ contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.listSeatBalances', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.listSeatBalances({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n covering_date: '2024-03-01T00:00:00.000Z',\n include_credits_and_commits: true,\n include_ledgers: true,\n limit: 25,\n subscription_ids: ['8deed800-1b7a-495d-a207-6c52bac54dc9'],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.list_seat_balances', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.list_seat_balances(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n covering_date=datetime.fromisoformat("2024-03-01T00:00:00.000"),\n include_credits_and_commits=True,\n include_ledgers=True,\n limit=25,\n subscription_ids=["8deed800-1b7a-495d-a207-6c52bac54dc9"],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().listSeatBalances', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractListSeatBalancesParams;\nimport com.metronome.api.models.v1.contracts.ContractListSeatBalancesResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractListSeatBalancesParams params = ContractListSeatBalancesParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractListSeatBalancesResponse response = client.v1().contracts().listSeatBalances(params);\n }\n}', }, go: { method: 'client.V1.Contracts.ListSeatBalances', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.ListSeatBalances(context.TODO(), metronome.V1ContractListSeatBalancesParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tCoveringDate: metronome.Time(time.Now()),\n\t\tIncludeCreditsAndCommits: metronome.Bool(true),\n\t\tIncludeLedgers: metronome.Bool(true),\n\t\tLimit: metronome.Int(25),\n\t\tSubscriptionIDs: []string{"8deed800-1b7a-495d-a207-6c52bac54dc9"},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.list_seat_balances', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.list_seat_balances(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/seatBalances/list \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "covering_date": "2024-03-01T00:00:00.000Z",\n "include_credits_and_commits": true,\n "include_ledgers": true,\n "limit": 25,\n "subscription_ids": [\n "8deed800-1b7a-495d-a207-6c52bac54dc9"\n ]\n }\'', }, }, }, { name: 'get_net_balance', endpoint: '/v1/contracts/customerBalances/getNetBalance', httpMethod: 'post', summary: 'Get the net balance of a customer', description: 'Retrieve the combined current balance across any grouping of credits and commits for a customer in a single API call.\n- Display real-time available balance to customers in billing dashboards\n- Build finance dashboards showing credit utilization across customer segments\n- Validate expected vs. actual balance during billing reconciliation\n\n### Key response fields:\n- `balance`: The combined net balance available to use at this moment across all matching commits and credits\n- `credit_type_id`: The credit type (fiat or custom pricing unit) the balance is denominated in\n\n### Filtering options:\nBalance filters allow you to scope the calculation to specific subsets of commits and credits. When using multiple filter objects, they are OR\'d together — if a commit or credit matches any filter, it\'s included in the net balance. Within a single filter object, all specified conditions are AND\'d together.\n- **Balance types**: Include any combination of `PREPAID_COMMIT`, `POSTPAID_COMMIT`, and `CREDIT` (e.g., `["PREPAID_COMMIT", "CREDIT"]` to exclude postpaid commits). If not specified, all balance types are included.\n- **Specific IDs**: Target exact commit or credit IDs for precise balance queries\n- **Custom fields**: Filter by custom field key-value pairs; when multiple pairs are provided, commits must match all of them\n\n**Example**: To get the balance of all free-trial credits OR all signup-promotion commits, you\'d pass two filter objects — one filtering for CREDIT with custom field campaign: free-trial, and another filtering for PREPAID_COMMIT with custom field campaign: signup-promotion.\n\n### Usage guidelines:\n- **Balance ledger details**: Use the [listBalances](https://docs.metronome.com/api-reference/credits-and-commits/list-balances) endpoint instead to understand detailed ledger drawdowns for each individual balance\n- **Draft invoice handling**: Use `invoice_inclusion_mode` to control whether pending draft invoice deductions are included (`FINALIZED_AND_DRAFT`, the default) or excluded (`FINALIZED`) from the balance calculation\n- **Account hierarchies**: When querying a child customer, shared commits from parent contracts are not included — query the parent customer directly to see shared commit balances\n- **Negative balances**: Manual ledger entries can cause negative segment balances; these are treated as zero when calculating the net balance\n- **Credit types**: If `credit_type_id` is not specified, the balance defaults to USD (cents)\n', stainlessPath: '(resource) v1.contracts > (method) get_net_balance', qualified: 'client.v1.contracts.getNetBalance', params: [ 'customer_id: string;', 'credit_type_id?: string;', "filters?: { balance_types?: 'PREPAID_COMMIT' | 'POSTPAID_COMMIT' | 'CREDIT'[]; custom_fields?: object; ids?: string[]; }[];", "invoice_inclusion_mode?: 'FINALIZED' | 'FINALIZED_AND_DRAFT';", ], response: '{ data: { balance: number; credit_type_id: string; }; }', markdown: "## get_net_balance\n\n`client.v1.contracts.getNetBalance(customer_id: string, credit_type_id?: string, filters?: { balance_types?: 'PREPAID_COMMIT' | 'POSTPAID_COMMIT' | 'CREDIT'[]; custom_fields?: object; ids?: string[]; }[], invoice_inclusion_mode?: 'FINALIZED' | 'FINALIZED_AND_DRAFT'): { data: object; }`\n\n**post** `/v1/contracts/customerBalances/getNetBalance`\n\nRetrieve the combined current balance across any grouping of credits and commits for a customer in a single API call.\n- Display real-time available balance to customers in billing dashboards\n- Build finance dashboards showing credit utilization across customer segments\n- Validate expected vs. actual balance during billing reconciliation\n\n### Key response fields:\n- `balance`: The combined net balance available to use at this moment across all matching commits and credits\n- `credit_type_id`: The credit type (fiat or custom pricing unit) the balance is denominated in\n\n### Filtering options:\nBalance filters allow you to scope the calculation to specific subsets of commits and credits. When using multiple filter objects, they are OR'd together — if a commit or credit matches any filter, it's included in the net balance. Within a single filter object, all specified conditions are AND'd together.\n- **Balance types**: Include any combination of `PREPAID_COMMIT`, `POSTPAID_COMMIT`, and `CREDIT` (e.g., `[\"PREPAID_COMMIT\", \"CREDIT\"]` to exclude postpaid commits). If not specified, all balance types are included.\n- **Specific IDs**: Target exact commit or credit IDs for precise balance queries\n- **Custom fields**: Filter by custom field key-value pairs; when multiple pairs are provided, commits must match all of them\n\n**Example**: To get the balance of all free-trial credits OR all signup-promotion commits, you'd pass two filter objects — one filtering for CREDIT with custom field campaign: free-trial, and another filtering for PREPAID_COMMIT with custom field campaign: signup-promotion.\n\n### Usage guidelines:\n- **Balance ledger details**: Use the [listBalances](https://docs.metronome.com/api-reference/credits-and-commits/list-balances) endpoint instead to understand detailed ledger drawdowns for each individual balance\n- **Draft invoice handling**: Use `invoice_inclusion_mode` to control whether pending draft invoice deductions are included (`FINALIZED_AND_DRAFT`, the default) or excluded (`FINALIZED`) from the balance calculation\n- **Account hierarchies**: When querying a child customer, shared commits from parent contracts are not included — query the parent customer directly to see shared commit balances\n- **Negative balances**: Manual ledger entries can cause negative segment balances; these are treated as zero when calculating the net balance\n- **Credit types**: If `credit_type_id` is not specified, the balance defaults to USD (cents)\n\n\n### Parameters\n\n- `customer_id: string`\n The ID of the customer.\n\n- `credit_type_id?: string`\n The ID of the credit type (can be fiat or a custom pricing unit) to get the balance for. Defaults to USD (cents) if not specified.\n\n- `filters?: { balance_types?: 'PREPAID_COMMIT' | 'POSTPAID_COMMIT' | 'CREDIT'[]; custom_fields?: object; ids?: string[]; }[]`\n Balance filters are OR'd together, so if a given commit or credit matches any of the filters, it will be included in the net balance.\n\n- `invoice_inclusion_mode?: 'FINALIZED' | 'FINALIZED_AND_DRAFT'`\n Controls which invoices are considered when calculating the remaining balance. `FINALIZED` considers only deductions from finalized invoices. `FINALIZED_AND_DRAFT` also includes deductions from pending draft invoices.\n\n### Returns\n\n- `{ data: { balance: number; credit_type_id: string; }; }`\n\n - `data: { balance: number; credit_type_id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.getNetBalance({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.getNetBalance', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.getNetBalance({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n filters: [\n {\n balance_types: ['CREDIT'],\n custom_fields: { campaign: 'free-trial' },\n },\n {\n balance_types: ['PREPAID_COMMIT', 'POSTPAID_COMMIT'],\n custom_fields: { campaign: 'signup-promotion' },\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.get_net_balance', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.get_net_balance(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n credit_type_id="2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n filters=[{\n "balance_types": ["CREDIT"],\n "custom_fields": {\n "campaign": "free-trial"\n },\n }, {\n "balance_types": ["PREPAID_COMMIT", "POSTPAID_COMMIT"],\n "custom_fields": {\n "campaign": "signup-promotion"\n },\n }],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().getNetBalance', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractGetNetBalanceParams;\nimport com.metronome.api.models.v1.contracts.ContractGetNetBalanceResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractGetNetBalanceParams params = ContractGetNetBalanceParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n ContractGetNetBalanceResponse response = client.v1().contracts().getNetBalance(params);\n }\n}', }, go: { method: 'client.V1.Contracts.GetNetBalance', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.GetNetBalance(context.TODO(), metronome.V1ContractGetNetBalanceParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\tFilters: []shared.BalanceFilterParam{{\n\t\t\tBalanceTypes: []string{"CREDIT"},\n\t\t\tCustomFields: map[string]string{\n\t\t\t\t"campaign": "free-trial",\n\t\t\t},\n\t\t}, {\n\t\t\tBalanceTypes: []string{"PREPAID_COMMIT", "POSTPAID_COMMIT"},\n\t\t\tCustomFields: map[string]string{\n\t\t\t\t"campaign": "signup-promotion",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.get_net_balance', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.get_net_balance(customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/customerBalances/getNetBalance \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "filters": [\n {\n "balance_types": [\n "CREDIT"\n ],\n "custom_fields": {\n "campaign": "free-trial"\n }\n },\n {\n "balance_types": [\n "PREPAID_COMMIT",\n "POSTPAID_COMMIT"\n ],\n "custom_fields": {\n "campaign": "signup-promotion"\n }\n }\n ]\n }\'', }, }, }, { name: 'schedule_pro_services_invoice', endpoint: '/v1/contracts/scheduleProServicesInvoice', httpMethod: 'post', summary: 'Schedule ProService invoice', description: "Create a new scheduled invoice for Professional Services terms on a contract. This endpoint's availability is dependent on your client's configuration.\n", stainlessPath: '(resource) v1.contracts > (method) schedule_pro_services_invoice', qualified: 'client.v1.contracts.scheduleProServicesInvoice', params: [ 'contract_id: string;', 'customer_id: string;', 'issued_at: string;', 'line_items: { professional_service_id: string; amendment_id?: string; amount?: number; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; quantity?: number; unit_price?: number; }[];', 'netsuite_invoice_header_end?: string;', 'netsuite_invoice_header_start?: string;', ], response: '{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }', markdown: "## schedule_pro_services_invoice\n\n`client.v1.contracts.scheduleProServicesInvoice(contract_id: string, customer_id: string, issued_at: string, line_items: { professional_service_id: string; amendment_id?: string; amount?: number; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; quantity?: number; unit_price?: number; }[], netsuite_invoice_header_end?: string, netsuite_invoice_header_start?: string): { data: invoice[]; }`\n\n**post** `/v1/contracts/scheduleProServicesInvoice`\n\nCreate a new scheduled invoice for Professional Services terms on a contract. This endpoint's availability is dependent on your client's configuration.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `issued_at: string`\n The date the invoice is issued\n\n- `line_items: { professional_service_id: string; amendment_id?: string; amount?: number; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; quantity?: number; unit_price?: number; }[]`\n Each line requires an amount or both unit_price and quantity.\n\n- `netsuite_invoice_header_end?: string`\n The end date of the invoice header in Netsuite\n\n- `netsuite_invoice_header_start?: string`\n The start date of the invoice header in Netsuite\n\n### Returns\n\n- `{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }`\n\n - `data: { id: string; credit_type: { id: string; name: string; }; customer_id: string; line_items: { credit_type: object; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: object; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: object; tiers?: object[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; invoice_adjustments?: { credit_type: object; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.scheduleProServicesInvoice({\n contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',\n customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',\n issued_at: '2019-12-27T18:11:19.117Z',\n line_items: [{ professional_service_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }],\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.scheduleProServicesInvoice', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.scheduleProServicesInvoice({\n contract_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',\n customer_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',\n issued_at: '2019-12-27T18:11:19.117Z',\n line_items: [{ professional_service_id: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e' }],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.schedule_pro_services_invoice', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.schedule_pro_services_invoice(\n contract_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n customer_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n issued_at=datetime.fromisoformat("2019-12-27T18:11:19.117"),\n line_items=[{\n "professional_service_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"\n }],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().scheduleProServicesInvoice', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractScheduleProServicesInvoiceParams;\nimport com.metronome.api.models.v1.contracts.ContractScheduleProServicesInvoiceResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractScheduleProServicesInvoiceParams params = ContractScheduleProServicesInvoiceParams.builder()\n .contractId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")\n .customerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")\n .issuedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))\n .addLineItem(ContractScheduleProServicesInvoiceParams.LineItem.builder()\n .professionalServiceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")\n .build())\n .build();\n ContractScheduleProServicesInvoiceResponse response = client.v1().contracts().scheduleProServicesInvoice(params);\n }\n}', }, go: { method: 'client.V1.Contracts.ScheduleProServicesInvoice', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.ScheduleProServicesInvoice(context.TODO(), metronome.V1ContractScheduleProServicesInvoiceParams{\n\t\tContractID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n\t\tCustomerID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n\t\tIssuedAt: time.Now(),\n\t\tLineItems: []metronome.V1ContractScheduleProServicesInvoiceParamsLineItem{{\n\t\t\tProfessionalServiceID: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.schedule_pro_services_invoice', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.schedule_pro_services_invoice(\n contract_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n customer_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n issued_at: "2019-12-27T18:11:19.117Z",\n line_items: [{professional_service_id: "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}]\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/scheduleProServicesInvoice \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n "customer_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",\n "issued_at": "2019-12-27T18:11:19.117Z",\n "line_items": [\n {\n "professional_service_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"\n }\n ]\n }\'', }, }, }, { name: 'create_historical_invoices', endpoint: '/v1/contracts/createHistoricalInvoices', httpMethod: 'post', summary: 'Create historical invoices', description: 'Create historical usage invoices for past billing periods on specific contracts. Use this endpoint to generate retroactive invoices with custom usage line items, quantities, and date ranges. Supports preview mode to validate invoice data before creation. Ideal for billing migrations or correcting past billing periods.\n', stainlessPath: '(resource) v1.contracts > (method) create_historical_invoices', qualified: 'client.v1.contracts.createHistoricalInvoices', params: [ "invoices: { contract_id: string; credit_type_id: string; customer_id: string; exclusive_end_date: string; inclusive_start_date: string; issue_date: string; usage_line_items: { exclusive_end_date: string; inclusive_start_date: string; product_id: string; presentation_group_values?: object; pricing_group_values?: object; quantity?: number; subtotals_with_quantity?: { exclusive_end_date: string; inclusive_start_date: string; quantity: number; }[]; }[]; billable_status?: 'billable' | 'unbillable'; breakdown_granularity?: 'HOUR' | 'DAY'; custom_fields?: object; }[];", 'preview: boolean;', ], response: '{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }', markdown: "## create_historical_invoices\n\n`client.v1.contracts.createHistoricalInvoices(invoices: { contract_id: string; credit_type_id: string; customer_id: string; exclusive_end_date: string; inclusive_start_date: string; issue_date: string; usage_line_items: { exclusive_end_date: string; inclusive_start_date: string; product_id: string; presentation_group_values?: object; pricing_group_values?: object; quantity?: number; subtotals_with_quantity?: object[]; }[]; billable_status?: 'billable' | 'unbillable'; breakdown_granularity?: 'HOUR' | 'DAY'; custom_fields?: object; }[], preview: boolean): { data: invoice[]; }`\n\n**post** `/v1/contracts/createHistoricalInvoices`\n\nCreate historical usage invoices for past billing periods on specific contracts. Use this endpoint to generate retroactive invoices with custom usage line items, quantities, and date ranges. Supports preview mode to validate invoice data before creation. Ideal for billing migrations or correcting past billing periods.\n\n\n### Parameters\n\n- `invoices: { contract_id: string; credit_type_id: string; customer_id: string; exclusive_end_date: string; inclusive_start_date: string; issue_date: string; usage_line_items: { exclusive_end_date: string; inclusive_start_date: string; product_id: string; presentation_group_values?: object; pricing_group_values?: object; quantity?: number; subtotals_with_quantity?: { exclusive_end_date: string; inclusive_start_date: string; quantity: number; }[]; }[]; billable_status?: 'billable' | 'unbillable'; breakdown_granularity?: 'HOUR' | 'DAY'; custom_fields?: object; }[]`\n\n- `preview: boolean`\n\n### Returns\n\n- `{ data: { id: string; credit_type: credit_type_data; customer_id: string; line_items: object[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: object[]; contract_custom_fields?: object; contract_id?: string; correction_record?: object; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: object; invoice_adjustments?: object[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: object; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: object; revenue_system_invoices?: object[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]; }`\n\n - `data: { id: string; credit_type: { id: string; name: string; }; customer_id: string; line_items: { credit_type: object; name: string; total: number; type: string; applied_commit_or_credit?: { id: string; type: 'PREPAID' | 'POSTPAID' | 'CREDIT'; }; commit_custom_fields?: object; commit_id?: string; commit_netsuite_item_id?: string; commit_netsuite_sales_order_id?: string; commit_segment_id?: string; commit_type?: string; custom_fields?: object; discount_custom_fields?: object; discount_id?: string; ending_before?: string; group_key?: string; group_value?: string; is_prorated?: boolean; list_price?: object; metadata?: string; netsuite_invoice_billing_end?: string; netsuite_invoice_billing_start?: string; netsuite_item_id?: string; origin?: { contract_id: string; customer_id: string; invoice_id: string; line_item_id: string; }; postpaid_commit?: { id: string; }; presentation_group_values?: object; pricing_group_values?: object; product_custom_fields?: object; product_id?: string; product_tags?: string[]; product_type?: string; professional_service_custom_fields?: object; professional_service_id?: string; quantity?: number; reseller_type?: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; scheduled_charge_custom_fields?: object; scheduled_charge_id?: string; starting_at?: string; sub_line_items?: { custom_fields: object; name: string; quantity: number; subtotal: number; charge_id?: string; credit_grant_id?: string; end_date?: string; price?: number; start_date?: string; tier_period?: object; tiers?: object[]; }[]; subscription_custom_fields?: object; subscription_id?: string; tier?: { level: number; starting_at: string; size?: string; }; unit_price?: number; }[]; status: string; total: number; type: string; amendment_id?: string; billable_status?: object; constituent_invoices?: { contract_id: string; customer_id: string; invoice_id: string; }[]; contract_custom_fields?: object; contract_id?: string; correction_record?: { corrected_invoice_id: string; memo: string; reason: string; corrected_external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: object; }; }; created_at?: string; custom_fields?: object; customer_custom_fields?: object; end_timestamp?: string; external_invoice?: { billing_provider_type: string; billing_provider_error?: string; external_payment_id?: string; external_status?: string; invoice_id?: string; invoiced_sub_total?: number; invoiced_total?: number; issued_at_timestamp?: string; pdf_url?: string; tax?: { total_tax_amount?: number; total_taxable_amount?: number; transaction_id?: string; }; }; invoice_adjustments?: { credit_type: object; name: string; total: number; credit_grant_custom_fields?: object; credit_grant_id?: string; }[]; issued_at?: string; net_payment_terms_days?: number; netsuite_sales_order_id?: string; payer?: { contract_id: string; customer_id: string; }; plan_custom_fields?: object; plan_id?: string; plan_name?: string; regenerated_from_invoice_id?: string; reseller_royalty?: { fraction: string; netsuite_reseller_id: string; reseller_type: 'AWS' | 'AWS_PRO_SERVICE' | 'GCP' | 'GCP_PRO_SERVICE'; aws_options?: { aws_account_number?: string; aws_offer_id?: string; aws_payer_reference_id?: string; }; gcp_options?: { gcp_account_id?: string; gcp_offer_id?: string; }; }; revenue_system_invoices?: { revenue_system_external_entity_type: string; revenue_system_provider: string; sync_status: string; error_message?: string; revenue_system_external_entity_id?: string; }[]; salesforce_opportunity_id?: string; start_timestamp?: string; subtotal?: number; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.createHistoricalInvoices({ invoices: [{\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n exclusive_end_date: '2020-02-01T00:00:00.000Z',\n inclusive_start_date: '2020-01-01T00:00:00.000Z',\n issue_date: '2020-02-01T00:00:00.000Z',\n usage_line_items: [{\n exclusive_end_date: '2020-02-01T00:00:00.000Z',\n inclusive_start_date: '2020-01-01T00:00:00.000Z',\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n}],\n}], preview: false });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.createHistoricalInvoices', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.createHistoricalInvoices({\n invoices: [\n {\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n inclusive_start_date: '2020-01-01T00:00:00.000Z',\n exclusive_end_date: '2020-02-01T00:00:00.000Z',\n issue_date: '2020-02-01T00:00:00.000Z',\n usage_line_items: [\n {\n product_id: 'f14d6729-6a44-4b13-9908-9387f1918790',\n inclusive_start_date: '2020-01-01T00:00:00.000Z',\n exclusive_end_date: '2020-02-01T00:00:00.000Z',\n quantity: 100,\n },\n ],\n },\n ],\n preview: false,\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.create_historical_invoices', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.create_historical_invoices(\n invoices=[{\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "inclusive_start_date": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "exclusive_end_date": datetime.fromisoformat("2020-02-01T00:00:00.000"),\n "issue_date": datetime.fromisoformat("2020-02-01T00:00:00.000"),\n "usage_line_items": [{\n "product_id": "f14d6729-6a44-4b13-9908-9387f1918790",\n "inclusive_start_date": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "exclusive_end_date": datetime.fromisoformat("2020-02-01T00:00:00.000"),\n "quantity": 100,\n }],\n }],\n preview=False,\n)\nprint(response.data)', }, java: { method: 'v1().contracts().createHistoricalInvoices', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractCreateHistoricalInvoicesParams;\nimport com.metronome.api.models.v1.contracts.ContractCreateHistoricalInvoicesResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractCreateHistoricalInvoicesParams params = ContractCreateHistoricalInvoicesParams.builder()\n .addInvoice(ContractCreateHistoricalInvoicesParams.Invoice.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .creditTypeId("2714e483-4ff1-48e4-9e25-ac732e8f24f2")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .exclusiveEndDate(OffsetDateTime.parse("2020-02-01T00:00:00.000Z"))\n .inclusiveStartDate(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .issueDate(OffsetDateTime.parse("2020-02-01T00:00:00.000Z"))\n .addUsageLineItem(ContractCreateHistoricalInvoicesParams.Invoice.UsageLineItem.builder()\n .exclusiveEndDate(OffsetDateTime.parse("2020-02-01T00:00:00.000Z"))\n .inclusiveStartDate(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .productId("f14d6729-6a44-4b13-9908-9387f1918790")\n .build())\n .build())\n .preview(false)\n .build();\n ContractCreateHistoricalInvoicesResponse response = client.v1().contracts().createHistoricalInvoices(params);\n }\n}', }, go: { method: 'client.V1.Contracts.NewHistoricalInvoices', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.NewHistoricalInvoices(context.TODO(), metronome.V1ContractNewHistoricalInvoicesParams{\n\t\tInvoices: []metronome.V1ContractNewHistoricalInvoicesParamsInvoice{{\n\t\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\t\tCreditTypeID: "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n\t\t\tInclusiveStartDate: time.Now(),\n\t\t\tExclusiveEndDate: time.Now(),\n\t\t\tIssueDate: time.Now(),\n\t\t\tUsageLineItems: []metronome.V1ContractNewHistoricalInvoicesParamsInvoiceUsageLineItem{{\n\t\t\t\tProductID: "f14d6729-6a44-4b13-9908-9387f1918790",\n\t\t\t\tInclusiveStartDate: time.Now(),\n\t\t\t\tExclusiveEndDate: time.Now(),\n\t\t\t\tQuantity: metronome.Float(100),\n\t\t\t}},\n\t\t}},\n\t\tPreview: false,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.create_historical_invoices', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.create_historical_invoices(\n invoices: [\n {\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n credit_type_id: "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n exclusive_end_date: "2020-02-01T00:00:00.000Z",\n inclusive_start_date: "2020-01-01T00:00:00.000Z",\n issue_date: "2020-02-01T00:00:00.000Z",\n usage_line_items: [\n {\n exclusive_end_date: "2020-02-01T00:00:00.000Z",\n inclusive_start_date: "2020-01-01T00:00:00.000Z",\n product_id: "f14d6729-6a44-4b13-9908-9387f1918790"\n }\n ]\n }\n ],\n preview: false\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/createHistoricalInvoices \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "invoices": [\n {\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "exclusive_end_date": "2020-02-01T00:00:00.000Z",\n "inclusive_start_date": "2020-01-01T00:00:00.000Z",\n "issue_date": "2020-02-01T00:00:00.000Z",\n "usage_line_items": [\n {\n "exclusive_end_date": "2020-02-01T00:00:00.000Z",\n "inclusive_start_date": "2020-01-01T00:00:00.000Z",\n "product_id": "f14d6729-6a44-4b13-9908-9387f1918790",\n "quantity": 100\n }\n ]\n }\n ],\n "preview": false\n }\'', }, }, }, { name: 'retrieve_subscription_quantity_history', endpoint: '/v1/contracts/getSubscriptionQuantityHistory', httpMethod: 'post', summary: 'Get subscription quantity history', description: "Get the history of subscription quantities and prices over time for a given `subscription_id`. This endpoint can be used to power an in-product experience where you show a customer their historical changes to seat count. Future changes are not included in this endpoint - use the `getContract` endpoint to view the future scheduled changes to a subscription's quantity. \n\nSubscriptions are used to model fixed recurring fees as well as seat-based recurring fees. To model changes to the number of seats in Metronome, you can increment or decrement the quantity on a subscription at any point in the past or future.\n", stainlessPath: '(resource) v1.contracts > (method) retrieve_subscription_quantity_history', qualified: 'client.v1.contracts.retrieveSubscriptionQuantityHistory', params: ['contract_id: string;', 'customer_id: string;', 'subscription_id: string;'], response: '{ data: { fiat_credit_type_id?: string; history?: { data: object[]; starting_at: string; }[]; subscription_id?: string; }; }', markdown: "## retrieve_subscription_quantity_history\n\n`client.v1.contracts.retrieveSubscriptionQuantityHistory(contract_id: string, customer_id: string, subscription_id: string): { data: object; }`\n\n**post** `/v1/contracts/getSubscriptionQuantityHistory`\n\nGet the history of subscription quantities and prices over time for a given `subscription_id`. This endpoint can be used to power an in-product experience where you show a customer their historical changes to seat count. Future changes are not included in this endpoint - use the `getContract` endpoint to view the future scheduled changes to a subscription's quantity. \n\nSubscriptions are used to model fixed recurring fees as well as seat-based recurring fees. To model changes to the number of seats in Metronome, you can increment or decrement the quantity on a subscription at any point in the past or future.\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `subscription_id: string`\n\n### Returns\n\n- `{ data: { fiat_credit_type_id?: string; history?: { data: object[]; starting_at: string; }[]; subscription_id?: string; }; }`\n\n - `data: { fiat_credit_type_id?: string; history?: { data: { quantity: number; total: number; unit_price: number; }[]; starting_at: string; }[]; subscription_id?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.retrieveSubscriptionQuantityHistory({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n subscription_id: '1a824d53-bde6-4d82-96d7-6347ff227d5c',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.retrieveSubscriptionQuantityHistory', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.retrieveSubscriptionQuantityHistory({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n subscription_id: '1a824d53-bde6-4d82-96d7-6347ff227d5c',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.retrieve_subscription_quantity_history', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.retrieve_subscription_quantity_history(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n subscription_id="1a824d53-bde6-4d82-96d7-6347ff227d5c",\n)\nprint(response.data)', }, java: { method: 'v1().contracts().retrieveSubscriptionQuantityHistory', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveSubscriptionQuantityHistoryParams;\nimport com.metronome.api.models.v1.contracts.ContractRetrieveSubscriptionQuantityHistoryResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractRetrieveSubscriptionQuantityHistoryParams params = ContractRetrieveSubscriptionQuantityHistoryParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c")\n .build();\n ContractRetrieveSubscriptionQuantityHistoryResponse response = client.v1().contracts().retrieveSubscriptionQuantityHistory(params);\n }\n}', }, go: { method: 'client.V1.Contracts.GetSubscriptionQuantityHistory', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.GetSubscriptionQuantityHistory(context.TODO(), metronome.V1ContractGetSubscriptionQuantityHistoryParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tSubscriptionID: "1a824d53-bde6-4d82-96d7-6347ff227d5c",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.retrieve_subscription_quantity_history', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.retrieve_subscription_quantity_history(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n subscription_id: "1a824d53-bde6-4d82-96d7-6347ff227d5c"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/getSubscriptionQuantityHistory \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "subscription_id": "1a824d53-bde6-4d82-96d7-6347ff227d5c"\n }\'', }, }, }, { name: 'get_subscription_seats_history', endpoint: '/v1/contracts/getSubscriptionSeatsHistory', httpMethod: 'post', summary: 'Get subscription seats history', description: 'Get the history of subscription seats schedule over time for a given `subscription_id`. This endpoint provides information about seat assignments and total quantities for different time periods, allowing you to track how seat assignments have changed over time.\n\n### Use this endpoint to:\n- Track changes to seat assignments over time\n- Get seat schedule for a specific date using the `covering_date` parameter\n- Get seat schedule history with optional date range filtering using `starting_at` and `ending_before`\n\n### Key response fields:\n- data: array of seat schedule entries with time periods, quantity, and assignments\n- next_page: cursor for pagination to retrieve additional results\n\n### Usage guidelines:\n- Use `covering_date` to get the active seats for a specific point in time. `covering_date` cannot be used with `starting_at` or `ending_before`.\n- Use `starting_at` and `ending_before` to filter results by time range. `starting_at` and `ending_before` cannot be used with `covering_date`.\n- Maximum limit is 10 seat schedule entries per request\n- Results are ordered by `starting_at` timestamp\n', stainlessPath: '(resource) v1.contracts > (method) get_subscription_seats_history', qualified: 'client.v1.contracts.getSubscriptionSeatsHistory', params: [ 'contract_id: string;', 'customer_id: string;', 'subscription_id: string;', 'covering_date?: string;', 'cursor?: string;', 'ending_before?: string;', 'limit?: number;', 'starting_at?: string;', ], response: '{ data: { assigned_seat_ids: string[]; ending_before: string; starting_at: string; total_quantity: number; }[]; next_page: string; }', markdown: "## get_subscription_seats_history\n\n`client.v1.contracts.getSubscriptionSeatsHistory(contract_id: string, customer_id: string, subscription_id: string, covering_date?: string, cursor?: string, ending_before?: string, limit?: number, starting_at?: string): { data: object[]; next_page: string; }`\n\n**post** `/v1/contracts/getSubscriptionSeatsHistory`\n\nGet the history of subscription seats schedule over time for a given `subscription_id`. This endpoint provides information about seat assignments and total quantities for different time periods, allowing you to track how seat assignments have changed over time.\n\n### Use this endpoint to:\n- Track changes to seat assignments over time\n- Get seat schedule for a specific date using the `covering_date` parameter\n- Get seat schedule history with optional date range filtering using `starting_at` and `ending_before`\n\n### Key response fields:\n- data: array of seat schedule entries with time periods, quantity, and assignments\n- next_page: cursor for pagination to retrieve additional results\n\n### Usage guidelines:\n- Use `covering_date` to get the active seats for a specific point in time. `covering_date` cannot be used with `starting_at` or `ending_before`.\n- Use `starting_at` and `ending_before` to filter results by time range. `starting_at` and `ending_before` cannot be used with `covering_date`.\n- Maximum limit is 10 seat schedule entries per request\n- Results are ordered by `starting_at` timestamp\n\n\n### Parameters\n\n- `contract_id: string`\n\n- `customer_id: string`\n\n- `subscription_id: string`\n\n- `covering_date?: string`\n Get the seats history segment for the covering date. Cannot be used with `starting_at` or `ending_before`.\n\n- `cursor?: string`\n Cursor for pagination. Use the value from the `next_page` field of the previous response to retrieve the next page of results.\n\n- `ending_before?: string`\n Include seats history segments that are active at or before this timestamp. Use with `starting_at` to get a specific time range. If not set, there's no upper bound.\n\n- `limit?: number`\n Maximum number of seat schedule entries to return. Defaults to 10. Required range: 1 <= x <= 10.\n\n- `starting_at?: string`\n Include seats history segments that are active at or after this timestamp. Use with `ending_before` to get a specific time range. If not set, there's no lower bound.\n\n### Returns\n\n- `{ data: { assigned_seat_ids: string[]; ending_before: string; starting_at: string; total_quantity: number; }[]; next_page: string; }`\n\n - `data: { assigned_seat_ids: string[]; ending_before: string; starting_at: string; total_quantity: number; }[]`\n - `next_page: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.getSubscriptionSeatsHistory({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n subscription_id: '1a824d53-bde6-4d82-96d7-6347ff227d5c',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.getSubscriptionSeatsHistory', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.getSubscriptionSeatsHistory({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n subscription_id: '1a824d53-bde6-4d82-96d7-6347ff227d5c',\n covering_date: '2024-01-15T00:00:00.000Z',\n limit: 10,\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.get_subscription_seats_history', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.get_subscription_seats_history(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n subscription_id="1a824d53-bde6-4d82-96d7-6347ff227d5c",\n covering_date=datetime.fromisoformat("2024-01-15T00:00:00.000"),\n limit=10,\n)\nprint(response.data)', }, java: { method: 'v1().contracts().getSubscriptionSeatsHistory', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryParams;\nimport com.metronome.api.models.v1.contracts.ContractGetSubscriptionSeatsHistoryResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ContractGetSubscriptionSeatsHistoryParams params = ContractGetSubscriptionSeatsHistoryParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .subscriptionId("1a824d53-bde6-4d82-96d7-6347ff227d5c")\n .build();\n ContractGetSubscriptionSeatsHistoryResponse response = client.v1().contracts().getSubscriptionSeatsHistory(params);\n }\n}', }, go: { method: 'client.V1.Contracts.GetSubscriptionSeatsHistory', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.GetSubscriptionSeatsHistory(context.TODO(), metronome.V1ContractGetSubscriptionSeatsHistoryParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tSubscriptionID: "1a824d53-bde6-4d82-96d7-6347ff227d5c",\n\t\tCoveringDate: metronome.Time(time.Now()),\n\t\tLimit: metronome.Int(10),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.get_subscription_seats_history', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.get_subscription_seats_history(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n subscription_id: "1a824d53-bde6-4d82-96d7-6347ff227d5c"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/getSubscriptionSeatsHistory \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "subscription_id": "1a824d53-bde6-4d82-96d7-6347ff227d5c",\n "covering_date": "2024-01-15T00:00:00.000Z",\n "limit": 10\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/contract-pricing/products/get', httpMethod: 'post', summary: 'Get a product', description: 'Retrieve a product by its ID, including all metadata and historical changes.\n', stainlessPath: '(resource) v1.contracts.products > (method) retrieve', qualified: 'client.v1.contracts.products.retrieve', params: ['id: string;'], response: "{ data: { id: string; current: object; initial: object; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: quantity_conversion; quantity_rounding?: quantity_rounding; starting_at?: string; tags?: string[]; }[]; archived_at?: string; custom_fields?: object; }; }", markdown: "## retrieve\n\n`client.v1.contracts.products.retrieve(id: string): { data: object; }`\n\n**post** `/v1/contract-pricing/products/get`\n\nRetrieve a product by its ID, including all metadata and historical changes.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ data: { id: string; current: object; initial: object; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: quantity_conversion; quantity_rounding?: quantity_rounding; starting_at?: string; tags?: string[]; }[]; archived_at?: string; custom_fields?: object; }; }`\n\n - `data: { id: string; current: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: object; quantity_rounding?: object; starting_at?: string; tags?: string[]; }; initial: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: object; quantity_rounding?: object; starting_at?: string; tags?: string[]; }; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }; quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }; starting_at?: string; tags?: string[]; }[]; archived_at?: string; custom_fields?: object; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst product = await client.v1.contracts.products.retrieve({ id: 'd84e7f4e-7a70-4fe4-be02-7a5027beffcc' });\n\nconsole.log(product);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.products.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst product = await client.v1.contracts.products.retrieve({\n id: 'd84e7f4e-7a70-4fe4-be02-7a5027beffcc',\n});\n\nconsole.log(product.data);", }, python: { method: 'v1.contracts.products.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nproduct = client.v1.contracts.products.retrieve(\n id="d84e7f4e-7a70-4fe4-be02-7a5027beffcc",\n)\nprint(product.data)', }, java: { method: 'v1().contracts().products().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.Id;\nimport com.metronome.api.models.v1.contracts.products.ProductRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n Id params = Id.builder()\n .id("d84e7f4e-7a70-4fe4-be02-7a5027beffcc")\n .build();\n ProductRetrieveResponse product = client.v1().contracts().products().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Products.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tproduct, err := client.V1.Contracts.Products.Get(context.TODO(), metronome.V1ContractProductGetParams{\n\t\tID: shared.IDParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", product.Data)\n}\n', }, ruby: { method: 'v1.contracts.products.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nproduct = metronome.v1.contracts.products.retrieve(id: "d84e7f4e-7a70-4fe4-be02-7a5027beffcc")\n\nputs(product)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/products/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "d84e7f4e-7a70-4fe4-be02-7a5027beffcc"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/contract-pricing/products/list', httpMethod: 'post', summary: 'List products', description: 'Get a paginated list of all products in your organization with their complete configuration, version history, and metadata. By default excludes archived products unless explicitly requested via the `archive_filter` parameter.\n', stainlessPath: '(resource) v1.contracts.products > (method) list', qualified: 'client.v1.contracts.products.list', params: [ 'limit?: number;', 'next_page?: string;', "archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL';", ], response: "{ id: string; current: object; initial: object; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: quantity_conversion; quantity_rounding?: quantity_rounding; starting_at?: string; tags?: string[]; }[]; archived_at?: string; custom_fields?: object; }", markdown: "## list\n\n`client.v1.contracts.products.list(limit?: number, next_page?: string, archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL'): { id: string; current: product_list_item_state; initial: product_list_item_state; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: object[]; archived_at?: string; custom_fields?: object; }`\n\n**post** `/v1/contract-pricing/products/list`\n\nGet a paginated list of all products in your organization with their complete configuration, version history, and metadata. By default excludes archived products unless explicitly requested via the `archive_filter` parameter.\n\n\n### Parameters\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL'`\n Filter options for the product list. If not provided, defaults to not archived.\n\n### Returns\n\n- `{ id: string; current: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: quantity_conversion; quantity_rounding?: quantity_rounding; starting_at?: string; tags?: string[]; }; initial: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: quantity_conversion; quantity_rounding?: quantity_rounding; starting_at?: string; tags?: string[]; }; type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'; updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: object; quantity_rounding?: object; starting_at?: string; tags?: string[]; }[]; archived_at?: string; custom_fields?: object; }`\n\n - `id: string`\n - `current: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }; quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }; starting_at?: string; tags?: string[]; }`\n - `initial: { created_at: string; created_by: string; name: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }; quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }; starting_at?: string; tags?: string[]; }`\n - `type: 'USAGE' | 'SUBSCRIPTION' | 'COMPOSITE' | 'FIXED' | 'PRO_SERVICE'`\n - `updates: { created_at: string; created_by: string; billable_metric_id?: string; composite_product_ids?: string[]; composite_tags?: string[]; exclude_free_usage?: boolean; is_refundable?: boolean; name?: string; netsuite_internal_item_id?: string; netsuite_overage_item_id?: string; presentation_group_key?: string[]; pricing_group_key?: string[]; quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }; quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }; starting_at?: string; tags?: string[]; }[]`\n - `archived_at?: string`\n - `custom_fields?: object`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const productListResponse of client.v1.contracts.products.list()) {\n console.log(productListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.contracts.products.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const productListResponse of client.v1.contracts.products.list({\n archive_filter: 'NOT_ARCHIVED',\n})) {\n console.log(productListResponse.id);\n}", }, python: { method: 'v1.contracts.products.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.contracts.products.list(\n archive_filter="NOT_ARCHIVED",\n)\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().contracts().products().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.products.ProductListPage;\nimport com.metronome.api.models.v1.contracts.products.ProductListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductListPage page = client.v1().contracts().products().list();\n }\n}', }, go: { method: 'client.V1.Contracts.Products.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Contracts.Products.List(context.TODO(), metronome.V1ContractProductListParams{\n\t\tArchiveFilter: metronome.V1ContractProductListParamsArchiveFilterNotArchived,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.contracts.products.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.contracts.products.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/products/list \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/contract-pricing/products/create', httpMethod: 'post', summary: 'Create a product', description: "Create a new product object. Products in Metronome represent your company's individual product or service offerings. A Product can be thought of as the basic unit of a line item on the invoice. This is analogous to SKUs or items in an ERP system. Give the product a meaningful name as they will appear on customer invoices.\n", stainlessPath: '(resource) v1.contracts.products > (method) create', qualified: 'client.v1.contracts.products.create', params: [ 'name: string;', "type: 'FIXED' | 'USAGE' | 'COMPOSITE' | 'SUBSCRIPTION' | 'PROFESSIONAL_SERVICE' | 'PRO_SERVICE';", 'billable_metric_id?: string;', 'composite_product_ids?: string[];', 'composite_tags?: string[];', 'custom_fields?: object;', 'exclude_free_usage?: boolean;', 'is_refundable?: boolean;', 'netsuite_internal_item_id?: string;', 'netsuite_overage_item_id?: string;', 'presentation_group_key?: string[];', 'pricing_group_key?: string[];', "quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; };", "quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; };", "sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD';", 'tags?: string[];', ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.contracts.products.create(name: string, type: 'FIXED' | 'USAGE' | 'COMPOSITE' | 'SUBSCRIPTION' | 'PROFESSIONAL_SERVICE' | 'PRO_SERVICE', billable_metric_id?: string, composite_product_ids?: string[], composite_tags?: string[], custom_fields?: object, exclude_free_usage?: boolean, is_refundable?: boolean, netsuite_internal_item_id?: string, netsuite_overage_item_id?: string, presentation_group_key?: string[], pricing_group_key?: string[], quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }, quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }, sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD', tags?: string[]): { data: id; }`\n\n**post** `/v1/contract-pricing/products/create`\n\nCreate a new product object. Products in Metronome represent your company's individual product or service offerings. A Product can be thought of as the basic unit of a line item on the invoice. This is analogous to SKUs or items in an ERP system. Give the product a meaningful name as they will appear on customer invoices.\n\n\n### Parameters\n\n- `name: string`\n displayed on invoices\n\n- `type: 'FIXED' | 'USAGE' | 'COMPOSITE' | 'SUBSCRIPTION' | 'PROFESSIONAL_SERVICE' | 'PRO_SERVICE'`\n\n- `billable_metric_id?: string`\n Required for USAGE products\n\n- `composite_product_ids?: string[]`\n Required for COMPOSITE products\n\n- `composite_tags?: string[]`\n Required for COMPOSITE products\n\n- `custom_fields?: object`\n Custom fields to be added eg. { \"key1\": \"value1\", \"key2\": \"value2\" }\n\n- `exclude_free_usage?: boolean`\n Beta feature only available for composite products. If true, products with $0 will not be included when computing composite usage. Defaults to false\n\n- `is_refundable?: boolean`\n This field's availability is dependent on your client's configuration. Defaults to true.\n\n- `netsuite_internal_item_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `netsuite_overage_item_id?: string`\n This field's availability is dependent on your client's configuration.\n\n- `presentation_group_key?: string[]`\n For USAGE products only. Groups usage line items on invoices. The superset of values in the pricing group key and presentation group key must be set as one compound group key on the billable metric.\n\n- `pricing_group_key?: string[]`\n For USAGE products only. If set, pricing for this product will be determined for each pricing_group_key value, as opposed to the product as a whole. The superset of values in the pricing group key and presentation group key must be set as one compound group key on the billable metric.\n\n- `quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }`\n Optional. Only valid for USAGE products. If provided, the quantity will be converted using the provided conversion factor and operation. For example, if the operation is \"multiply\" and the conversion factor is 100, then the quantity will be multiplied by 100. This can be used in cases where data is sent in one unit and priced in another. For example, data could be sent in MB and priced in GB. In this case, the conversion factor would be 1024 and the operation would be \"divide\".\n - `conversion_factor: number`\n The factor to multiply or divide the quantity by.\n - `operation: 'MULTIPLY' | 'DIVIDE'`\n The operation to perform on the quantity\n - `name?: string`\n Optional name for this conversion.\n\n- `quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }`\n Optional. Only valid for USAGE products. If provided, the quantity will be rounded using the provided rounding method and decimal places. For example, if the method is \"round up\" and the decimal places is 0, then the quantity will be rounded up to the nearest integer.\n - `decimal_places: number`\n - `rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'`\n\n- `sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD'`\n Defines the breakdown behavior when calculating usage from SQL Billable Metrics. If set to 'service_period' (default), the usage will be evaluated once for all events the invoice service period and the usage will be applied at the last instant of the invoice. If set to 'hour', it will be broken down and evaluated for each hour. For most use cases, 'hour' is recommended. The setting has no effect for Streaming Billable Metrics.\n\n- `tags?: string[]`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst product = await client.v1.contracts.products.create({ name: 'My Product', type: 'USAGE' });\n\nconsole.log(product);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.products.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst product = await client.v1.contracts.products.create({\n name: 'My Product',\n type: 'USAGE',\n billable_metric_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n});\n\nconsole.log(product.data);", }, python: { method: 'v1.contracts.products.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nproduct = client.v1.contracts.products.create(\n name="My Product",\n type="USAGE",\n billable_metric_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\nprint(product.data)', }, java: { method: 'v1().contracts().products().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.products.ProductCreateParams;\nimport com.metronome.api.models.v1.contracts.products.ProductCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductCreateParams params = ProductCreateParams.builder()\n .name("My Product")\n .type(ProductCreateParams.Type.USAGE)\n .build();\n ProductCreateResponse product = client.v1().contracts().products().create(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Products.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tproduct, err := client.V1.Contracts.Products.New(context.TODO(), metronome.V1ContractProductNewParams{\n\t\tName: "My Product",\n\t\tType: metronome.V1ContractProductNewParamsTypeUsage,\n\t\tBillableMetricID: metronome.String("13117714-3f05-48e5-a6e9-a66093f13b4d"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", product.Data)\n}\n', }, ruby: { method: 'v1.contracts.products.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nproduct = metronome.v1.contracts.products.create(name: "My Product", type: :USAGE)\n\nputs(product)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/products/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "My Product",\n "type": "USAGE",\n "billable_metric_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/contract-pricing/products/update', httpMethod: 'post', summary: 'Update a product', description: "Updates a product's configuration while maintaining billing continuity for active customers. Use this endpoint to modify product names, metrics, pricing rules, and composite settings without disrupting ongoing billing cycles. Changes are scheduled using the starting_at timestamp, which must be on an hour boundary—set future dates to schedule updates ahead of time, or past dates for retroactive changes. Returns the updated product ID upon success. \n\n### Usage guidance: \n- Product type cannot be changed after creation. For incorrect product types, create a new product and archive the original instead.\n", stainlessPath: '(resource) v1.contracts.products > (method) update', qualified: 'client.v1.contracts.products.update', params: [ 'product_id: string;', 'starting_at: string;', 'billable_metric_id?: string;', 'composite_product_ids?: string[];', 'composite_tags?: string[];', 'exclude_free_usage?: boolean;', 'is_refundable?: boolean;', 'name?: string;', 'netsuite_internal_item_id?: string;', 'netsuite_overage_item_id?: string;', 'presentation_group_key?: string[];', 'pricing_group_key?: string[];', "quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; };", "quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; };", "sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD';", 'tags?: string[];', ], response: '{ data: { id: string; }; }', markdown: "## update\n\n`client.v1.contracts.products.update(product_id: string, starting_at: string, billable_metric_id?: string, composite_product_ids?: string[], composite_tags?: string[], exclude_free_usage?: boolean, is_refundable?: boolean, name?: string, netsuite_internal_item_id?: string, netsuite_overage_item_id?: string, presentation_group_key?: string[], pricing_group_key?: string[], quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }, quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }, sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD', tags?: string[]): { data: id; }`\n\n**post** `/v1/contract-pricing/products/update`\n\nUpdates a product's configuration while maintaining billing continuity for active customers. Use this endpoint to modify product names, metrics, pricing rules, and composite settings without disrupting ongoing billing cycles. Changes are scheduled using the starting_at timestamp, which must be on an hour boundary—set future dates to schedule updates ahead of time, or past dates for retroactive changes. Returns the updated product ID upon success. \n\n### Usage guidance: \n- Product type cannot be changed after creation. For incorrect product types, create a new product and archive the original instead.\n\n\n### Parameters\n\n- `product_id: string`\n ID of the product to update\n\n- `starting_at: string`\n Timestamp representing when the update should go into effect. It must be on an hour boundary (e.g. 1:00, not 1:30).\n\n- `billable_metric_id?: string`\n Available for USAGE products only. If not provided, defaults to product's current billable metric.\n\n- `composite_product_ids?: string[]`\n Available for COMPOSITE products only. If not provided, defaults to product's current composite_product_ids.\n\n- `composite_tags?: string[]`\n Available for COMPOSITE products only. If not provided, defaults to product's current composite_tags.\n\n- `exclude_free_usage?: boolean`\n Beta feature only available for composite products. If true, products with $0 will not be included when computing composite usage. Defaults to false\n\n- `is_refundable?: boolean`\n Defaults to product's current refundability status. This field's availability is dependent on your client's configuration.\n\n- `name?: string`\n displayed on invoices. If not provided, defaults to product's current name.\n\n- `netsuite_internal_item_id?: string`\n If not provided, defaults to product's current netsuite_internal_item_id. This field's availability is dependent on your client's configuration.\n\n- `netsuite_overage_item_id?: string`\n Available for USAGE and COMPOSITE products only. If not provided, defaults to product's current netsuite_overage_item_id. This field's availability is dependent on your client's configuration.\n\n- `presentation_group_key?: string[]`\n For USAGE products only. Groups usage line items on invoices. The superset of values in the pricing group key and presentation group key must be set as one compound group key on the billable metric.\n\n- `pricing_group_key?: string[]`\n For USAGE products only. If set, pricing for this product will be determined for each pricing_group_key value, as opposed to the product as a whole. The superset of values in the pricing group key and presentation group key must be set as one compound group key on the billable metric.\n\n- `quantity_conversion?: { conversion_factor: number; operation: 'MULTIPLY' | 'DIVIDE'; name?: string; }`\n Optional. Only valid for USAGE products. If provided, the quantity will be converted using the provided conversion factor and operation. For example, if the operation is \"multiply\" and the conversion factor is 100, then the quantity will be multiplied by 100. This can be used in cases where data is sent in one unit and priced in another. For example, data could be sent in MB and priced in GB. In this case, the conversion factor would be 1024 and the operation would be \"divide\".\n - `conversion_factor: number`\n The factor to multiply or divide the quantity by.\n - `operation: 'MULTIPLY' | 'DIVIDE'`\n The operation to perform on the quantity\n - `name?: string`\n Optional name for this conversion.\n\n- `quantity_rounding?: { decimal_places: number; rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'; }`\n Optional. Only valid for USAGE products. If provided, the quantity will be rounded using the provided rounding method and decimal places. For example, if the method is \"round up\" and the decimal places is 0, then the quantity will be rounded up to the nearest integer.\n - `decimal_places: number`\n - `rounding_method: 'ROUND_UP' | 'ROUND_DOWN' | 'ROUND_HALF_UP'`\n\n- `sql_breakdown_granularity?: 'HOUR' | 'SERVICE_PERIOD'`\n Defines the breakdown behavior when calculating usage from SQL Billable Metrics. If set to 'service_period' (default), the usage will be evaluated once for all events the invoice service period and the usage will be applied at the last instant of the invoice. If set to 'hour', it will be broken down and evaluated for each hour. For most use cases, 'hour' is recommended. The setting has no effect for Streaming Billable Metrics.\n\n- `tags?: string[]`\n If not provided, defaults to product's current tags\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst product = await client.v1.contracts.products.update({ product_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', starting_at: '2020-01-01T00:00:00.000Z' });\n\nconsole.log(product);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.products.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst product = await client.v1.contracts.products.update({\n product_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n starting_at: '2020-01-01T00:00:00.000Z',\n name: 'My Updated Product',\n});\n\nconsole.log(product.data);", }, python: { method: 'v1.contracts.products.update', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nproduct = client.v1.contracts.products.update(\n product_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n name="My Updated Product",\n)\nprint(product.data)', }, java: { method: 'v1().contracts().products().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.products.ProductUpdateParams;\nimport com.metronome.api.models.v1.contracts.products.ProductUpdateResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductUpdateParams params = ProductUpdateParams.builder()\n .productId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\n ProductUpdateResponse product = client.v1().contracts().products().update(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Products.Update', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tproduct, err := client.V1.Contracts.Products.Update(context.TODO(), metronome.V1ContractProductUpdateParams{\n\t\tProductID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tStartingAt: time.Now(),\n\t\tName: metronome.String("My Updated Product"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", product.Data)\n}\n', }, ruby: { method: 'v1.contracts.products.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nproduct = metronome.v1.contracts.products.update(\n product_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n starting_at: "2020-01-01T00:00:00.000Z"\n)\n\nputs(product)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/products/update \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "product_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "starting_at": "2020-01-01T00:00:00.000Z",\n "name": "My Updated Product"\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/contract-pricing/products/archive', httpMethod: 'post', summary: 'Archive a product', description: 'Archive a product. Any current rate cards associated with this product will continue to function as normal. However, it will no longer be available as an option for newly created rates. Once you archive a product, you can still retrieve it in the UI and API, but you cannot unarchive it.\n', stainlessPath: '(resource) v1.contracts.products > (method) archive', qualified: 'client.v1.contracts.products.archive', params: ['product_id: string;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.contracts.products.archive(product_id: string): { data: id; }`\n\n**post** `/v1/contract-pricing/products/archive`\n\nArchive a product. Any current rate cards associated with this product will continue to function as normal. However, it will no longer be available as an option for newly created rates. Once you archive a product, you can still retrieve it in the UI and API, but you cannot unarchive it.\n\n\n### Parameters\n\n- `product_id: string`\n ID of the product to be archived\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.products.archive({ product_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.products.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.products.archive({\n product_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.products.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.products.archive(\n product_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(response.data)', }, java: { method: 'v1().contracts().products().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.products.ProductArchiveParams;\nimport com.metronome.api.models.v1.contracts.products.ProductArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductArchiveParams params = ProductArchiveParams.builder()\n .productId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n ProductArchiveResponse response = client.v1().contracts().products().archive(params);\n }\n}', }, go: { method: 'client.V1.Contracts.Products.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.Products.Archive(context.TODO(), metronome.V1ContractProductArchiveParams{\n\t\tProductID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.products.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.products.archive(product_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/products/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "product_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'retrieve_rate_schedule', endpoint: '/v1/contract-pricing/rate-cards/getRateSchedule', httpMethod: 'post', summary: 'Get a rate schedule', description: "A rate card defines the prices that you charge for your products. Rate cards support scheduled changes over time, to allow you to easily roll out pricing changes and new product launches across your customer base. Use this endpoint to understand the rate schedule `starting_at` a given date, optionally filtering the list of rates returned based on product id or pricing group values. For example, you may want to display a schedule of upcoming price changes for a given product in your product experience - use this endpoint to fetch that information from its source of truth in Metronome. \n\nIf you want to understand the rates for a specific customer's contract, inclusive of contract-level overrides, use the `getContractRateSchedule` endpoint.\n", stainlessPath: '(resource) v1.contracts.rateCards > (method) retrieve_rate_schedule', qualified: 'client.v1.contracts.rateCards.retrieveRateSchedule', params: [ 'rate_card_id: string;', 'starting_at: string;', 'limit?: number;', 'next_page?: string;', 'ending_before?: string;', "selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; }[];", ], response: "{ data: { entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: object; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: object; ending_before?: string; pricing_group_values?: object; }[]; next_page?: string; }", markdown: "## retrieve_rate_schedule\n\n`client.v1.contracts.rateCards.retrieveRateSchedule(rate_card_id: string, starting_at: string, limit?: number, next_page?: string, ending_before?: string, selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; }[]): { data: object[]; next_page?: string; }`\n\n**post** `/v1/contract-pricing/rate-cards/getRateSchedule`\n\nA rate card defines the prices that you charge for your products. Rate cards support scheduled changes over time, to allow you to easily roll out pricing changes and new product launches across your customer base. Use this endpoint to understand the rate schedule `starting_at` a given date, optionally filtering the list of rates returned based on product id or pricing group values. For example, you may want to display a schedule of upcoming price changes for a given product in your product experience - use this endpoint to fetch that information from its source of truth in Metronome. \n\nIf you want to understand the rates for a specific customer's contract, inclusive of contract-level overrides, use the `getContractRateSchedule` endpoint.\n\n\n### Parameters\n\n- `rate_card_id: string`\n ID of the rate card to get the schedule for\n\n- `starting_at: string`\n inclusive starting point for the rates schedule\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `ending_before?: string`\n optional exclusive end date for the rates schedule. When not specified rates will show all future schedule segments.\n\n- `selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; }[]`\n List of rate selectors, rates matching ANY of the selector will be included in the response Passing no selectors will result in all rates being returned.\n\n### Returns\n\n- `{ data: { entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: object; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: object; ending_before?: string; pricing_group_values?: object; }[]; next_page?: string; }`\n\n - `data: { entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: object[]; }; ending_before?: string; pricing_group_values?: object; }[]`\n - `next_page?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.rateCards.retrieveRateSchedule({ rate_card_id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe', starting_at: '2024-01-01T00:00:00.000Z' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.retrieveRateSchedule', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.rateCards.retrieveRateSchedule({\n rate_card_id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe',\n starting_at: '2024-01-01T00:00:00.000Z',\n selectors: [\n {\n product_id: 'd6300dbb-882e-4d2d-8dec-5125d16b65d0',\n partial_pricing_group_values: { region: 'us-west-2', cloud: 'aws' },\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.rate_cards.retrieve_rate_schedule', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.rate_cards.retrieve_rate_schedule(\n rate_card_id="f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n starting_at=datetime.fromisoformat("2024-01-01T00:00:00.000"),\n selectors=[{\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0",\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws",\n },\n }],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().rateCards().retrieveRateSchedule', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardRetrieveRateScheduleParams;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardRetrieveRateScheduleResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateCardRetrieveRateScheduleParams params = RateCardRetrieveRateScheduleParams.builder()\n .rateCardId("f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe")\n .startingAt(OffsetDateTime.parse("2024-01-01T00:00:00.000Z"))\n .build();\n RateCardRetrieveRateScheduleResponse response = client.v1().contracts().rateCards().retrieveRateSchedule(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.GetRateSchedule', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.RateCards.GetRateSchedule(context.TODO(), metronome.V1ContractRateCardGetRateScheduleParams{\n\t\tRateCardID: "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n\t\tStartingAt: time.Now(),\n\t\tSelectors: []metronome.V1ContractRateCardGetRateScheduleParamsSelector{{\n\t\t\tProductID: metronome.String("d6300dbb-882e-4d2d-8dec-5125d16b65d0"),\n\t\t\tPartialPricingGroupValues: map[string]string{\n\t\t\t\t"region": "us-west-2",\n\t\t\t\t"cloud": "aws",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.retrieve_rate_schedule', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.rate_cards.retrieve_rate_schedule(\n rate_card_id: "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n starting_at: "2024-01-01T00:00:00.000Z"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/getRateSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "rate_card_id": "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n "starting_at": "2024-01-01T00:00:00.000Z",\n "selectors": [\n {\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws"\n },\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0"\n }\n ]\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/contract-pricing/rate-cards/get', httpMethod: 'post', summary: 'Get a rate card', description: 'Return details for a specific rate card including name, description, and aliases. This endpoint does not return rates - use the dedicated getRates or getRateSchedule endpoints to understand the rates on a rate card.\n', stainlessPath: '(resource) v1.contracts.rateCards > (method) retrieve', qualified: 'client.v1.contracts.rateCards.retrieve', params: ['id: string;'], response: '{ data: { id: string; created_at: string; created_by: string; name: string; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; credit_type_conversions?: { custom_credit_type: credit_type_data; fiat_per_custom_credit: string; }[]; custom_fields?: object; description?: string; fiat_credit_type?: object; }; }', markdown: "## retrieve\n\n`client.v1.contracts.rateCards.retrieve(id: string): { data: object; }`\n\n**post** `/v1/contract-pricing/rate-cards/get`\n\nReturn details for a specific rate card including name, description, and aliases. This endpoint does not return rates - use the dedicated getRates or getRateSchedule endpoints to understand the rates on a rate card.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ data: { id: string; created_at: string; created_by: string; name: string; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; credit_type_conversions?: { custom_credit_type: credit_type_data; fiat_per_custom_credit: string; }[]; custom_fields?: object; description?: string; fiat_credit_type?: object; }; }`\n\n - `data: { id: string; created_at: string; created_by: string; name: string; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; credit_type_conversions?: { custom_credit_type: { id: string; name: string; }; fiat_per_custom_credit: string; }[]; custom_fields?: object; description?: string; fiat_credit_type?: { id: string; name: string; }; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst rateCard = await client.v1.contracts.rateCards.retrieve({ id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe' });\n\nconsole.log(rateCard);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst rateCard = await client.v1.contracts.rateCards.retrieve({\n id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe',\n});\n\nconsole.log(rateCard.data);", }, python: { method: 'v1.contracts.rate_cards.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nrate_card = client.v1.contracts.rate_cards.retrieve(\n id="f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n)\nprint(rate_card.data)', }, java: { method: 'v1().contracts().rateCards().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.Id;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n Id params = Id.builder()\n .id("f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe")\n .build();\n RateCardRetrieveResponse rateCard = client.v1().contracts().rateCards().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\trateCard, err := client.V1.Contracts.RateCards.Get(context.TODO(), metronome.V1ContractRateCardGetParams{\n\t\tID: shared.IDParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", rateCard.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nrate_card = metronome.v1.contracts.rate_cards.retrieve(id: "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe")\n\nputs(rate_card)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/contract-pricing/rate-cards/list', httpMethod: 'post', summary: 'List rate cards', description: 'List all rate cards. Returns rate card IDs, names, descriptions, aliases, and other details. To view the rates associated with a given rate card, use the getRates or getRateSchedule endpoints.\n', stainlessPath: '(resource) v1.contracts.rateCards > (method) list', qualified: 'client.v1.contracts.rateCards.list', params: ['limit?: number;', 'next_page?: string;', 'body?: object;'], response: '{ id: string; created_at: string; created_by: string; name: string; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; credit_type_conversions?: { custom_credit_type: object; fiat_per_custom_credit: string; }[]; custom_fields?: object; description?: string; fiat_credit_type?: { id: string; name: string; }; }', markdown: "## list\n\n`client.v1.contracts.rateCards.list(limit?: number, next_page?: string, body?: object): { id: string; created_at: string; created_by: string; name: string; aliases?: object[]; credit_type_conversions?: object[]; custom_fields?: object; description?: string; fiat_credit_type?: credit_type_data; }`\n\n**post** `/v1/contract-pricing/rate-cards/list`\n\nList all rate cards. Returns rate card IDs, names, descriptions, aliases, and other details. To view the rates associated with a given rate card, use the getRates or getRateSchedule endpoints.\n\n\n### Parameters\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `body?: object`\n\n### Returns\n\n- `{ id: string; created_at: string; created_by: string; name: string; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; credit_type_conversions?: { custom_credit_type: object; fiat_per_custom_credit: string; }[]; custom_fields?: object; description?: string; fiat_credit_type?: { id: string; name: string; }; }`\n\n - `id: string`\n - `created_at: string`\n - `created_by: string`\n - `name: string`\n - `aliases?: { name: string; ending_before?: string; starting_at?: string; }[]`\n - `credit_type_conversions?: { custom_credit_type: { id: string; name: string; }; fiat_per_custom_credit: string; }[]`\n - `custom_fields?: object`\n - `description?: string`\n - `fiat_credit_type?: { id: string; name: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const rateCardListResponse of client.v1.contracts.rateCards.list()) {\n console.log(rateCardListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const rateCardListResponse of client.v1.contracts.rateCards.list()) {\n console.log(rateCardListResponse.id);\n}", }, python: { method: 'v1.contracts.rate_cards.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.contracts.rate_cards.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().contracts().rateCards().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardListPage;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateCardListPage page = client.v1().contracts().rateCards().list();\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Contracts.RateCards.List(context.TODO(), metronome.V1ContractRateCardListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.contracts.rate_cards.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/list \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'create', endpoint: '/v1/contract-pricing/rate-cards/create', httpMethod: 'post', summary: 'Create a rate card', description: "In Metronome, the rate card is the central location for your pricing. Rate cards were built with new product launches and pricing changes in mind - you can update your products and pricing in one place, and that change will be automatically propagated across your customer cohorts. Most clients need only maintain one or a few rate cards within Metronome.\n\n### Use this endpoint to:\n- Create a rate card with a name and description\n- Define the rate card's single underlying fiat currency, and any number of conversion rates between that fiat currency and custom pricing units. You can then add products and associated rates in the fiat currency or custom pricing unit for which you have defined a conversion rate. \n- Set aliases for the rate card. Aliases are human-readable names that you can use in the place of the id of the rate card when provisioning a customer's contract. By using an alias, you can easily create a contract and provision a customer by choosing the paygo rate card, without storing the rate card id in your internal systems. This is helpful when launching a new rate card for paygo customers, you can update the alias for paygo to be scheduled to be assigned to the new rate card without updating your code.\n\n### Key response fields:\n- The ID of the rate card you just created\n\n### Usage guidelines:\n- After creating a rate card, you can now use the addRate or addRates endpoints to add products and their prices to it\n- A rate card alias can only be used by one rate card at a time. If you create a contract with a rate card alias that is already in use by another rate card, the original rate card's alias schedule will be updated. The alias will reference the rate card to which it was most recently assigned.\n", stainlessPath: '(resource) v1.contracts.rateCards > (method) create', qualified: 'client.v1.contracts.rateCards.create', params: [ 'name: string;', 'aliases?: { name: string; ending_before?: string; starting_at?: string; }[];', 'credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[];', 'custom_fields?: object;', 'description?: string;', 'fiat_credit_type_id?: string;', ], response: '{ data: { id: string; }; }', markdown: '## create\n\n`client.v1.contracts.rateCards.create(name: string, aliases?: { name: string; ending_before?: string; starting_at?: string; }[], credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[], custom_fields?: object, description?: string, fiat_credit_type_id?: string): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/create`\n\nIn Metronome, the rate card is the central location for your pricing. Rate cards were built with new product launches and pricing changes in mind - you can update your products and pricing in one place, and that change will be automatically propagated across your customer cohorts. Most clients need only maintain one or a few rate cards within Metronome.\n\n### Use this endpoint to:\n- Create a rate card with a name and description\n- Define the rate card\'s single underlying fiat currency, and any number of conversion rates between that fiat currency and custom pricing units. You can then add products and associated rates in the fiat currency or custom pricing unit for which you have defined a conversion rate. \n- Set aliases for the rate card. Aliases are human-readable names that you can use in the place of the id of the rate card when provisioning a customer\'s contract. By using an alias, you can easily create a contract and provision a customer by choosing the paygo rate card, without storing the rate card id in your internal systems. This is helpful when launching a new rate card for paygo customers, you can update the alias for paygo to be scheduled to be assigned to the new rate card without updating your code.\n\n### Key response fields:\n- The ID of the rate card you just created\n\n### Usage guidelines:\n- After creating a rate card, you can now use the addRate or addRates endpoints to add products and their prices to it\n- A rate card alias can only be used by one rate card at a time. If you create a contract with a rate card alias that is already in use by another rate card, the original rate card\'s alias schedule will be updated. The alias will reference the rate card to which it was most recently assigned.\n\n\n### Parameters\n\n- `name: string`\n Used only in UI/API. It is not exposed to end customers.\n\n- `aliases?: { name: string; ending_before?: string; starting_at?: string; }[]`\n Reference this alias when creating a contract. If the same alias is assigned to multiple rate cards, it will reference the rate card to which it was most recently assigned. It is not exposed to end customers.\n\n- `credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[]`\n Required when using custom pricing units in rates.\n\n- `custom_fields?: object`\n Custom fields to be added eg. { "key1": "value1", "key2": "value2" }\n\n- `description?: string`\n\n- `fiat_credit_type_id?: string`\n The Metronome ID of the credit type to associate with the rate card, defaults to USD (cents) if not passed.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from \'@metronome/sdk\';\n\nconst client = new Metronome();\n\nconst rateCard = await client.v1.contracts.rateCards.create({ name: \'My Rate Card\' });\n\nconsole.log(rateCard);\n```', perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst rateCard = await client.v1.contracts.rateCards.create({\n name: 'My Rate Card',\n aliases: [{ name: 'my-rate-card' }],\n credit_type_conversions: [\n { custom_credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2', fiat_per_custom_credit: 2 },\n ],\n description: 'My Rate Card Description',\n fiat_credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n});\n\nconsole.log(rateCard.data);", }, python: { method: 'v1.contracts.rate_cards.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nrate_card = client.v1.contracts.rate_cards.create(\n name="My Rate Card",\n aliases=[{\n "name": "my-rate-card"\n }],\n credit_type_conversions=[{\n "custom_credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "fiat_per_custom_credit": 2,\n }],\n description="My Rate Card Description",\n fiat_credit_type_id="2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n)\nprint(rate_card.data)', }, java: { method: 'v1().contracts().rateCards().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardCreateParams;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateCardCreateParams params = RateCardCreateParams.builder()\n .name("My Rate Card")\n .build();\n RateCardCreateResponse rateCard = client.v1().contracts().rateCards().create(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\trateCard, err := client.V1.Contracts.RateCards.New(context.TODO(), metronome.V1ContractRateCardNewParams{\n\t\tName: "My Rate Card",\n\t\tAliases: []metronome.V1ContractRateCardNewParamsAlias{{\n\t\t\tName: "my-rate-card",\n\t\t}},\n\t\tCreditTypeConversions: []metronome.V1ContractRateCardNewParamsCreditTypeConversion{{\n\t\t\tCustomCreditTypeID: "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n\t\t\tFiatPerCustomCredit: 2,\n\t\t}},\n\t\tDescription: metronome.String("My Rate Card Description"),\n\t\tFiatCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", rateCard.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nrate_card = metronome.v1.contracts.rate_cards.create(name: "My Rate Card")\n\nputs(rate_card)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "My Rate Card",\n "aliases": [\n {\n "name": "my-rate-card"\n }\n ],\n "credit_type_conversions": [\n {\n "custom_credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "fiat_per_custom_credit": 2\n }\n ],\n "description": "My Rate Card Description",\n "fiat_credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/contract-pricing/rate-cards/update', httpMethod: 'post', summary: 'Update a rate card', description: 'Update a rate card\'s name, description, aliases, and credit type conversion rates. This endpoint does not affect underlying pricing rates or schedules.\n\n### Use this endpoint to:\n- Rename rate cards: Update display names or descriptions for organizational clarity\n- Manage aliases: Add, modify, or schedule alias transitions for seamless and code-free rate card migrations\n- Update documentation: Keep rate card descriptions current with business context\n- Configure custom pricing units: Add credit type conversions to enable rates with different pricing units\n\n#### Active contract impact:\n- Alias changes: Already-created contracts continue using their originally assigned rate cards.\n- Other changes made using this endpoint will only impact the Metronome UI.\n\n#### Grandfathering existing PLG customer pricing:\n- Rate card aliases support scheduled transitions, enabling seamless rate card migrations for new customers, allowing existing customers to be grandfathered into their existing prices without code. Note that there are multiple mechanisms to support grandfathering in Metronome. \n\n#### How scheduled aliases work for PLG grandfathering:\nInitial setup:\n- Add alias to current rate card: Assign a stable alias (e.g., "standard-pricing") to your active rate card\n- Reference alias during contract creation: Configure your self-serve workflow to create contracts using `rate_card_alias` instead of direct `rate_card_id`\n- Automatic resolution: New contracts referencing the alias automatically resolve to the rate card associated with the alias at the point in time of provisioning\n\n#### Grandfathering process:\n- Create new rate card: Build your new rate card with updated pricing structure\n- Schedule alias transition: Add the same alias to the new rate card with a `starting_at` timestamp\n- Automatic cutover: Starting at the scheduled time, new contracts created in your PLG workflow using that alias will automatically reference the new rate card\n', stainlessPath: '(resource) v1.contracts.rateCards > (method) update', qualified: 'client.v1.contracts.rateCards.update', params: [ 'rate_card_id: string;', 'add_credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[];', 'aliases?: { name: string; ending_before?: string; starting_at?: string; }[];', 'description?: string;', 'name?: string;', ], response: '{ data: { id: string; }; }', markdown: "## update\n\n`client.v1.contracts.rateCards.update(rate_card_id: string, add_credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[], aliases?: { name: string; ending_before?: string; starting_at?: string; }[], description?: string, name?: string): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/update`\n\nUpdate a rate card's name, description, aliases, and credit type conversion rates. This endpoint does not affect underlying pricing rates or schedules.\n\n### Use this endpoint to:\n- Rename rate cards: Update display names or descriptions for organizational clarity\n- Manage aliases: Add, modify, or schedule alias transitions for seamless and code-free rate card migrations\n- Update documentation: Keep rate card descriptions current with business context\n- Configure custom pricing units: Add credit type conversions to enable rates with different pricing units\n\n#### Active contract impact:\n- Alias changes: Already-created contracts continue using their originally assigned rate cards.\n- Other changes made using this endpoint will only impact the Metronome UI.\n\n#### Grandfathering existing PLG customer pricing:\n- Rate card aliases support scheduled transitions, enabling seamless rate card migrations for new customers, allowing existing customers to be grandfathered into their existing prices without code. Note that there are multiple mechanisms to support grandfathering in Metronome. \n\n#### How scheduled aliases work for PLG grandfathering:\nInitial setup:\n- Add alias to current rate card: Assign a stable alias (e.g., \"standard-pricing\") to your active rate card\n- Reference alias during contract creation: Configure your self-serve workflow to create contracts using `rate_card_alias` instead of direct `rate_card_id`\n- Automatic resolution: New contracts referencing the alias automatically resolve to the rate card associated with the alias at the point in time of provisioning\n\n#### Grandfathering process:\n- Create new rate card: Build your new rate card with updated pricing structure\n- Schedule alias transition: Add the same alias to the new rate card with a `starting_at` timestamp\n- Automatic cutover: Starting at the scheduled time, new contracts created in your PLG workflow using that alias will automatically reference the new rate card\n\n\n### Parameters\n\n- `rate_card_id: string`\n ID of the rate card to update\n\n- `add_credit_type_conversions?: { custom_credit_type_id: string; fiat_per_custom_credit: number; }[]`\n Add credit type conversions for using custom pricing units in rates. Existing conversions cannot be modified.\n\n- `aliases?: { name: string; ending_before?: string; starting_at?: string; }[]`\n Reference this alias when creating a contract. If the same alias is assigned to multiple rate cards, it will reference the rate card to which it was most recently assigned. It is not exposed to end customers.\n\n- `description?: string`\n\n- `name?: string`\n Used only in UI/API. It is not exposed to end customers.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst rateCard = await client.v1.contracts.rateCards.update({ rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(rateCard);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst rateCard = await client.v1.contracts.rateCards.update({\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n description: 'My Updated Rate Card Description',\n name: 'My Updated Rate Card',\n});\n\nconsole.log(rateCard.data);", }, python: { method: 'v1.contracts.rate_cards.update', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nrate_card = client.v1.contracts.rate_cards.update(\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n description="My Updated Rate Card Description",\n name="My Updated Rate Card",\n)\nprint(rate_card.data)', }, java: { method: 'v1().contracts().rateCards().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardUpdateParams;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardUpdateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateCardUpdateParams params = RateCardUpdateParams.builder()\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n RateCardUpdateResponse rateCard = client.v1().contracts().rateCards().update(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Update', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\trateCard, err := client.V1.Contracts.RateCards.Update(context.TODO(), metronome.V1ContractRateCardUpdateParams{\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tDescription: metronome.String("My Updated Rate Card Description"),\n\t\tName: metronome.String("My Updated Rate Card"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", rateCard.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nrate_card = metronome.v1.contracts.rate_cards.update(rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(rate_card)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/update \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "description": "My Updated Rate Card Description",\n "name": "My Updated Rate Card"\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/contract-pricing/rate-cards/archive', httpMethod: 'post', summary: 'Archive a rate card', description: 'Permanently disable a rate card by archiving it, preventing use in new contracts while preserving existing contract pricing. Use this when retiring old pricing models, consolidating rate cards, or removing outdated pricing structures. Returns the archived rate card ID and stops the rate card from appearing in contract creation workflows.\n', stainlessPath: '(resource) v1.contracts.rateCards > (method) archive', qualified: 'client.v1.contracts.rateCards.archive', params: ['id: string;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.contracts.rateCards.archive(id: string): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/archive`\n\nPermanently disable a rate card by archiving it, preventing use in new contracts while preserving existing contract pricing. Use this when retiring old pricing models, consolidating rate cards, or removing outdated pricing structures. Returns the archived rate card ID and stops the rate card from appearing in contract creation workflows.\n\n\n### Parameters\n\n- `id: string`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.rateCards.archive({ id: '12b21470-4570-40df-8998-449d0b0bc52f' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.rateCards.archive({\n id: '12b21470-4570-40df-8998-449d0b0bc52f',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.rate_cards.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.rate_cards.archive(\n id="12b21470-4570-40df-8998-449d0b0bc52f",\n)\nprint(response.data)', }, java: { method: 'v1().contracts().rateCards().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.Id;\nimport com.metronome.api.models.v1.contracts.ratecards.RateCardArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n Id params = Id.builder()\n .id("12b21470-4570-40df-8998-449d0b0bc52f")\n .build();\n RateCardArchiveResponse response = client.v1().contracts().rateCards().archive(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n\t"github.com/Metronome-Industries/metronome-go/shared"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.RateCards.Archive(context.TODO(), metronome.V1ContractRateCardArchiveParams{\n\t\tID: shared.IDParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.rate_cards.archive(id: "12b21470-4570-40df-8998-449d0b0bc52f")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "id": "12b21470-4570-40df-8998-449d0b0bc52f"\n }\'', }, }, }, { name: 'set', endpoint: '/v1/contract-pricing/rate-cards/setRateCardProductsOrder', httpMethod: 'post', summary: 'Set the rate card products order', description: "The ordering of products on a rate card determines the order in which the products will appear on customers' invoices. Use this endpoint to set the order of products on the rate card.\n", stainlessPath: '(resource) v1.contracts.rateCards.product_orders > (method) set', qualified: 'client.v1.contracts.rateCards.productOrders.set', params: ['product_order: string[];', 'rate_card_id: string;'], response: '{ data: { id: string; }; }', markdown: "## set\n\n`client.v1.contracts.rateCards.productOrders.set(product_order: string[], rate_card_id: string): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/setRateCardProductsOrder`\n\nThe ordering of products on a rate card determines the order in which the products will appear on customers' invoices. Use this endpoint to set the order of products on the rate card.\n\n\n### Parameters\n\n- `product_order: string[]`\n\n- `rate_card_id: string`\n ID of the rate card to update\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.rateCards.productOrders.set({ product_order: ['13117714-3f05-48e5-a6e9-a66093f13b4d', 'b086f2f4-9851-4466-9ca0-30d53e6a42ac'], rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.productOrders.set', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.rateCards.productOrders.set({\n product_order: ['13117714-3f05-48e5-a6e9-a66093f13b4d', 'b086f2f4-9851-4466-9ca0-30d53e6a42ac'],\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.rate_cards.product_orders.set', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.rate_cards.product_orders.set(\n product_order=["13117714-3f05-48e5-a6e9-a66093f13b4d", "b086f2f4-9851-4466-9ca0-30d53e6a42ac"],\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(response.data)', }, java: { method: 'v1().contracts().rateCards().productOrders().set', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.productorders.ProductOrderSetParams;\nimport com.metronome.api.models.v1.contracts.ratecards.productorders.ProductOrderSetResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductOrderSetParams params = ProductOrderSetParams.builder()\n .addProductOrder("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .addProductOrder("b086f2f4-9851-4466-9ca0-30d53e6a42ac")\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n ProductOrderSetResponse response = client.v1().contracts().rateCards().productOrders().set(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.ProductOrders.Set', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.RateCards.ProductOrders.Set(context.TODO(), metronome.V1ContractRateCardProductOrderSetParams{\n\t\tProductOrder: []string{"13117714-3f05-48e5-a6e9-a66093f13b4d", "b086f2f4-9851-4466-9ca0-30d53e6a42ac"},\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.product_orders.set', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.rate_cards.product_orders.set(\n product_order: ["13117714-3f05-48e5-a6e9-a66093f13b4d", "b086f2f4-9851-4466-9ca0-30d53e6a42ac"],\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/setRateCardProductsOrder \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "product_order": [\n "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "b086f2f4-9851-4466-9ca0-30d53e6a42ac"\n ],\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/contract-pricing/rate-cards/moveRateCardProducts', httpMethod: 'post', summary: 'Update the rate card products order', description: "The ordering of products on a rate card determines the order in which the products will appear on customers' invoices. Use this endpoint to set the order of specific products on the rate card by moving them relative to their current location.\n", stainlessPath: '(resource) v1.contracts.rateCards.product_orders > (method) update', qualified: 'client.v1.contracts.rateCards.productOrders.update', params: ['product_moves: { position: number; product_id: string; }[];', 'rate_card_id: string;'], response: '{ data: { id: string; }; }', markdown: "## update\n\n`client.v1.contracts.rateCards.productOrders.update(product_moves: { position: number; product_id: string; }[], rate_card_id: string): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/moveRateCardProducts`\n\nThe ordering of products on a rate card determines the order in which the products will appear on customers' invoices. Use this endpoint to set the order of specific products on the rate card by moving them relative to their current location.\n\n\n### Parameters\n\n- `product_moves: { position: number; product_id: string; }[]`\n\n- `rate_card_id: string`\n ID of the rate card to update\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst productOrder = await client.v1.contracts.rateCards.productOrders.update({ product_moves: [{ position: 0, product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' }, { position: 1, product_id: 'b086f2f4-9851-4466-9ca0-30d53e6a42ac' }], rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(productOrder);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.productOrders.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst productOrder = await client.v1.contracts.rateCards.productOrders.update({\n product_moves: [\n { product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', position: 0 },\n { product_id: 'b086f2f4-9851-4466-9ca0-30d53e6a42ac', position: 1 },\n ],\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(productOrder.data);", }, python: { method: 'v1.contracts.rate_cards.product_orders.update', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nproduct_order = client.v1.contracts.rate_cards.product_orders.update(\n product_moves=[{\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "position": 0,\n }, {\n "product_id": "b086f2f4-9851-4466-9ca0-30d53e6a42ac",\n "position": 1,\n }],\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(product_order.data)', }, java: { method: 'v1().contracts().rateCards().productOrders().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.productorders.ProductOrderUpdateParams;\nimport com.metronome.api.models.v1.contracts.ratecards.productorders.ProductOrderUpdateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n ProductOrderUpdateParams params = ProductOrderUpdateParams.builder()\n .addProductMove(ProductOrderUpdateParams.ProductMove.builder()\n .position(0.0)\n .productId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build())\n .addProductMove(ProductOrderUpdateParams.ProductMove.builder()\n .position(1.0)\n .productId("b086f2f4-9851-4466-9ca0-30d53e6a42ac")\n .build())\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n ProductOrderUpdateResponse productOrder = client.v1().contracts().rateCards().productOrders().update(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.ProductOrders.Update', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tproductOrder, err := client.V1.Contracts.RateCards.ProductOrders.Update(context.TODO(), metronome.V1ContractRateCardProductOrderUpdateParams{\n\t\tProductMoves: []metronome.V1ContractRateCardProductOrderUpdateParamsProductMove{{\n\t\t\tProductID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\t\tPosition: 0,\n\t\t}, {\n\t\t\tProductID: "b086f2f4-9851-4466-9ca0-30d53e6a42ac",\n\t\t\tPosition: 1,\n\t\t}},\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", productOrder.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.product_orders.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nproduct_order = metronome.v1.contracts.rate_cards.product_orders.update(\n product_moves: [\n {position: 0, product_id: "13117714-3f05-48e5-a6e9-a66093f13b4d"},\n {position: 1, product_id: "b086f2f4-9851-4466-9ca0-30d53e6a42ac"}\n ],\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n)\n\nputs(product_order)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/moveRateCardProducts \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "product_moves": [\n {\n "position": 0,\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n },\n {\n "position": 1,\n "product_id": "b086f2f4-9851-4466-9ca0-30d53e6a42ac"\n }\n ],\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/contract-pricing/rate-cards/getRates', httpMethod: 'post', summary: 'Get rates', description: "Understand the rate schedule at a given timestamp, optionally filtering the list of rates returned based on properties such as `product_id` and `pricing_group_values`. For example, you may want to display the current price for a given product in your product experience - use this endpoint to fetch that information from its source of truth in Metronome. \n\nIf you want to understand the rates for a specific customer's contract, inclusive of contract-level overrides, use the `getContractRateSchedule` endpoint.\n", stainlessPath: '(resource) v1.contracts.rateCards.rates > (method) list', qualified: 'client.v1.contracts.rateCards.rates.list', params: [ 'at: string;', 'rate_card_id: string;', 'limit?: number;', 'next_page?: string;', "selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[];", ], response: "{ entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: tier[]; }; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: tier[]; }; ending_before?: string; pricing_group_values?: object; }", markdown: "## list\n\n`client.v1.contracts.rateCards.rates.list(at: string, rate_card_id: string, limit?: number, next_page?: string, selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]): { entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: rate; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: commit_rate; ending_before?: string; pricing_group_values?: object; }`\n\n**post** `/v1/contract-pricing/rate-cards/getRates`\n\nUnderstand the rate schedule at a given timestamp, optionally filtering the list of rates returned based on properties such as `product_id` and `pricing_group_values`. For example, you may want to display the current price for a given product in your product experience - use this endpoint to fetch that information from its source of truth in Metronome. \n\nIf you want to understand the rates for a specific customer's contract, inclusive of contract-level overrides, use the `getContractRateSchedule` endpoint.\n\n\n### Parameters\n\n- `at: string`\n inclusive starting point for the rates schedule\n\n- `rate_card_id: string`\n ID of the rate card to get the schedule for\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `selectors?: { billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; partial_pricing_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]`\n List of rate selectors, rates matching ANY of the selector will be included in the response Passing no selectors will result in all rates being returned.\n\n### Returns\n\n- `{ entitled: boolean; product_custom_fields: object; product_id: string; product_name: string; product_tags: string[]; rate: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: tier[]; }; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: tier[]; }; ending_before?: string; pricing_group_values?: object; }`\n\n - `entitled: boolean`\n - `product_custom_fields: object`\n - `product_id: string`\n - `product_name: string`\n - `product_tags: string[]`\n - `rate: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; credit_type?: { id: string; name: string; }; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: { price: number; size?: number; }[]; }`\n - `starting_at: string`\n - `billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'`\n - `commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: { price: number; size?: number; }[]; }`\n - `ending_before?: string`\n - `pricing_group_values?: object`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const rateListResponse of client.v1.contracts.rateCards.rates.list({ at: '2024-01-01T00:00:00.000Z', rate_card_id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe' })) {\n console.log(rateListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.rates.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const rateListResponse of client.v1.contracts.rateCards.rates.list({\n at: '2024-01-01T00:00:00.000Z',\n rate_card_id: 'f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe',\n selectors: [\n {\n product_id: 'd6300dbb-882e-4d2d-8dec-5125d16b65d0',\n partial_pricing_group_values: { region: 'us-west-2', cloud: 'aws' },\n },\n ],\n})) {\n console.log(rateListResponse.product_id);\n}", }, python: { method: 'v1.contracts.rate_cards.rates.list', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.contracts.rate_cards.rates.list(\n at=datetime.fromisoformat("2024-01-01T00:00:00.000"),\n rate_card_id="f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n selectors=[{\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0",\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws",\n },\n }],\n)\npage = page.data[0]\nprint(page.product_id)', }, java: { method: 'v1().contracts().rateCards().rates().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateListPage;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateListParams;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateListParams params = RateListParams.builder()\n .at(OffsetDateTime.parse("2024-01-01T00:00:00.000Z"))\n .rateCardId("f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe")\n .build();\n RateListPage page = client.v1().contracts().rateCards().rates().list(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Rates.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Contracts.RateCards.Rates.List(context.TODO(), metronome.V1ContractRateCardRateListParams{\n\t\tAt: time.Now(),\n\t\tRateCardID: "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n\t\tSelectors: []metronome.V1ContractRateCardRateListParamsSelector{{\n\t\t\tProductID: metronome.String("d6300dbb-882e-4d2d-8dec-5125d16b65d0"),\n\t\t\tPartialPricingGroupValues: map[string]string{\n\t\t\t\t"region": "us-west-2",\n\t\t\t\t"cloud": "aws",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.rates.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.contracts.rate_cards.rates.list(\n at: "2024-01-01T00:00:00.000Z",\n rate_card_id: "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe"\n)\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/getRates \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "at": "2024-01-01T00:00:00.000Z",\n "rate_card_id": "f3d51ae8-f283-44e1-9933-a3cf9ad7a6fe",\n "selectors": [\n {\n "partial_pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws"\n },\n "product_id": "d6300dbb-882e-4d2d-8dec-5125d16b65d0"\n }\n ]\n }\'', }, }, }, { name: 'add', endpoint: '/v1/contract-pricing/rate-cards/addRate', httpMethod: 'post', summary: 'Add a rate', description: 'Add a new rate\n\nThis endpoint is heavily rate limited. For adding multiple rates, using the [addRates](https://docs.metronome.com/api-reference/rate-cards/add-rates) endpoint is strongly encouraged.\n', stainlessPath: '(resource) v1.contracts.rateCards.rates > (method) add', qualified: 'client.v1.contracts.rateCards.rates.add', params: [ 'entitled: boolean;', 'product_id: string;', 'rate_card_id: string;', "rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM';", 'starting_at: string;', "billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY';", "commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: { price: number; size?: number; }[]; };", 'credit_type_id?: string;', 'custom_rate?: object;', 'ending_before?: string;', 'is_prorated?: boolean;', 'price?: number;', 'pricing_group_values?: object;', 'quantity?: number;', 'tiers?: { price: number; size?: number; }[];', ], response: "{ data: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; commit_rate?: object; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; }", markdown: "## add\n\n`client.v1.contracts.rateCards.rates.add(entitled: boolean, product_id: string, rate_card_id: string, rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM', starting_at: string, billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY', commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: tier[]; }, credit_type_id?: string, custom_rate?: object, ending_before?: string, is_prorated?: boolean, price?: number, pricing_group_values?: object, quantity?: number, tiers?: { price: number; size?: number; }[]): { data: object; }`\n\n**post** `/v1/contract-pricing/rate-cards/addRate`\n\nAdd a new rate\n\nThis endpoint is heavily rate limited. For adding multiple rates, using the [addRates](https://docs.metronome.com/api-reference/rate-cards/add-rates) endpoint is strongly encouraged.\n\n\n### Parameters\n\n- `entitled: boolean`\n\n- `product_id: string`\n ID of the product to add a rate for\n\n- `rate_card_id: string`\n ID of the rate card to update\n\n- `rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'`\n\n- `starting_at: string`\n inclusive effective date\n\n- `billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'`\n Optional. Frequency to bill subscriptions with. Required for subscription type products with Flat rate.\n\n- `commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: { price: number; size?: number; }[]; }`\n A distinct rate on the rate card. You can choose to use this rate rather than list rate when consuming a credit or commit.\n - `rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'`\n - `price?: number`\n Commit rate price. For FLAT rate_type, this must be >=0. For PERCENTAGE rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 and <=1.\n - `tiers?: { price: number; size?: number; }[]`\n Only set for TIERED rate_type.\n\n- `credit_type_id?: string`\n The Metronome ID of the credit type to associate with price, defaults to USD (cents) if not passed. Used by all rate_types except type PERCENTAGE. PERCENTAGE rates use the credit type of associated rates.\n\n- `custom_rate?: object`\n Only set for CUSTOM rate_type. This field is interpreted by custom rate processors.\n\n- `ending_before?: string`\n exclusive end date\n\n- `is_prorated?: boolean`\n Default proration configuration. Only valid for SUBSCRIPTION rate_type. Must be set to true.\n\n- `price?: number`\n Default price. For FLAT and SUBSCRIPTION rate_type, this must be >=0. For PERCENTAGE rate_type, this is a decimal fraction, e.g. use 0.1 for 10%; this must be >=0 and <=1.\n\n- `pricing_group_values?: object`\n Optional. List of pricing group key value pairs which will be used to calculate the price.\n\n- `quantity?: number`\n Default quantity. For SUBSCRIPTION rate_type, this must be >=0.\n\n- `tiers?: { price: number; size?: number; }[]`\n Only set for TIERED rate_type.\n\n### Returns\n\n- `{ data: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; commit_rate?: object; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }; }`\n\n - `data: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'CUSTOM' | 'TIERED' | 'TIERED_PERCENTAGE'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: object[]; }; credit_type?: { id: string; name: string; }; custom_rate?: object; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: { price: number; size?: number; }[]; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.rateCards.rates.add({\n entitled: true,\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n rate_type: 'FLAT',\n starting_at: '2020-01-01T00:00:00.000Z',\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.rates.add', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.rateCards.rates.add({\n entitled: true,\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n rate_type: 'FLAT',\n starting_at: '2020-01-01T00:00:00.000Z',\n credit_type_id: '2714e483-4ff1-48e4-9e25-ac732e8f24f2',\n price: 100,\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.rate_cards.rates.add', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.rate_cards.rates.add(\n entitled=True,\n product_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n rate_type="FLAT",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n credit_type_id="2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n price=100,\n)\nprint(response.data)', }, java: { method: 'v1().contracts().rateCards().rates().add', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateAddParams;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateAddResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateAddParams params = RateAddParams.builder()\n .entitled(true)\n .productId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .rateType(RateAddParams.RateType.FLAT)\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\n RateAddResponse response = client.v1().contracts().rateCards().rates().add(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Rates.Add', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.RateCards.Rates.Add(context.TODO(), metronome.V1ContractRateCardRateAddParams{\n\t\tEntitled: true,\n\t\tProductID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tRateType: metronome.V1ContractRateCardRateAddParamsRateTypeFlat,\n\t\tStartingAt: time.Now(),\n\t\tCreditTypeID: metronome.String("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),\n\t\tPrice: metronome.Float(100),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.rates.add', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.rate_cards.rates.add(\n entitled: true,\n product_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n rate_type: :FLAT,\n starting_at: "2020-01-01T00:00:00.000Z"\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/addRate \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "entitled": true,\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "rate_type": "FLAT",\n "starting_at": "2020-01-01T00:00:00.000Z",\n "credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",\n "price": 100\n }\'', }, }, }, { name: 'addMany', endpoint: '/v1/contract-pricing/rate-cards/addRates', httpMethod: 'post', summary: 'Add rates', description: 'Add new rates\n', stainlessPath: '(resource) v1.contracts.rateCards.rates > (method) addMany', qualified: 'client.v1.contracts.rateCards.rates.addMany', params: [ 'rate_card_id: string;', "rates: { entitled: boolean; product_id: string; rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: object[]; }; credit_type_id?: string; custom_rate?: object; ending_before?: string; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: { price: number; size?: number; }[]; }[];", ], response: '{ data: { id: string; }; }', markdown: "## addMany\n\n`client.v1.contracts.rateCards.rates.addMany(rate_card_id: string, rates: { entitled: boolean; product_id: string; rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: object; credit_type_id?: string; custom_rate?: object; ending_before?: string; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: object[]; }[]): { data: id; }`\n\n**post** `/v1/contract-pricing/rate-cards/addRates`\n\nAdd new rates\n\n\n### Parameters\n\n- `rate_card_id: string`\n\n- `rates: { entitled: boolean; product_id: string; rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; starting_at: string; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; price?: number; tiers?: object[]; }; credit_type_id?: string; custom_rate?: object; ending_before?: string; is_prorated?: boolean; price?: number; pricing_group_values?: object; quantity?: number; tiers?: { price: number; size?: number; }[]; }[]`\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.contracts.rateCards.rates.addMany({ rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', rates: [{\n entitled: true,\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n rate_type: 'FLAT',\n starting_at: '2020-01-01T00:00:00.000Z',\n}, {\n entitled: true,\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n rate_type: 'FLAT',\n starting_at: '2020-01-01T00:00:00.000Z',\n}] });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.rates.addMany', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.contracts.rateCards.rates.addMany({\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n rates: [\n {\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n entitled: true,\n rate_type: 'FLAT',\n price: 100,\n pricing_group_values: { region: 'us-west-2', cloud: 'aws' },\n },\n {\n product_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n entitled: true,\n rate_type: 'FLAT',\n price: 120,\n pricing_group_values: { region: 'us-east-2', cloud: 'aws' },\n },\n ],\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.contracts.rate_cards.rates.add_many', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.contracts.rate_cards.rates.add_many(\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n rates=[{\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "starting_at": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "entitled": True,\n "rate_type": "FLAT",\n "price": 100,\n "pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws",\n },\n }, {\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "starting_at": datetime.fromisoformat("2020-01-01T00:00:00.000"),\n "entitled": True,\n "rate_type": "FLAT",\n "price": 120,\n "pricing_group_values": {\n "region": "us-east-2",\n "cloud": "aws",\n },\n }],\n)\nprint(response.data)', }, java: { method: 'v1().contracts().rateCards().rates().addMany', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateAddManyParams;\nimport com.metronome.api.models.v1.contracts.ratecards.rates.RateAddManyResponse;\nimport java.time.OffsetDateTime;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n RateAddManyParams params = RateAddManyParams.builder()\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .addRate(RateAddManyParams.Rate.builder()\n .entitled(true)\n .productId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .rateType(RateAddManyParams.Rate.RateType.FLAT)\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build())\n .addRate(RateAddManyParams.Rate.builder()\n .entitled(true)\n .productId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .rateType(RateAddManyParams.Rate.RateType.FLAT)\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build())\n .build();\n RateAddManyResponse response = client.v1().contracts().rateCards().rates().addMany(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.Rates.AddMany', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Contracts.RateCards.Rates.AddMany(context.TODO(), metronome.V1ContractRateCardRateAddManyParams{\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tRates: []metronome.V1ContractRateCardRateAddManyParamsRate{{\n\t\t\tProductID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\t\tStartingAt: time.Now(),\n\t\t\tEntitled: true,\n\t\t\tRateType: "FLAT",\n\t\t\tPrice: metronome.Float(100),\n\t\t\tPricingGroupValues: map[string]string{\n\t\t\t\t"region": "us-west-2",\n\t\t\t\t"cloud": "aws",\n\t\t\t},\n\t\t}, {\n\t\t\tProductID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\t\tStartingAt: time.Now(),\n\t\t\tEntitled: true,\n\t\t\tRateType: "FLAT",\n\t\t\tPrice: metronome.Float(120),\n\t\t\tPricingGroupValues: map[string]string{\n\t\t\t\t"region": "us-east-2",\n\t\t\t\t"cloud": "aws",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.rates.add_many', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.contracts.rate_cards.rates.add_many(\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n rates: [\n {\n entitled: true,\n product_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n rate_type: :FLAT,\n starting_at: "2020-01-01T00:00:00.000Z"\n },\n {\n entitled: true,\n product_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n rate_type: :FLAT,\n starting_at: "2020-01-01T00:00:00.000Z"\n }\n ]\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/addRates \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "rates": [\n {\n "entitled": true,\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "rate_type": "FLAT",\n "starting_at": "2020-01-01T00:00:00.000Z",\n "price": 100,\n "pricing_group_values": {\n "region": "us-west-2",\n "cloud": "aws"\n }\n },\n {\n "entitled": true,\n "product_id": "13117714-3f05-48e5-a6e9-a66093f13b4d",\n "rate_type": "FLAT",\n "starting_at": "2020-01-01T00:00:00.000Z",\n "price": 120,\n "pricing_group_values": {\n "region": "us-east-2",\n "cloud": "aws"\n }\n }\n ]\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/contracts/getNamedSchedule', httpMethod: 'post', summary: "Get a contract's named schedule", description: "Get a named schedule for the given contract. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.contracts.rateCards.named_schedules > (method) retrieve', qualified: 'client.v1.contracts.rateCards.namedSchedules.retrieve', params: [ 'contract_id: string;', 'customer_id: string;', 'schedule_name: string;', 'covering_date?: string;', ], response: '{ data: { starting_at: string; value: object; ending_before?: string; }[]; }', markdown: "## retrieve\n\n`client.v1.contracts.rateCards.namedSchedules.retrieve(contract_id: string, customer_id: string, schedule_name: string, covering_date?: string): { data: object[]; }`\n\n**post** `/v1/contracts/getNamedSchedule`\n\nGet a named schedule for the given contract. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract whose named schedule is to be retrieved\n\n- `customer_id: string`\n ID of the customer whose named schedule is to be retrieved\n\n- `schedule_name: string`\n The identifier for the schedule to be retrieved\n\n- `covering_date?: string`\n If provided, at most one schedule segment will be returned (the one that covers this date). If not provided, all segments will be returned.\n\n### Returns\n\n- `{ data: { starting_at: string; value: object; ending_before?: string; }[]; }`\n\n - `data: { starting_at: string; value: object; ending_before?: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst namedSchedule = await client.v1.contracts.rateCards.namedSchedules.retrieve({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n});\n\nconsole.log(namedSchedule);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.namedSchedules.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst namedSchedule = await client.v1.contracts.rateCards.namedSchedules.retrieve({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n covering_date: '2022-02-15T00:00:00Z',\n});\n\nconsole.log(namedSchedule.data);", }, python: { method: 'v1.contracts.rate_cards.named_schedules.retrieve', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nnamed_schedule = client.v1.contracts.rate_cards.named_schedules.retrieve(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name="my-schedule",\n covering_date=datetime.fromisoformat("2022-02-15T00:00:00"),\n)\nprint(named_schedule.data)', }, java: { method: 'v1().contracts().rateCards().namedSchedules().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.ratecards.namedschedules.NamedScheduleRetrieveParams;\nimport com.metronome.api.models.v1.contracts.ratecards.namedschedules.NamedScheduleRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleRetrieveParams params = NamedScheduleRetrieveParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .scheduleName("my-schedule")\n .build();\n NamedScheduleRetrieveResponse namedSchedule = client.v1().contracts().rateCards().namedSchedules().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.NamedSchedules.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tnamedSchedule, err := client.V1.Contracts.RateCards.NamedSchedules.Get(context.TODO(), metronome.V1ContractRateCardNamedScheduleGetParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tScheduleName: "my-schedule",\n\t\tCoveringDate: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", namedSchedule.Data)\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.named_schedules.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nnamed_schedule = metronome.v1.contracts.rate_cards.named_schedules.retrieve(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name: "my-schedule"\n)\n\nputs(named_schedule)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/getNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "schedule_name": "my-schedule",\n "covering_date": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/contracts/updateNamedSchedule', httpMethod: 'post', summary: "Update a contract's named schedule", description: "Update a named schedule for the given contract. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.contracts.rateCards.named_schedules > (method) update', qualified: 'client.v1.contracts.rateCards.namedSchedules.update', params: [ 'contract_id: string;', 'customer_id: string;', 'schedule_name: string;', 'starting_at: string;', 'value: object;', 'ending_before?: string;', ], markdown: "## update\n\n`client.v1.contracts.rateCards.namedSchedules.update(contract_id: string, customer_id: string, schedule_name: string, starting_at: string, value: object, ending_before?: string): void`\n\n**post** `/v1/contracts/updateNamedSchedule`\n\nUpdate a named schedule for the given contract. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `contract_id: string`\n ID of the contract whose named schedule is to be updated\n\n- `customer_id: string`\n ID of the customer whose named schedule is to be updated\n\n- `schedule_name: string`\n The identifier for the schedule to be updated\n\n- `starting_at: string`\n\n- `value: object`\n The value to set for the named schedule. The structure of this object is specific to the named schedule.\n\n- `ending_before?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.contracts.rateCards.namedSchedules.update({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n})\n```", perLanguage: { typescript: { method: 'client.v1.contracts.rateCards.namedSchedules.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.contracts.rateCards.namedSchedules.update({\n contract_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n customer_id: '9b85c1c1-5238-4f2a-a409-61412905e1e1',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n ending_before: '2022-02-15T00:00:00Z',\n});", }, python: { method: 'v1.contracts.rate_cards.named_schedules.update', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.contracts.rate_cards.named_schedules.update(\n contract_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id="9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name="my-schedule",\n starting_at=datetime.fromisoformat("2022-02-01T00:00:00"),\n value={\n "my_key": "my_value"\n },\n ending_before=datetime.fromisoformat("2022-02-15T00:00:00"),\n)', }, java: { method: 'v1().contracts().rateCards().namedSchedules().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.contracts.ratecards.namedschedules.NamedScheduleUpdateParams;\nimport java.time.OffsetDateTime;\nimport java.util.Map;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleUpdateParams params = NamedScheduleUpdateParams.builder()\n .contractId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .customerId("9b85c1c1-5238-4f2a-a409-61412905e1e1")\n .scheduleName("my-schedule")\n .startingAt(OffsetDateTime.parse("2022-02-01T00:00:00Z"))\n .value(JsonValue.from(Map.of(\n "my_key", "my_value"\n )))\n .build();\n client.v1().contracts().rateCards().namedSchedules().update(params);\n }\n}', }, go: { method: 'client.V1.Contracts.RateCards.NamedSchedules.Update', example: 'package main\n\nimport (\n\t"context"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Contracts.RateCards.NamedSchedules.Update(context.TODO(), metronome.V1ContractRateCardNamedScheduleUpdateParams{\n\t\tContractID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tCustomerID: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n\t\tScheduleName: "my-schedule",\n\t\tStartingAt: time.Now(),\n\t\tValue: map[string]any{\n\t\t\t"my_key": "my_value",\n\t\t},\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.contracts.rate_cards.named_schedules.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.contracts.rate_cards.named_schedules.update(\n contract_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n customer_id: "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n schedule_name: "my-schedule",\n starting_at: "2022-02-01T00:00:00Z",\n value: {my_key: "my_value"}\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/contracts/updateNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "contract_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "customer_id": "9b85c1c1-5238-4f2a-a409-61412905e1e1",\n "schedule_name": "my-schedule",\n "starting_at": "2022-02-01T00:00:00Z",\n "value": {\n "my_key": "my_value"\n },\n "ending_before": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/contract-pricing/rate-cards/getNamedSchedule', httpMethod: 'post', summary: "Get a rate card's named schedule", description: "Get a named schedule for the given rate card. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.contracts.named_schedules > (method) retrieve', qualified: 'client.v1.contracts.namedSchedules.retrieve', params: ['rate_card_id: string;', 'schedule_name: string;', 'covering_date?: string;'], response: '{ data: { starting_at: string; value: object; ending_before?: string; }[]; }', markdown: "## retrieve\n\n`client.v1.contracts.namedSchedules.retrieve(rate_card_id: string, schedule_name: string, covering_date?: string): { data: object[]; }`\n\n**post** `/v1/contract-pricing/rate-cards/getNamedSchedule`\n\nGet a named schedule for the given rate card. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `rate_card_id: string`\n ID of the rate card whose named schedule is to be retrieved\n\n- `schedule_name: string`\n The identifier for the schedule to be retrieved\n\n- `covering_date?: string`\n If provided, at most one schedule segment will be returned (the one that covers this date). If not provided, all segments will be returned.\n\n### Returns\n\n- `{ data: { starting_at: string; value: object; ending_before?: string; }[]; }`\n\n - `data: { starting_at: string; value: object; ending_before?: string; }[]`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst namedSchedule = await client.v1.contracts.namedSchedules.retrieve({ rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc', schedule_name: 'my-schedule' });\n\nconsole.log(namedSchedule);\n```", perLanguage: { typescript: { method: 'client.v1.contracts.namedSchedules.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst namedSchedule = await client.v1.contracts.namedSchedules.retrieve({\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n schedule_name: 'my-schedule',\n covering_date: '2022-02-15T00:00:00Z',\n});\n\nconsole.log(namedSchedule.data);", }, python: { method: 'v1.contracts.named_schedules.retrieve', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nnamed_schedule = client.v1.contracts.named_schedules.retrieve(\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n schedule_name="my-schedule",\n covering_date=datetime.fromisoformat("2022-02-15T00:00:00"),\n)\nprint(named_schedule.data)', }, java: { method: 'v1().contracts().namedSchedules().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.contracts.namedschedules.NamedScheduleRetrieveParams;\nimport com.metronome.api.models.v1.contracts.namedschedules.NamedScheduleRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleRetrieveParams params = NamedScheduleRetrieveParams.builder()\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .scheduleName("my-schedule")\n .build();\n NamedScheduleRetrieveResponse namedSchedule = client.v1().contracts().namedSchedules().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Contracts.NamedSchedules.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tnamedSchedule, err := client.V1.Contracts.NamedSchedules.Get(context.TODO(), metronome.V1ContractNamedScheduleGetParams{\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tScheduleName: "my-schedule",\n\t\tCoveringDate: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", namedSchedule.Data)\n}\n', }, ruby: { method: 'v1.contracts.named_schedules.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nnamed_schedule = metronome.v1.contracts.named_schedules.retrieve(\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n schedule_name: "my-schedule"\n)\n\nputs(named_schedule)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/getNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "schedule_name": "my-schedule",\n "covering_date": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'update', endpoint: '/v1/contract-pricing/rate-cards/updateNamedSchedule', httpMethod: 'post', summary: "Update a rate card's named schedule", description: "Update a named schedule for the given rate card. This endpoint's availability is dependent on your client's configuration.", stainlessPath: '(resource) v1.contracts.named_schedules > (method) update', qualified: 'client.v1.contracts.namedSchedules.update', params: [ 'rate_card_id: string;', 'schedule_name: string;', 'starting_at: string;', 'value: object;', 'ending_before?: string;', ], markdown: "## update\n\n`client.v1.contracts.namedSchedules.update(rate_card_id: string, schedule_name: string, starting_at: string, value: object, ending_before?: string): void`\n\n**post** `/v1/contract-pricing/rate-cards/updateNamedSchedule`\n\nUpdate a named schedule for the given rate card. This endpoint's availability is dependent on your client's configuration.\n\n### Parameters\n\n- `rate_card_id: string`\n ID of the rate card whose named schedule is to be updated\n\n- `schedule_name: string`\n The identifier for the schedule to be updated\n\n- `starting_at: string`\n\n- `value: object`\n The value to set for the named schedule. The structure of this object is specific to the named schedule.\n\n- `ending_before?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nawait client.v1.contracts.namedSchedules.update({\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n})\n```", perLanguage: { typescript: { method: 'client.v1.contracts.namedSchedules.update', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.contracts.namedSchedules.update({\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n schedule_name: 'my-schedule',\n starting_at: '2022-02-01T00:00:00Z',\n value: { my_key: 'my_value' },\n ending_before: '2022-02-15T00:00:00Z',\n});", }, python: { method: 'v1.contracts.named_schedules.update', example: 'import os\nfrom datetime import datetime\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nclient.v1.contracts.named_schedules.update(\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n schedule_name="my-schedule",\n starting_at=datetime.fromisoformat("2022-02-01T00:00:00"),\n value={\n "my_key": "my_value"\n },\n ending_before=datetime.fromisoformat("2022-02-15T00:00:00"),\n)', }, java: { method: 'v1().contracts().namedSchedules().update', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.contracts.namedschedules.NamedScheduleUpdateParams;\nimport java.time.OffsetDateTime;\nimport java.util.Map;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n NamedScheduleUpdateParams params = NamedScheduleUpdateParams.builder()\n .rateCardId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .scheduleName("my-schedule")\n .startingAt(OffsetDateTime.parse("2022-02-01T00:00:00Z"))\n .value(JsonValue.from(Map.of(\n "my_key", "my_value"\n )))\n .build();\n client.v1().contracts().namedSchedules().update(params);\n }\n}', }, go: { method: 'client.V1.Contracts.NamedSchedules.Update', example: 'package main\n\nimport (\n\t"context"\n\t"time"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\terr := client.V1.Contracts.NamedSchedules.Update(context.TODO(), metronome.V1ContractNamedScheduleUpdateParams{\n\t\tRateCardID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t\tScheduleName: "my-schedule",\n\t\tStartingAt: time.Now(),\n\t\tValue: map[string]any{\n\t\t\t"my_key": "my_value",\n\t\t},\n\t\tEndingBefore: metronome.Time(time.Now()),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n', }, ruby: { method: 'v1.contracts.named_schedules.update', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresult = metronome.v1.contracts.named_schedules.update(\n rate_card_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n schedule_name: "my-schedule",\n starting_at: "2022-02-01T00:00:00Z",\n value: {my_key: "my_value"}\n)\n\nputs(result)', }, http: { example: 'curl https://api.metronome.com/v1/contract-pricing/rate-cards/updateNamedSchedule \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n "schedule_name": "my-schedule",\n "starting_at": "2022-02-01T00:00:00Z",\n "value": {\n "my_key": "my_value"\n },\n "ending_before": "2022-02-15T00:00:00Z"\n }\'', }, }, }, { name: 'create', endpoint: '/v1/packages/create', httpMethod: 'post', summary: 'Create a package', description: 'Create a package that defines a set of reusable, time-relative contract terms that can be used across cohorts of customers. Packages provide an abstraction layer on top of rate cards to provide an easy way to provision customers with standard pricing. \n\n### **Use this endpoint to:**\n- Model standard pay-as-you-go pricing packages that can be easily reused across customers\n- Define standardized contract terms and discounting for sales-led motions\n- Set aliases for the package to facilitate easy package transition. Aliases are human-readable names that you can use in the place of the id of the package when provisioning a customer’s contract. By using an alias, you can easily create a contract and provision a customer by choosing the “Starter Plan” package, without storing the package ID in your internal systems. This is helpful when launching terms for a package, as you can create a new package with the “Starter Plan” alias scheduled to be assigned without updating your provisioning code.\n\n### Key input fields:\n- `starting_at_offset`: Starting date relative to contract start. Generates the `starting_at` date when a contract is provisioned using a package.\n- `duration`: Duration starting from `starting_at_offset`. Generates the `ending_before` date when a contract is provisioned using a package.\n- `date_offset`: Date relative to contract start. Used for point-in-time dates without a duration.\n- `aliases`: Human-readable name to use when provisioning contracts with a package.\n\n### Usage guidelines:\n- Use packages for standard self-serve use cases where customers have consistent terms. For customers with negotiated custom contract terms, use the `createContract` endpoint for maximum flexibility.\n- Billing provider configuration can be set when creating a package by using `billing_provider` and `delivery_method`. To provision a customer successfully with a package, the customer must have one and only one billing provider configuration that matches the billing provider configuration set on the package.\n- A package alias can only be used by one package at a time. If you create a new package with an alias that is already in use by another package, the original package’s alias schedule will be updated. The alias will reference the package to which it was most recently assigned.\n- Terms can only be specified using times relative to the contract start date. Supported granularities are: `days`, `weeks`, `months`, `years`\n- Packages cannot be edited once created. Use the rate card to easily add new rates across all of your customers or make direct edits to a contract after provisioning with a package. Edited contracts will still be associated with the package used during provisioning.\n', stainlessPath: '(resource) v1.packages > (method) create', qualified: 'client.v1.packages.create', params: [ 'name: string;', 'aliases?: { name: string; ending_before?: string; starting_at?: string; }[];', "billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite';", "commits?: { access_schedule: { schedule_items: { amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; credit_type_id?: string; }; product_id: string; type: 'PREPAID' | 'POSTPAID'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { schedule_items: { date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; credit_type_id?: string; do_not_invoice?: boolean; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; temporary_id?: string; }[];", 'contract_name?: string;', "credits?: { access_schedule: { schedule_items: { amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[];", "delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns';", "duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; };", "multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT';", 'net_payment_terms_days?: number;', "overrides?: { override_specifiers: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[];", "prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; };", 'rate_card_alias?: string;', 'rate_card_id?: string;', "recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[];", "recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[];", "scheduled_charges?: { product_id: string; schedule: { schedule_items: { date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; credit_type_id?: string; }; custom_fields?: object; name?: string; }[];", "scheduled_charges_on_usage_invoices?: 'ALL';", "spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; };", "spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[];", "subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; initial_unassigned_seats?: number; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; temporary_id?: string; }[];", 'uniqueness_key?: string;', "usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; invoice_generation_starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; };", ], response: '{ data: { id: string; }; }', markdown: "## create\n\n`client.v1.packages.create(name: string, aliases?: { name: string; ending_before?: string; starting_at?: string; }[], billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite', commits?: { access_schedule: { schedule_items: object[]; credit_type_id?: string; }; product_id: string; type: 'PREPAID' | 'POSTPAID'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { schedule_items: object[]; credit_type_id?: string; do_not_invoice?: boolean; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; temporary_id?: string; }[], contract_name?: string, credits?: { access_schedule: { schedule_items: object[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: object[]; }[], delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns', duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }, multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT', net_payment_terms_days?: number, overrides?: { override_specifiers: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[], prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }, rate_card_alias?: string, rate_card_id?: string, recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[], recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { apply_seat_increase_config: object; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[], scheduled_charges?: { product_id: string; schedule: { schedule_items: object[]; credit_type_id?: string; }; custom_fields?: object; name?: string; }[], scheduled_charges_on_usage_invoices?: 'ALL', spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }, spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[], subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: object; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; initial_unassigned_seats?: number; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; temporary_id?: string; }[], uniqueness_key?: string, usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; invoice_generation_starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }): { data: id; }`\n\n**post** `/v1/packages/create`\n\nCreate a package that defines a set of reusable, time-relative contract terms that can be used across cohorts of customers. Packages provide an abstraction layer on top of rate cards to provide an easy way to provision customers with standard pricing. \n\n### **Use this endpoint to:**\n- Model standard pay-as-you-go pricing packages that can be easily reused across customers\n- Define standardized contract terms and discounting for sales-led motions\n- Set aliases for the package to facilitate easy package transition. Aliases are human-readable names that you can use in the place of the id of the package when provisioning a customer’s contract. By using an alias, you can easily create a contract and provision a customer by choosing the “Starter Plan” package, without storing the package ID in your internal systems. This is helpful when launching terms for a package, as you can create a new package with the “Starter Plan” alias scheduled to be assigned without updating your provisioning code.\n\n### Key input fields:\n- `starting_at_offset`: Starting date relative to contract start. Generates the `starting_at` date when a contract is provisioned using a package.\n- `duration`: Duration starting from `starting_at_offset`. Generates the `ending_before` date when a contract is provisioned using a package.\n- `date_offset`: Date relative to contract start. Used for point-in-time dates without a duration.\n- `aliases`: Human-readable name to use when provisioning contracts with a package.\n\n### Usage guidelines:\n- Use packages for standard self-serve use cases where customers have consistent terms. For customers with negotiated custom contract terms, use the `createContract` endpoint for maximum flexibility.\n- Billing provider configuration can be set when creating a package by using `billing_provider` and `delivery_method`. To provision a customer successfully with a package, the customer must have one and only one billing provider configuration that matches the billing provider configuration set on the package.\n- A package alias can only be used by one package at a time. If you create a new package with an alias that is already in use by another package, the original package’s alias schedule will be updated. The alias will reference the package to which it was most recently assigned.\n- Terms can only be specified using times relative to the contract start date. Supported granularities are: `days`, `weeks`, `months`, `years`\n- Packages cannot be edited once created. Use the rate card to easily add new rates across all of your customers or make direct edits to a contract after provisioning with a package. Edited contracts will still be associated with the package used during provisioning.\n\n\n### Parameters\n\n- `name: string`\n\n- `aliases?: { name: string; ending_before?: string; starting_at?: string; }[]`\n Reference this alias when creating a contract. If the same alias is assigned to multiple packages, it will reference the package to which it was most recently assigned. It is not exposed to end customers.\n\n- `billing_provider?: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace' | 'stripe' | 'netsuite'`\n\n- `commits?: { access_schedule: { schedule_items: { amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; credit_type_id?: string; }; product_id: string; type: 'PREPAID' | 'POSTPAID'; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { schedule_items: { date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; credit_type_id?: string; do_not_invoice?: boolean; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; temporary_id?: string; }[]`\n\n- `contract_name?: string`\n\n- `credits?: { access_schedule: { schedule_items: { amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; credit_type_id?: string; }; product_id: string; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n\n- `delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'`\n\n- `duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }`\n - `unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'`\n - `value: number`\n\n- `multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'`\n Defaults to LOWEST_MULTIPLIER, which applies the greatest discount to list prices automatically. EXPLICIT prioritization requires specifying priorities for each multiplier; the one with the lowest priority value will be prioritized first. If tiered overrides are used, prioritization must be explicit.\n\n- `net_payment_terms_days?: number`\n\n- `overrides?: { override_specifiers: { any_commit_or_credit_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type_id?: string; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: { price: number; size?: number; }[]; }; priority?: number; target?: 'COMMIT_RATE' | 'LIST_RATE'; tiers?: { multiplier: number; size?: number; }[]; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]`\n\n- `prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `recharge_to_amount: number`\n Specify the amount the balance should be recharged to.\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's prepaid balance lowers to this amount, a threshold charge will be initiated.\n - `custom_credit_type_id?: string`\n If provided, the threshold, recharge-to amount, and the resulting threshold commit amount will be in terms of this credit type instead of the fiat currency.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n - `threshold_balance_specifiers?: { exclude: { custom_field_filters: { entity: 'Commit' | 'ContractCredit' | 'ContractCreditOrCommit'; key: string; value: string; }[]; }[]; }[]`\n Determines which balances are excluded from remaining balance calculation for threshold billing.\n\n- `rate_card_alias?: string`\n Selects the rate card linked to the specified alias as of the contract's start date.\n\n- `rate_card_id?: string`\n\n- `recurring_commits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[]`\n\n- `recurring_credits?: { access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product_id: string; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { apply_seat_increase_config: { is_prorated: boolean; }; subscription_id: string; allocation?: 'INDIVIDUAL' | 'POOLED'; }; temporary_id?: string; }[]`\n\n- `scheduled_charges?: { product_id: string; schedule: { schedule_items: { date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; credit_type_id?: string; }; custom_fields?: object; name?: string; }[]`\n\n- `scheduled_charges_on_usage_invoices?: 'ALL'`\n Determines which scheduled and commit charges to consolidate onto the Contract's usage invoice. The charge's `timestamp` must match the usage invoice's `ending_before` date for consolidation to occur. This field cannot be modified after a Contract has been created. If this field is omitted, charges will appear on a separate invoice from usage charges.\n\n- `spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; }`\n - `commit: { product_id: string; description?: string; name?: string; priority?: number; }`\n - `is_enabled: boolean`\n When set to false, the contract will not be evaluated against the threshold_amount. Toggling to true will result an immediate evaluation, regardless of prior state.\n - `payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: { tax_amount: number; tax_name?: string; }; stripe_config?: { payment_type: 'INVOICE' | 'PAYMENT_INTENT'; invoice_metadata?: object; }; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }`\n - `threshold_amount: number`\n Specify the threshold amount for the contract. Each time the contract's usage hits this amount, a threshold charge will be initiated.\n - `discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }`\n\n- `spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]`\n\n- `subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior?: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated?: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product_id: string; }; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; initial_unassigned_seats?: number; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; temporary_id?: string; }[]`\n\n- `uniqueness_key?: string`\n Prevents the creation of duplicates. If a request to create a record is made with a previously used uniqueness key, a new record will not be created and the request will fail with a 409 error.\n\n- `usage_statement_schedule?: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; invoice_generation_starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }`\n - `frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'`\n - `day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'`\n If not provided, defaults to the first day of the month.\n - `invoice_generation_starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }`\n The offset at which Metronome should start generating usage invoices, relative to the contract start date. If unspecified, contract start date will be used. This is useful to set if you want to import historical invoices via our 'Create Historical Invoices' API rather than having Metronome automatically generate them.\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst _package = await client.v1.packages.create({ name: 'My package' });\n\nconsole.log(_package);\n```", perLanguage: { typescript: { method: 'client.v1.packages.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst _package = await client.v1.packages.create({\n name: 'My package',\n billing_provider: 'stripe',\n delivery_method: 'direct_to_billing_provider',\n rate_card_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(_package.data);", }, python: { method: 'v1.packages.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npackage = client.v1.packages.create(\n name="My package",\n billing_provider="stripe",\n delivery_method="direct_to_billing_provider",\n rate_card_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(package.data)', }, java: { method: 'v1().packages().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.packages.PackageCreateParams;\nimport com.metronome.api.models.v1.packages.PackageCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PackageCreateParams params = PackageCreateParams.builder()\n .name("My package")\n .build();\n PackageCreateResponse package_ = client.v1().packages().create(params);\n }\n}', }, go: { method: 'client.V1.Packages.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpackage_, err := client.V1.Packages.New(context.TODO(), metronome.V1PackageNewParams{\n\t\tName: "My package",\n\t\tBillingProvider: metronome.V1PackageNewParamsBillingProviderStripe,\n\t\tDeliveryMethod: metronome.V1PackageNewParamsDeliveryMethodDirectToBillingProvider,\n\t\tRateCardID: metronome.String("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", package_.Data)\n}\n', }, ruby: { method: 'v1.packages.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npackage = metronome.v1.packages.create(name: "My package")\n\nputs(package)', }, http: { example: 'curl https://api.metronome.com/v1/packages/create \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "name": "My package",\n "billing_provider": "stripe",\n "delivery_method": "direct_to_billing_provider",\n "rate_card_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'retrieve', endpoint: '/v1/packages/get', httpMethod: 'post', summary: 'Get a package', description: 'Gets the details for a specific package, including name, aliases, duration, and terms. Use this endpoint to understand a package’s alias schedule, or display a specific package’s details to end customers.\n', stainlessPath: '(resource) v1.packages > (method) retrieve', qualified: 'client.v1.packages.retrieve', params: ['package_id: string;'], response: "{ data: { id: string; commits: object[]; created_at: string; created_by: string; overrides: object[]; scheduled_charges: object[]; usage_statement_schedule: object; aliases?: object[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: object[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: object; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: object[]; uniqueness_key?: string; }; }", markdown: "## retrieve\n\n`client.v1.packages.retrieve(package_id: string): { data: object; }`\n\n**post** `/v1/packages/get`\n\nGets the details for a specific package, including name, aliases, duration, and terms. Use this endpoint to understand a package’s alias schedule, or display a specific package’s details to end customers.\n\n\n### Parameters\n\n- `package_id: string`\n\n### Returns\n\n- `{ data: { id: string; commits: { id: string; product: object; type: 'PREPAID' | 'POSTPAID'; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: object; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: commit_specifier[]; }[]; created_at: string; created_by: string; overrides: { id: string; override_specifiers: object[]; starting_at_offset: object; applicable_product_tags?: string[]; duration?: object; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_tiers?: override_tier[]; overwrite_rate?: overwrite_rate; priority?: number; product?: object; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; scheduled_charges: { id: string; product: object; schedule: object; custom_fields?: object; description?: string; name?: string; }[]; usage_statement_schedule: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; }; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: { id: string; product: object; access_schedule?: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: commit_specifier[]; }[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: object; rate_card_id?: string; recurring_commits?: { id: string; access_amount: object; commit_duration: object; priority: number; product: object; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: object; invoice_amount?: object; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: object; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: commit_specifier[]; subscription_config?: object; }[]; recurring_credits?: { id: string; access_amount: object; commit_duration: object; priority: number; product: object; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: object; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: object; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: object; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: commit_specifier[]; subscription_config?: object; }[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: object; spend_trackers?: { alias: string; applicable_spend_specifiers: object[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]; subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: object; subscription_rate: object; id?: string; billing_cycle_config?: object; custom_fields?: object; description?: string; duration?: object; fiat_credit_type_id?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: object; starting_at_offset?: object; }[]; uniqueness_key?: string; }; }`\n\n - `data: { id: string; commits: { id: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { credit_type: object; schedule_items: { id: string; amount: number; duration: object; starting_at_offset: object; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { credit_type: object; do_not_invoice: boolean; schedule_items: { id: string; date_offset: object; quantity: number; unit_price: number; }[]; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; created_at: string; created_by: string; overrides: { id: string; override_specifiers: { any_commit_or_credit_template_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_template_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_template_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_tags?: string[]; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_tiers?: { multiplier: number; size?: number; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: credit_type_data; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: tier[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; scheduled_charges: { id: string; product: { id: string; name: string; }; schedule: { credit_type: object; schedule_items: { id: string; date_offset: object; quantity: number; unit_price: number; }[]; }; custom_fields?: object; description?: string; name?: string; }[]; usage_statement_schedule: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; }; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: { id: string; product: { id: string; name: string; }; access_schedule?: { credit_type: object; schedule_items: { id: string; amount: number; duration: object; starting_at_offset: object; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: { commit: object; is_enabled: boolean; payment_gate_config: object; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: object; }; threshold_balance_specifiers?: { exclude: object[]; }[]; }; rate_card_id?: string; recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: { is_prorated: boolean; }; subscription_template_id: string; }; }[]; recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: { is_prorated: boolean; }; subscription_template_id: string; }; }[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: object; is_enabled: boolean; payment_gate_config: object; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: object; }; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]; subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: { id: string; name: string; }; }; id?: string; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; fiat_credit_type_id?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; uniqueness_key?: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst _package = await client.v1.packages.retrieve({ package_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(_package);\n```", perLanguage: { typescript: { method: 'client.v1.packages.retrieve', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst _package = await client.v1.packages.retrieve({\n package_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(_package.data);", }, python: { method: 'v1.packages.retrieve', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npackage = client.v1.packages.retrieve(\n package_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(package.data)', }, java: { method: 'v1().packages().retrieve', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.packages.PackageRetrieveParams;\nimport com.metronome.api.models.v1.packages.PackageRetrieveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PackageRetrieveParams params = PackageRetrieveParams.builder()\n .packageId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PackageRetrieveResponse package_ = client.v1().packages().retrieve(params);\n }\n}', }, go: { method: 'client.V1.Packages.Get', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpackage_, err := client.V1.Packages.Get(context.TODO(), metronome.V1PackageGetParams{\n\t\tPackageID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", package_.Data)\n}\n', }, ruby: { method: 'v1.packages.retrieve', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npackage = metronome.v1.packages.retrieve(package_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(package)', }, http: { example: 'curl https://api.metronome.com/v1/packages/get \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "package_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/packages/list', httpMethod: 'post', summary: 'List all packages', description: 'Lists all packages with details including name, aliases, duration, and terms. To view contracts on a specific package, use the `listContractsOnPackage` endpoint.\n', stainlessPath: '(resource) v1.packages > (method) list', qualified: 'client.v1.packages.list', params: [ 'limit?: number;', 'next_page?: string;', "archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL';", ], response: "{ id: string; commits: object[]; created_at: string; created_by: string; overrides: object[]; scheduled_charges: object[]; usage_statement_schedule: object; aliases?: object[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: object[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: object; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: object[]; uniqueness_key?: string; }", markdown: "## list\n\n`client.v1.packages.list(limit?: number, next_page?: string, archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL'): { id: string; commits: object[]; created_at: string; created_by: string; overrides: object[]; scheduled_charges: object[]; usage_statement_schedule: object; aliases?: object[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: object[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: object; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: prepaid_balance_threshold_configuration; rate_card_id?: string; recurring_commits?: object[]; recurring_credits?: object[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: spend_threshold_configuration; spend_trackers?: object[]; subscriptions?: object[]; uniqueness_key?: string; }`\n\n**post** `/v1/packages/list`\n\nLists all packages with details including name, aliases, duration, and terms. To view contracts on a specific package, use the `listContractsOnPackage` endpoint.\n\n\n### Parameters\n\n- `limit?: number`\n The maximum number of packages to return. Defaults to 10.\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `archive_filter?: 'ARCHIVED' | 'NOT_ARCHIVED' | 'ALL'`\n Filter packages by archived status. Defaults to NOT_ARCHIVED.\n\n### Returns\n\n- `{ id: string; commits: { id: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { credit_type: credit_type_data; schedule_items: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { credit_type: credit_type_data; do_not_invoice: boolean; schedule_items: object[]; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: object[]; }[]; created_at: string; created_by: string; overrides: { id: string; override_specifiers: { any_commit_or_credit_template_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_template_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_template_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_tags?: string[]; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_tiers?: object[]; overwrite_rate?: object; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]; scheduled_charges: { id: string; product: { id: string; name: string; }; schedule: { credit_type: credit_type_data; schedule_items: object[]; }; custom_fields?: object; description?: string; name?: string; }[]; usage_statement_schedule: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; }; aliases?: { name: string; ending_before?: string; starting_at?: string; }[]; archived_at?: string; billing_provider?: string; contract_name?: string; credits?: { id: string; product: { id: string; name: string; }; access_schedule?: { credit_type: credit_type_data; schedule_items: object[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: object[]; }[]; delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'; name?: string; net_payment_terms_days?: number; prepaid_balance_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: object; threshold_balance_specifiers?: object[]; }; rate_card_id?: string; recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; invoice?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: object; subscription_template_id: string; }; }[]; recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: object; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: object[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: object; subscription_template_id: string; }; }[]; scheduled_charges_on_usage_invoices?: 'ALL'; spend_threshold_configuration?: { commit: base_threshold_commit; is_enabled: boolean; payment_gate_config: payment_gate_config; threshold_amount: number; discount_configuration?: object; }; spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]; subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: object; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: object; }; id?: string; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; fiat_credit_type_id?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; uniqueness_key?: string; }`\n\n - `id: string`\n - `commits: { id: string; product: { id: string; name: string; }; type: 'PREPAID' | 'POSTPAID'; access_schedule?: { credit_type: { id: string; name: string; }; schedule_items: { id: string; amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; invoice_schedule?: { credit_type: { id: string; name: string; }; do_not_invoice: boolean; schedule_items: { id: string; date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; }; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n - `created_at: string`\n - `created_by: string`\n - `overrides: { id: string; override_specifiers: { any_commit_or_credit_template_ids?: string[]; billing_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; commit_template_ids?: string[]; presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; recurring_commit_template_ids?: string[]; }[]; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_tags?: string[]; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; entitled?: boolean; is_commit_specific?: boolean; multiplier?: number; override_tiers?: { multiplier: number; size?: number; }[]; overwrite_rate?: { rate_type: 'FLAT' | 'PERCENTAGE' | 'SUBSCRIPTION' | 'TIERED' | 'TIERED_PERCENTAGE' | 'CUSTOM'; credit_type?: object; custom_rate?: object; is_prorated?: boolean; price?: number; quantity?: number; tiers?: object[]; }; priority?: number; product?: { id: string; name: string; }; target?: 'COMMIT_RATE' | 'LIST_RATE'; type?: 'OVERWRITE' | 'MULTIPLIER' | 'TIERED'; }[]`\n - `scheduled_charges: { id: string; product: { id: string; name: string; }; schedule: { credit_type: { id: string; name: string; }; schedule_items: { id: string; date_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; quantity: number; unit_price: number; }[]; }; custom_fields?: object; description?: string; name?: string; }[]`\n - `usage_statement_schedule: { frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; day?: 'FIRST_OF_MONTH' | 'CONTRACT_START'; }`\n - `aliases?: { name: string; ending_before?: string; starting_at?: string; }[]`\n - `archived_at?: string`\n - `billing_provider?: string`\n - `contract_name?: string`\n - `credits?: { id: string; product: { id: string; name: string; }; access_schedule?: { credit_type: { id: string; name: string; }; schedule_items: { id: string; amount: number; duration: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; custom_fields?: object; description?: string; name?: string; priority?: number; rate_type?: 'COMMIT_RATE' | 'LIST_RATE'; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; }[]`\n - `delivery_method?: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'`\n - `duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }`\n - `multiplier_override_prioritization?: 'LOWEST_MULTIPLIER' | 'EXPLICIT'`\n - `name?: string`\n - `net_payment_terms_days?: number`\n - `prepaid_balance_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; recharge_to_amount: number; threshold_amount: number; custom_credit_type_id?: string; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; threshold_balance_specifiers?: { exclude: { custom_field_filters: object[]; }[]; }[]; }`\n - `rate_card_id?: string`\n - `recurring_commits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; invoice_amount?: { credit_type_id: string; quantity: number; unit_price: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; invoice?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: { is_prorated: boolean; }; subscription_template_id: string; }; }[]`\n - `recurring_credits?: { id: string; access_amount: { credit_type_id: string; unit_price: number; quantity?: number; }; commit_duration: { value: number; unit?: 'PERIODS'; }; priority: number; product: { id: string; name: string; }; rate_type: 'COMMIT_RATE' | 'LIST_RATE'; starting_at_offset: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; applicable_product_ids?: string[]; applicable_product_tags?: string[]; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; name?: string; proration?: 'NONE' | 'FIRST' | 'LAST' | 'FIRST_AND_LAST'; proration_rounding?: { access?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; recurrence_frequency?: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY' | 'DAILY'; rollover_fraction?: number; specifiers?: { presentation_group_values?: object; pricing_group_values?: object; product_id?: string; product_tags?: string[]; }[]; subscription_config?: { allocation: 'INDIVIDUAL' | 'POOLED'; apply_seat_increase_config: { is_prorated: boolean; }; subscription_template_id: string; }; }[]`\n - `scheduled_charges_on_usage_invoices?: 'ALL'`\n - `spend_threshold_configuration?: { commit: { product_id: string; description?: string; name?: string; priority?: number; }; is_enabled: boolean; payment_gate_config: { payment_gate_type: 'NONE' | 'STRIPE' | 'EXTERNAL'; precalculated_tax_config?: object; stripe_config?: object; tax_type?: 'NONE' | 'STRIPE' | 'ANROK' | 'PRECALCULATED'; }; threshold_amount: number; discount_configuration?: { payment_fraction: number; cap?: { amount: number; spend_tracker_alias: string; }; }; }`\n - `spend_trackers?: { alias: string; applicable_spend_specifiers: { sources: 'THRESHOLD_RECHARGE' | 'MANUAL'[]; spend_type: 'COMMIT_PURCHASE'; discounted?: 'ANY' | 'DISCOUNTED_ONLY' | 'UNDISCOUNTED_ONLY'; }[]; credit_type_id: string; reset_frequency: 'BILLING_PERIOD'; }[]`\n - `subscriptions?: { collection_schedule: 'ADVANCE' | 'ARREARS'; proration: { invoice_behavior: 'BILL_IMMEDIATELY' | 'BILL_ON_NEXT_COLLECTION_DATE'; is_prorated: boolean; rounding?: { decimal_places: number; rounding_method: 'HALF_UP' | 'FLOOR' | 'CEILING'; }; }; subscription_rate: { billing_frequency: 'MONTHLY' | 'QUARTERLY' | 'ANNUAL' | 'WEEKLY'; product: { id: string; name: string; }; }; id?: string; billing_cycle_config?: { invoice_placement?: 'ON_SCHEDULED_INVOICE' | 'ON_USAGE_INVOICE'; }; custom_fields?: object; description?: string; duration?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; fiat_credit_type_id?: string; initial_quantity?: number; name?: string; quantity_management_mode?: 'SEAT_BASED' | 'QUANTITY_ONLY'; seat_config?: { seat_group_key: string; }; starting_at_offset?: { unit: 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'; value: number; }; }[]`\n - `uniqueness_key?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const packageListResponse of client.v1.packages.list()) {\n console.log(packageListResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.packages.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const packageListResponse of client.v1.packages.list()) {\n console.log(packageListResponse.id);\n}", }, python: { method: 'v1.packages.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.packages.list()\npage = page.data[0]\nprint(page.id)', }, java: { method: 'v1().packages().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.packages.PackageListPage;\nimport com.metronome.api.models.v1.packages.PackageListParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PackageListPage page = client.v1().packages().list();\n }\n}', }, go: { method: 'client.V1.Packages.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Packages.List(context.TODO(), metronome.V1PackageListParams{})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.packages.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.packages.list\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/packages/list \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, { name: 'list_contracts_on_package', endpoint: '/v1/packages/listContractsOnPackage', httpMethod: 'post', summary: 'List contracts associated with a package', description: 'For a given package, returns all contract IDs and customer IDs associated with the package over a specific time period. \n\n### Use this endpoint to:\n- Understand which customers are provisioned on a package at any given time for internal cohort management\n- Manage customer migrations to a new package. For example, to migrate all active customers to a new package, call this endpoint, end contracts, and provision customers on a new package.\n\n### **Usage guidelines:**\nUse the **`starting_at`**, **`covering_date`**, and **`include_archived`** parameters to filter the list of returned contracts. For example, to list only currently active contracts, pass **`covering_date`** equal to the current time.\n', stainlessPath: '(resource) v1.packages > (method) list_contracts_on_package', qualified: 'client.v1.packages.listContractsOnPackage', params: [ 'package_id: string;', 'limit?: number;', 'next_page?: string;', 'covering_date?: string;', 'include_archived?: boolean;', 'starting_at?: string;', ], response: '{ contract_id: string; customer_id: string; starting_at: string; archived_at?: string; ending_before?: string; }', markdown: "## list_contracts_on_package\n\n`client.v1.packages.listContractsOnPackage(package_id: string, limit?: number, next_page?: string, covering_date?: string, include_archived?: boolean, starting_at?: string): { contract_id: string; customer_id: string; starting_at: string; archived_at?: string; ending_before?: string; }`\n\n**post** `/v1/packages/listContractsOnPackage`\n\nFor a given package, returns all contract IDs and customer IDs associated with the package over a specific time period. \n\n### Use this endpoint to:\n- Understand which customers are provisioned on a package at any given time for internal cohort management\n- Manage customer migrations to a new package. For example, to migrate all active customers to a new package, call this endpoint, end contracts, and provision customers on a new package.\n\n### **Usage guidelines:**\nUse the **`starting_at`**, **`covering_date`**, and **`include_archived`** parameters to filter the list of returned contracts. For example, to list only currently active contracts, pass **`covering_date`** equal to the current time.\n\n\n### Parameters\n\n- `package_id: string`\n\n- `limit?: number`\n Max number of results that should be returned\n\n- `next_page?: string`\n Cursor that indicates where the next page of results should start.\n\n- `covering_date?: string`\n Optional RFC 3339 timestamp. Only include contracts active on the provided date. This cannot be provided if starting_at filter is provided.\n\n- `include_archived?: boolean`\n Default false. Determines whether to include archived contracts in the results\n\n- `starting_at?: string`\n Optional RFC 3339 timestamp. Only include contracts that started on or after this date. This cannot be provided if covering_date filter is provided.\n\n### Returns\n\n- `{ contract_id: string; customer_id: string; starting_at: string; archived_at?: string; ending_before?: string; }`\n\n - `contract_id: string`\n - `customer_id: string`\n - `starting_at: string`\n - `archived_at?: string`\n - `ending_before?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\n// Automatically fetches more pages as needed.\nfor await (const packageListContractsOnPackageResponse of client.v1.packages.listContractsOnPackage({ package_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' })) {\n console.log(packageListContractsOnPackageResponse);\n}\n```", perLanguage: { typescript: { method: 'client.v1.packages.listContractsOnPackage', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\n// Automatically fetches more pages as needed.\nfor await (const packageListContractsOnPackageResponse of client.v1.packages.listContractsOnPackage(\n { package_id: '13117714-3f05-48e5-a6e9-a66093f13b4d' },\n)) {\n console.log(packageListContractsOnPackageResponse.contract_id);\n}", }, python: { method: 'v1.packages.list_contracts_on_package', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\npage = client.v1.packages.list_contracts_on_package(\n package_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n)\npage = page.data[0]\nprint(page.contract_id)', }, java: { method: 'v1().packages().listContractsOnPackage', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.packages.PackageListContractsOnPackagePage;\nimport com.metronome.api.models.v1.packages.PackageListContractsOnPackageParams;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PackageListContractsOnPackageParams params = PackageListContractsOnPackageParams.builder()\n .packageId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .build();\n PackageListContractsOnPackagePage page = client.v1().packages().listContractsOnPackage(params);\n }\n}', }, go: { method: 'client.V1.Packages.ListContractsOnPackage', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tpage, err := client.V1.Packages.ListContractsOnPackage(context.TODO(), metronome.V1PackageListContractsOnPackageParams{\n\t\tPackageID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", page)\n}\n', }, ruby: { method: 'v1.packages.list_contracts_on_package', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\npage = metronome.v1.packages.list_contracts_on_package(package_id: "13117714-3f05-48e5-a6e9-a66093f13b4d")\n\nputs(page)', }, http: { example: 'curl https://api.metronome.com/v1/packages/listContractsOnPackage \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "package_id": "13117714-3f05-48e5-a6e9-a66093f13b4d"\n }\'', }, }, }, { name: 'archive', endpoint: '/v1/packages/archive', httpMethod: 'post', summary: 'Archive a package', description: 'Archive a package. Archived packages cannot be used to create new contracts. However, existing contracts associated with the package will continue to function as normal. Once you archive a package, you can still retrieve it in the UI and API, but you cannot unarchive it.\n', stainlessPath: '(resource) v1.packages > (method) archive', qualified: 'client.v1.packages.archive', params: ['package_id: string;'], response: '{ data: { id: string; }; }', markdown: "## archive\n\n`client.v1.packages.archive(package_id: string): { data: id; }`\n\n**post** `/v1/packages/archive`\n\nArchive a package. Archived packages cannot be used to create new contracts. However, existing contracts associated with the package will continue to function as normal. Once you archive a package, you can still retrieve it in the UI and API, but you cannot unarchive it.\n\n\n### Parameters\n\n- `package_id: string`\n ID of the package to archive\n\n### Returns\n\n- `{ data: { id: string; }; }`\n\n - `data: { id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.packages.archive({ package_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc' });\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.packages.archive', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.packages.archive({\n package_id: 'd7abd0cd-4ae9-4db7-8676-e986a4ebd8dc',\n});\n\nconsole.log(response.data);", }, python: { method: 'v1.packages.archive', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.packages.archive(\n package_id="d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n)\nprint(response.data)', }, java: { method: 'v1().packages().archive', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.packages.PackageArchiveParams;\nimport com.metronome.api.models.v1.packages.PackageArchiveResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n PackageArchiveParams params = PackageArchiveParams.builder()\n .packageId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .build();\n PackageArchiveResponse response = client.v1().packages().archive(params);\n }\n}', }, go: { method: 'client.V1.Packages.Archive', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Packages.Archive(context.TODO(), metronome.V1PackageArchiveParams{\n\t\tPackageID: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response.Data)\n}\n', }, ruby: { method: 'v1.packages.archive', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.packages.archive(package_id: "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/packages/archive \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "package_id": "d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc"\n }\'', }, }, }, { name: 'upsert_avalara_credentials', endpoint: '/v1/upsertAvalaraCredentials', httpMethod: 'post', summary: 'Upsert Avalara credentials', description: 'Set the Avalara credentials for some specified `delivery_method_ids`, which can be found in the `/listConfiguredBillingProviders` response. This maps the Avalara credentials to the appropriate billing entity. These credentials are only used for PLG Invoicing today.\n', stainlessPath: '(resource) v1.settings > (method) upsert_avalara_credentials', qualified: 'client.v1.settings.upsertAvalaraCredentials', params: [ "avalara_environment: 'PRODUCTION' | 'SANDBOX';", 'avalara_password: string;', 'avalara_username: string;', 'delivery_method_ids: string[];', 'commit_transactions?: boolean;', ], response: '{ }', markdown: "## upsert_avalara_credentials\n\n`client.v1.settings.upsertAvalaraCredentials(avalara_environment: 'PRODUCTION' | 'SANDBOX', avalara_password: string, avalara_username: string, delivery_method_ids: string[], commit_transactions?: boolean): { }`\n\n**post** `/v1/upsertAvalaraCredentials`\n\nSet the Avalara credentials for some specified `delivery_method_ids`, which can be found in the `/listConfiguredBillingProviders` response. This maps the Avalara credentials to the appropriate billing entity. These credentials are only used for PLG Invoicing today.\n\n\n### Parameters\n\n- `avalara_environment: 'PRODUCTION' | 'SANDBOX'`\n The Avalara environment to use (SANDBOX or PRODUCTION).\n\n- `avalara_password: string`\n The password for the Avalara account.\n\n- `avalara_username: string`\n The username for the Avalara account.\n\n- `delivery_method_ids: string[]`\n The delivery method IDs of the billing provider configurations to update, can be found in the response of the `/listConfiguredBillingProviders` endpoint.\n\n- `commit_transactions?: boolean`\n Commit transactions if you want Metronome tax calculations used for reporting and tax filings.\n\n### Returns\n\n- `{ }`\n\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst response = await client.v1.settings.upsertAvalaraCredentials({\n avalara_environment: 'PRODUCTION',\n avalara_password: 'my_password_123',\n avalara_username: 'test@metronome.com',\n delivery_method_ids: ['9a906ebb-fbc7-42e8-8e29-53bfd2db3aca'],\n});\n\nconsole.log(response);\n```", perLanguage: { typescript: { method: 'client.v1.settings.upsertAvalaraCredentials', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst response = await client.v1.settings.upsertAvalaraCredentials({\n avalara_environment: 'PRODUCTION',\n avalara_password: 'my_password_123',\n avalara_username: 'test@metronome.com',\n delivery_method_ids: ['9a906ebb-fbc7-42e8-8e29-53bfd2db3aca'],\n commit_transactions: true,\n});\n\nconsole.log(response);", }, python: { method: 'v1.settings.upsert_avalara_credentials', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nresponse = client.v1.settings.upsert_avalara_credentials(\n avalara_environment="PRODUCTION",\n avalara_password="my_password_123",\n avalara_username="test@metronome.com",\n delivery_method_ids=["9a906ebb-fbc7-42e8-8e29-53bfd2db3aca"],\n commit_transactions=True,\n)\nprint(response)', }, java: { method: 'v1().settings().upsertAvalaraCredentials', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.settings.SettingUpsertAvalaraCredentialsParams;\nimport com.metronome.api.models.v1.settings.SettingUpsertAvalaraCredentialsResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n SettingUpsertAvalaraCredentialsParams params = SettingUpsertAvalaraCredentialsParams.builder()\n .avalaraEnvironment(SettingUpsertAvalaraCredentialsParams.AvalaraEnvironment.PRODUCTION)\n .avalaraPassword("my_password_123")\n .avalaraUsername("test@metronome.com")\n .addDeliveryMethodId("9a906ebb-fbc7-42e8-8e29-53bfd2db3aca")\n .build();\n SettingUpsertAvalaraCredentialsResponse response = client.v1().settings().upsertAvalaraCredentials(params);\n }\n}', }, go: { method: 'client.V1.Settings.UpsertAvalaraCredentials', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tresponse, err := client.V1.Settings.UpsertAvalaraCredentials(context.TODO(), metronome.V1SettingUpsertAvalaraCredentialsParams{\n\t\tAvalaraEnvironment: metronome.V1SettingUpsertAvalaraCredentialsParamsAvalaraEnvironmentProduction,\n\t\tAvalaraPassword: "my_password_123",\n\t\tAvalaraUsername: "test@metronome.com",\n\t\tDeliveryMethodIDs: []string{"9a906ebb-fbc7-42e8-8e29-53bfd2db3aca"},\n\t\tCommitTransactions: metronome.Bool(true),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", response)\n}\n', }, ruby: { method: 'v1.settings.upsert_avalara_credentials', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nresponse = metronome.v1.settings.upsert_avalara_credentials(\n avalara_environment: :PRODUCTION,\n avalara_password: "my_password_123",\n avalara_username: "test@metronome.com",\n delivery_method_ids: ["9a906ebb-fbc7-42e8-8e29-53bfd2db3aca"]\n)\n\nputs(response)', }, http: { example: 'curl https://api.metronome.com/v1/upsertAvalaraCredentials \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "avalara_environment": "PRODUCTION",\n "avalara_password": "my_password_123",\n "avalara_username": "test@metronome.com",\n "delivery_method_ids": [\n "9a906ebb-fbc7-42e8-8e29-53bfd2db3aca"\n ],\n "commit_transactions": true\n }\'', }, }, }, { name: 'create', endpoint: '/v1/setUpBillingProvider', httpMethod: 'post', summary: 'Set up account-level billing provider', description: 'Set up account-level configuration for a billing provider. Once configured, individual contracts across customers can be mapped to this configuration using the returned delivery_method_id.\n', stainlessPath: '(resource) v1.settings.billing_providers > (method) create', qualified: 'client.v1.settings.billingProviders.create', params: [ "billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace';", 'configuration: object;', "delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'aws_sns';", ], response: '{ data: { delivery_method_id: string; }; }', markdown: "## create\n\n`client.v1.settings.billingProviders.create(billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace', configuration: object, delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'aws_sns'): { data: object; }`\n\n**post** `/v1/setUpBillingProvider`\n\nSet up account-level configuration for a billing provider. Once configured, individual contracts across customers can be mapped to this configuration using the returned delivery_method_id.\n\n\n### Parameters\n\n- `billing_provider: 'aws_marketplace' | 'azure_marketplace' | 'gcp_marketplace'`\n The billing provider set for this configuration.\n\n- `configuration: object`\n Account-level configuration for the billing provider. The structure of this object is specific to the billing provider and delivery provider combination. See examples below.\n\n- `delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'aws_sns'`\n The method to use for delivering invoices for this configuration.\n\n### Returns\n\n- `{ data: { delivery_method_id: string; }; }`\n\n - `data: { delivery_method_id: string; }`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst billingProvider = await client.v1.settings.billingProviders.create({\n billing_provider: 'aws_marketplace',\n configuration: { aws_external_id: 'bar', aws_iam_role_arn: 'bar' },\n delivery_method: 'direct_to_billing_provider',\n});\n\nconsole.log(billingProvider);\n```", perLanguage: { typescript: { method: 'client.v1.settings.billingProviders.create', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst billingProvider = await client.v1.settings.billingProviders.create({\n billing_provider: 'aws_marketplace',\n configuration: {\n aws_external_id: '47b4f6b7-e297-42e8-b175-331d933b402c',\n aws_iam_role_arn: 'arn:aws:iam::test',\n },\n delivery_method: 'direct_to_billing_provider',\n});\n\nconsole.log(billingProvider.data);", }, python: { method: 'v1.settings.billing_providers.create', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nbilling_provider = client.v1.settings.billing_providers.create(\n billing_provider="aws_marketplace",\n configuration={\n "aws_external_id": "47b4f6b7-e297-42e8-b175-331d933b402c",\n "aws_iam_role_arn": "arn:aws:iam::test",\n },\n delivery_method="direct_to_billing_provider",\n)\nprint(billing_provider.data)', }, java: { method: 'v1().settings().billingProviders().create', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.settings.billingproviders.BillingProviderCreateParams;\nimport com.metronome.api.models.v1.settings.billingproviders.BillingProviderCreateResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillingProviderCreateParams params = BillingProviderCreateParams.builder()\n .billingProvider(BillingProviderCreateParams.BillingProvider.AWS_MARKETPLACE)\n .configuration(BillingProviderCreateParams.Configuration.builder()\n .putAdditionalProperty("aws_external_id", JsonValue.from("bar"))\n .putAdditionalProperty("aws_iam_role_arn", JsonValue.from("bar"))\n .build())\n .deliveryMethod(BillingProviderCreateParams.DeliveryMethod.DIRECT_TO_BILLING_PROVIDER)\n .build();\n BillingProviderCreateResponse billingProvider = client.v1().settings().billingProviders().create(params);\n }\n}', }, go: { method: 'client.V1.Settings.BillingProviders.New', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tbillingProvider, err := client.V1.Settings.BillingProviders.New(context.TODO(), metronome.V1SettingBillingProviderNewParams{\n\t\tBillingProvider: metronome.V1SettingBillingProviderNewParamsBillingProviderAwsMarketplace,\n\t\tConfiguration: map[string]any{\n\t\t\t"aws_external_id": "47b4f6b7-e297-42e8-b175-331d933b402c",\n\t\t\t"aws_iam_role_arn": "arn:aws:iam::test",\n\t\t},\n\t\tDeliveryMethod: metronome.V1SettingBillingProviderNewParamsDeliveryMethodDirectToBillingProvider,\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", billingProvider.Data)\n}\n', }, ruby: { method: 'v1.settings.billing_providers.create', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nbilling_provider = metronome.v1.settings.billing_providers.create(\n billing_provider: :aws_marketplace,\n configuration: {aws_external_id: "bar", aws_iam_role_arn: "bar"},\n delivery_method: :direct_to_billing_provider\n)\n\nputs(billing_provider)', }, http: { example: 'curl https://api.metronome.com/v1/setUpBillingProvider \\\n -H \'Content-Type: application/json\' \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \\\n -d \'{\n "billing_provider": "aws_marketplace",\n "configuration": {\n "aws_external_id": "bar",\n "aws_iam_role_arn": "bar"\n },\n "delivery_method": "direct_to_billing_provider"\n }\'', }, }, }, { name: 'list', endpoint: '/v1/listConfiguredBillingProviders', httpMethod: 'post', summary: 'List account-level billing providers', description: 'Lists all configured billing providers and their delivery method configurations for your account. Returns provider details, delivery method IDs, and configuration settings needed for mapping individual customer contracts to billing integrations.\n', stainlessPath: '(resource) v1.settings.billing_providers > (method) list', qualified: 'client.v1.settings.billingProviders.list', params: ['next_page?: string;'], response: "{ data: { billing_provider: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]; next_page?: string; }", markdown: "## list\n\n`client.v1.settings.billingProviders.list(next_page?: string): { data: object[]; next_page?: string; }`\n\n**post** `/v1/listConfiguredBillingProviders`\n\nLists all configured billing providers and their delivery method configurations for your account. Returns provider details, delivery method IDs, and configuration settings needed for mapping individual customer contracts to billing integrations.\n\n\n### Parameters\n\n- `next_page?: string`\n The cursor to the next page of results\n\n### Returns\n\n- `{ data: { billing_provider: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]; next_page?: string; }`\n\n - `data: { billing_provider: string; delivery_method: 'direct_to_billing_provider' | 'aws_sqs' | 'tackle' | 'aws_sns'; delivery_method_configuration: object; delivery_method_id: string; }[]`\n - `next_page?: string`\n\n### Example\n\n```typescript\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome();\n\nconst billingProviders = await client.v1.settings.billingProviders.list();\n\nconsole.log(billingProviders);\n```", perLanguage: { typescript: { method: 'client.v1.settings.billingProviders.list', example: "import Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst billingProviders = await client.v1.settings.billingProviders.list({\n next_page: 'af26878a-de62-4a0d-9b77-3936f7c2b6d6',\n});\n\nconsole.log(billingProviders.data);", }, python: { method: 'v1.settings.billing_providers.list', example: 'import os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\nbilling_providers = client.v1.settings.billing_providers.list(\n next_page="af26878a-de62-4a0d-9b77-3936f7c2b6d6",\n)\nprint(billing_providers.data)', }, java: { method: 'v1().settings().billingProviders().list', example: 'package com.metronome.api.example;\n\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.models.v1.settings.billingproviders.BillingProviderListParams;\nimport com.metronome.api.models.v1.settings.billingproviders.BillingProviderListResponse;\n\npublic final class Main {\n private Main() {}\n\n public static void main(String[] args) {\n MetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\n BillingProviderListResponse billingProviders = client.v1().settings().billingProviders().list();\n }\n}', }, go: { method: 'client.V1.Settings.BillingProviders.List', example: 'package main\n\nimport (\n\t"context"\n\t"fmt"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"),\n\t)\n\tbillingProviders, err := client.V1.Settings.BillingProviders.List(context.TODO(), metronome.V1SettingBillingProviderListParams{\n\t\tNextPage: metronome.String("af26878a-de62-4a0d-9b77-3936f7c2b6d6"),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf("%+v\\n", billingProviders.Data)\n}\n', }, ruby: { method: 'v1.settings.billing_providers.list', example: 'require "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(bearer_token: "My Bearer Token")\n\nbilling_providers = metronome.v1.settings.billing_providers.list\n\nputs(billing_providers)', }, http: { example: 'curl https://api.metronome.com/v1/listConfiguredBillingProviders \\\n -X POST \\\n -H "Authorization: Bearer $METRONOME_BEARER_TOKEN"', }, }, }, ]; const EMBEDDED_READMES: { language: string; content: string }[] = [ { language: 'go', content: '# Metronome Go API Library\n\nGo Reference\n\nThe Metronome Go library provides convenient access to the [Metronome REST API](https://docs.metronome.com)\nfrom applications written in Go.\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n\n\n```go\nimport (\n\t"github.com/Metronome-Industries/metronome-go" // imported as SDK_PackageName\n)\n```\n\n\n\nOr to pin the version:\n\n\n\n```sh\ngo get -u \'github.com/Metronome-Industries/metronome-go@v0.0.1\'\n```\n\n\n\n## Requirements\n\nThis library requires Go 1.22+.\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```go\npackage main\n\nimport (\n\t"context"\n\n\t"github.com/Metronome-Industries/metronome-go"\n\t"github.com/Metronome-Industries/metronome-go/option"\n)\n\nfunc main() {\n\tclient := metronome.NewClient(\n\t\toption.WithBearerToken("My Bearer Token"), // defaults to os.LookupEnv("METRONOME_BEARER_TOKEN")\n\t)\n\terr := client.V1.Usage.Ingest(context.TODO(), metronome.V1UsageIngestParams{\n\t\tUsage: []metronome.V1UsageIngestParamsUsage{{\n\t\t\tTransactionID: "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n\t\t\tCustomerID: "team@example.com",\n\t\t\tEventType: "heartbeat",\n\t\t\tTimestamp: "2024-01-01T00:00:00Z",\n\t\t\tProperties: map[string]any{\n\t\t\t\t"cluster_id": "42",\n\t\t\t\t"cpu_seconds": 60,\n\t\t\t\t"region": "Europe",\n\t\t\t},\n\t\t}},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n\n```\n\n### Request fields\n\nAll request parameters are wrapped in a generic `Field` type,\nwhich we use to distinguish zero values from null or omitted fields.\n\nThis prevents accidentally sending a zero value if you forget a required parameter,\nand enables explicitly sending `null`, `false`, `\'\'`, or `0` on optional parameters.\nAny field not specified is not sent.\n\nTo construct fields with values, use the helpers `String()`, `Int()`, `Float()`, or most commonly, the generic `F[T]()`.\nTo send a null, use `Null[T]()`, and to send a nonconforming value, use `Raw[T](any)`. For example:\n\n```go\nparams := FooParams{\n\tName: SDK_PackageName.F("hello"),\n\n\t// Explicitly send `"description": null`\n\tDescription: SDK_PackageName.Null[string](),\n\n\tPoint: SDK_PackageName.F(SDK_PackageName.Point{\n\t\tX: SDK_PackageName.Int(0),\n\t\tY: SDK_PackageName.Int(1),\n\n\t\t// In cases where the API specifies a given type,\n\t\t// but you want to send something else, use `Raw`:\n\t\tZ: SDK_PackageName.Raw[int64](0.01), // sends a float\n\t}),\n}\n```\n\n### Response objects\n\nAll fields in response structs are value types (not pointers or wrappers).\n\nIf a given field is `null`, not present, or invalid, the corresponding field\nwill simply be its zero value.\n\nAll response structs also include a special `JSON` field, containing more detailed\ninformation about each property, which you can use like so:\n\n```go\nif res.Name == "" {\n\t// true if `"name"` is either not present or explicitly null\n\tres.JSON.Name.IsNull()\n\n\t// true if the `"name"` key was not present in the response JSON at all\n\tres.JSON.Name.IsMissing()\n\n\t// When the API returns data that cannot be coerced to the expected type:\n\tif res.JSON.Name.IsInvalid() {\n\t\traw := res.JSON.Name.Raw()\n\n\t\tlegacyName := struct{\n\t\t\tFirst string `json:"first"`\n\t\t\tLast string `json:"last"`\n\t\t}{}\n\t\tjson.Unmarshal([]byte(raw), &legacyName)\n\t\tname = legacyName.First + " " + legacyName.Last\n\t}\n}\n```\n\nThese `.JSON` structs also include an `Extras` map containing\nany properties in the json response that were not specified\nin the struct. This can be useful for API features not yet\npresent in the SDK.\n\n```go\nbody := res.JSON.ExtraFields["my_unexpected_field"].Raw()\n```\n\n### RequestOptions\n\nThis library uses the functional options pattern. Functions defined in the\n`SDK_PackageOptionName` package return a `RequestOption`, which is a closure that mutates a\n`RequestConfig`. These options can be supplied to the client or at individual\nrequests. For example:\n\n```go\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\t// Adds a header to every request made by the client\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "custom_header_info"),\n)\n\nclient.V1.Contracts.New(context.TODO(), ...,\n\t// Override the header\n\tSDK_PackageOptionName.WithHeader("X-Some-Header", "some_other_custom_header_info"),\n\t// Add an undocumented field to the request body, using sjson syntax\n\tSDK_PackageOptionName.WithJSONSet("some.json.path", map[string]string{"my": "object"}),\n)\n```\n\nSee the [full list of request options](https://pkg.go.dev/github.com/Metronome-Industries/metronome-go/SDK_PackageOptionName).\n\n### Pagination\n\nThis library provides some conveniences for working with paginated list endpoints.\n\nYou can use `.ListAutoPaging()` methods to iterate through items across all pages:\n\n```go\niter := client.V1.Contracts.Products.ListAutoPaging(context.TODO(), metronome.V1ContractProductListParams{})\n// Automatically fetches more pages as needed.\nfor iter.Next() {\n\tv1ContractProductListResponse := iter.Current()\n\tfmt.Printf("%+v\\n", v1ContractProductListResponse)\n}\nif err := iter.Err(); err != nil {\n\tpanic(err.Error())\n}\n```\n\nOr you can use simple `.List()` methods to fetch a single page and receive a standard response object\nwith additional helper methods like `.GetNextPage()`, e.g.:\n\n```go\npage, err := client.V1.Contracts.Products.List(context.TODO(), metronome.V1ContractProductListParams{})\nfor page != nil {\n\tfor _, product := range page.Data {\n\t\tfmt.Printf("%+v\\n", product)\n\t}\n\tpage, err = page.GetNextPage()\n}\nif err != nil {\n\tpanic(err.Error())\n}\n```\n\n### Errors\n\nWhen the API returns a non-success status code, we return an error with type\n`*SDK_PackageName.Error`. This contains the `StatusCode`, `*http.Request`, and\n`*http.Response` values of the request, as well as the JSON of the error body\n(much like other response objects in the SDK).\n\nTo handle errors, we recommend that you use the `errors.As` pattern:\n\n```go\n_, err := client.V1.Contracts.New(context.TODO(), metronome.V1ContractNewParams{\n\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\tStartingAt: time.Now(),\n})\nif err != nil {\n\tvar apierr *metronome.Error\n\tif errors.As(err, &apierr) {\n\t\tprintln(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request\n\t\tprintln(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response\n\t}\n\tpanic(err.Error()) // GET "/v1/contracts/create": 400 Bad Request { ... }\n}\n```\n\nWhen other errors occur, they are returned unwrapped; for example,\nif HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.\n\n### Timeouts\n\nRequests do not time out by default; use context to configure a timeout for a request lifecycle.\n\nNote that if a request is [retried](#retries), the context timeout does not start over.\nTo set a per-retry timeout, use `SDK_PackageOptionName.WithRequestTimeout()`.\n\n```go\n// This sets the timeout for the request, including all the retries.\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)\ndefer cancel()\nclient.V1.Contracts.New(\n\tctx,\n\tmetronome.V1ContractNewParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tStartingAt: time.Now(),\n\t},\n\t// This sets the per-retry timeout\n\toption.WithRequestTimeout(20*time.Second),\n)\n```\n\n### File uploads\n\nRequest parameters that correspond to file uploads in multipart requests are typed as\n`param.Field[io.Reader]`. The contents of the `io.Reader` will by default be sent as a multipart form\npart with the file name of "anonymous_file" and content-type of "application/octet-stream".\n\nThe file name and content-type can be customized by implementing `Name() string` or `ContentType()\nstring` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a\nfile returned by `os.Open` will be sent with the file name on disk.\n\nWe also provide a helper `SDK_PackageName.FileParam(reader io.Reader, filename string, contentType string)`\nwhich can be used to wrap any `io.Reader` with the appropriate file name and content type.\n\n\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nWe retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit,\nand >=500 Internal errors.\n\nYou can use the `WithMaxRetries` option to configure or disable this:\n\n```go\n// Configure the default for all requests:\nclient := metronome.NewClient(\n\toption.WithMaxRetries(0), // default is 2\n)\n\n// Override per-request:\nclient.V1.Contracts.New(\n\tcontext.TODO(),\n\tmetronome.V1ContractNewParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tStartingAt: time.Now(),\n\t},\n\toption.WithMaxRetries(5),\n)\n```\n\n\n### Accessing raw response data (e.g. response headers)\n\nYou can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when\nyou need to examine response headers, status codes, or other details.\n\n```go\n// Create a variable to store the HTTP response\nvar response *http.Response\ncontract, err := client.V1.Contracts.New(\n\tcontext.TODO(),\n\tmetronome.V1ContractNewParams{\n\t\tCustomerID: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n\t\tStartingAt: time.Now(),\n\t},\n\toption.WithResponseInto(&response),\n)\nif err != nil {\n\t// handle error\n}\nfmt.Printf("%+v\\n", contract)\n\nfmt.Printf("Status Code: %d\\n", response.StatusCode)\nfmt.Printf("Headers: %+#v\\n", response.Header)\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs.\n`RequestOptions` on the client, such as retries, will be respected when making these requests.\n\n```go\nvar (\n // params can be an io.Reader, a []byte, an encoding/json serializable object,\n // or a "…Params" struct defined in this library.\n params map[string]interface{}\n\n // result can be an []byte, *http.Response, a encoding/json deserializable object,\n // or a model defined in this library.\n result *http.Response\n)\nerr := client.Post(context.Background(), "/unspecified", params, &result)\nif err != nil {\n …\n}\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use either the `SDK_PackageOptionName.WithQuerySet()`\nor the `SDK_PackageOptionName.WithJSONSet()` methods.\n\n```go\nparams := FooNewParams{\n ID: SDK_PackageName.F("id_xxxx"),\n Data: SDK_PackageName.F(FooNewParamsData{\n FirstName: SDK_PackageName.F("John"),\n }),\n}\nclient.Foo.New(context.Background(), params, SDK_PackageOptionName.WithJSONSet("data.last_name", "Doe"))\n```\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may either access the raw JSON of the response as a string\nwith `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with\n`result.JSON.Foo.Raw()`.\n\nAny fields that are not present on the response struct will be saved and can be accessed by `result.JSON.ExtraFields()` which returns the extra fields as a `map[string]Field`.\n\n### Middleware\n\nWe provide `SDK_PackageOptionName.WithMiddleware` which applies the given\nmiddleware to requests.\n\n```go\nfunc Logger(req *http.Request, next SDK_PackageOptionName.MiddlewareNext) (res *http.Response, err error) {\n\t// Before the request\n\tstart := time.Now()\n\tLogReq(req)\n\n\t// Forward the request to the next handler\n\tres, err = next(req)\n\n\t// Handle stuff after the request\n\tend := time.Now()\n\tLogRes(res, err, start - end)\n\n return res, err\n}\n\nclient := SDK_PackageName.SDK_ClientInitializerName(\n\tSDK_PackageOptionName.WithMiddleware(Logger),\n)\n```\n\nWhen multiple middlewares are provided as variadic arguments, the middlewares\nare applied left to right. If `SDK_PackageOptionName.WithMiddleware` is given\nmultiple times, for example first in the client then the method, the\nmiddleware in the client will run first and the middleware given in the method\nwill run next.\n\nYou may also replace the default `http.Client` with\n`SDK_PackageOptionName.WithHTTPClient(client)`. Only one http client is\naccepted (this overwrites any previous client) and receives requests after any\nmiddleware has been applied.\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/Metronome-Industries/metronome-go/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'java', content: '# Metronome Java API Library\n\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.metronome.api/metronome-java)](https://central.sonatype.com/artifact/com.metronome.api/metronome-java/0.0.1)\n[![javadoc](https://javadoc.io/badge2/com.metronome.api/metronome-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.metronome.api/metronome-java/0.0.1)\n\n\nThe Metronome Java SDK provides convenient access to the [Metronome REST API](https://docs.metronome.com) from applications written in Java.\n\n\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n\n\nThe REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.metronome.api/metronome-java/0.0.1).\n\n\n\n## Installation\n\n\n\n### Gradle\n\n~~~kotlin\nimplementation("com.metronome.api:metronome-java:0.0.1")\n~~~\n\n### Maven\n\n~~~xml\n\n com.metronome.api\n metronome-java\n 0.0.1\n\n~~~\n\n\n\n## Requirements\n\nThis library requires Java 8 or later.\n\n## Usage\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\nimport java.util.List;\n\n// Configures using the `metronome.bearerToken`, `metronome.webhookSecret` and `metronome.baseUrl` system properties\n// Or configures using the `METRONOME_BEARER_TOKEN`, `METRONOME_WEBHOOK_SECRET` and `METRONOME_BASE_URL` environment variables\nMetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\nList params = List.of(UsageIngestParams.Usage.builder()\n .transactionId("90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72")\n .customerId("team@example.com")\n .eventType("heartbeat")\n .timestamp("2024-01-01T00:00:00Z")\n .properties(UsageIngestParams.Usage.Properties.builder()\n .putAdditionalProperty("cluster_id", JsonValue.from("42"))\n .putAdditionalProperty("cpu_seconds", JsonValue.from(60))\n .putAdditionalProperty("region", JsonValue.from("Europe"))\n .build())\n .build());\nclient.v1().usage().ingest(params);\n```\n\n## Client configuration\n\nConfigure the client using system properties or environment variables:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\n// Configures using the `metronome.bearerToken`, `metronome.webhookSecret` and `metronome.baseUrl` system properties\n// Or configures using the `METRONOME_BEARER_TOKEN`, `METRONOME_WEBHOOK_SECRET` and `METRONOME_BASE_URL` environment variables\nMetronomeClient client = MetronomeOkHttpClient.fromEnv();\n```\n\nOr manually:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .bearerToken("My Bearer Token")\n .build();\n```\n\nOr using a combination of the two approaches:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n // Configures using the `metronome.bearerToken`, `metronome.webhookSecret` and `metronome.baseUrl` system properties\n // Or configures using the `METRONOME_BEARER_TOKEN`, `METRONOME_WEBHOOK_SECRET` and `METRONOME_BASE_URL` environment variables\n .fromEnv()\n .bearerToken("My Bearer Token")\n .build();\n```\n\nSee this table for the available options:\n\n| Setter | System property | Environment variable | Required | Default value |\n| --------------- | ------------------------- | -------------------------- | -------- | ----------------------------- |\n| `bearerToken` | `metronome.bearerToken` | `METRONOME_BEARER_TOKEN` | true | - |\n| `webhookSecret` | `metronome.webhookSecret` | `METRONOME_WEBHOOK_SECRET` | false | - |\n| `baseUrl` | `metronome.baseUrl` | `METRONOME_BASE_URL` | true | `"https://api.metronome.com"` |\n\nSystem properties take precedence over environment variables.\n\n> [!TIP]\n> Don\'t create more than one client in the same application. Each client has a connection pool and\n> thread pools, which are more efficient to share between requests.\n\n### Modifying configuration\n\nTo temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\n\nMetronomeClient clientWithOptions = client.withOptions(optionsBuilder -> {\n optionsBuilder.baseUrl("https://example.com");\n optionsBuilder.maxRetries(42);\n});\n```\n\nThe `withOptions()` method does not affect the original client or service.\n\n## Requests and responses\n\nTo send a request to the Metronome API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.\n\nFor example, `client.v1().contracts().create(...)` should be called with an instance of `ContractCreateParams`, and it will return an instance of `ContractCreateResponse`.\n\n## Immutability\n\nEach class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it.\n\nEach class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.\n\nBecause each class is immutable, builder modification will _never_ affect already built class instances.\n\n## Asynchronous execution\n\nThe default client is synchronous. To switch to asynchronous execution, call the `async()` method:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\nimport java.util.List;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `metronome.bearerToken`, `metronome.webhookSecret` and `metronome.baseUrl` system properties\n// Or configures using the `METRONOME_BEARER_TOKEN`, `METRONOME_WEBHOOK_SECRET` and `METRONOME_BASE_URL` environment variables\nMetronomeClient client = MetronomeOkHttpClient.fromEnv();\n\nList params = List.of(UsageIngestParams.Usage.builder()\n .transactionId("90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72")\n .customerId("team@example.com")\n .eventType("heartbeat")\n .timestamp("2024-01-01T00:00:00Z")\n .properties(UsageIngestParams.Usage.Properties.builder()\n .putAdditionalProperty("cluster_id", JsonValue.from("42"))\n .putAdditionalProperty("cpu_seconds", JsonValue.from(60))\n .putAdditionalProperty("region", JsonValue.from("Europe"))\n .build())\n .build());\nCompletableFuture future = client.async().v1().usage().ingest(params);\n```\n\nOr create an asynchronous client from the beginning:\n\n```java\nimport com.metronome.api.client.MetronomeClientAsync;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClientAsync;\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\nimport java.util.List;\nimport java.util.concurrent.CompletableFuture;\n\n// Configures using the `metronome.bearerToken`, `metronome.webhookSecret` and `metronome.baseUrl` system properties\n// Or configures using the `METRONOME_BEARER_TOKEN`, `METRONOME_WEBHOOK_SECRET` and `METRONOME_BASE_URL` environment variables\nMetronomeClientAsync client = MetronomeOkHttpClientAsync.fromEnv();\n\nList params = List.of(UsageIngestParams.Usage.builder()\n .transactionId("90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72")\n .customerId("team@example.com")\n .eventType("heartbeat")\n .timestamp("2024-01-01T00:00:00Z")\n .properties(UsageIngestParams.Usage.Properties.builder()\n .putAdditionalProperty("cluster_id", JsonValue.from("42"))\n .putAdditionalProperty("cpu_seconds", JsonValue.from(60))\n .putAdditionalProperty("region", JsonValue.from("Europe"))\n .build())\n .build());\nCompletableFuture future = client.v1().usage().ingest(params);\n```\n\nThe asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.\n\n\n\n\n\n## Binary responses\n\nThe SDK defines methods that return binary responses, which are used for API responses that shouldn\'t necessarily be parsed, like non-JSON data.\n\nThese methods return [`HttpResponse`](metronome-java-core/src/main/kotlin/com/metronome/api/core/http/HttpResponse.kt):\n\n```java\nimport com.metronome.api.core.http.HttpResponse;\nimport com.metronome.api.models.v1.customers.invoices.InvoiceRetrievePdfParams;\n\nInvoiceRetrievePdfParams params = InvoiceRetrievePdfParams.builder()\n .customerId("d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc")\n .invoiceId("6a37bb88-8538-48c5-b37b-a41c836328bd")\n .build();\nHttpResponse response = client.v1().customers().invoices().retrievePdf(params);\n```\n\nTo save the response content to a file, use the [`Files.copy(...)`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.io.InputStream-java.nio.file.Path-java.nio.file.CopyOption...-) method:\n\n```java\nimport com.metronome.api.core.http.HttpResponse;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\nimport java.nio.file.StandardCopyOption;\n\ntry (HttpResponse response = client.v1().customers().invoices().retrievePdf(params)) {\n Files.copy(\n response.body(),\n Paths.get(path),\n StandardCopyOption.REPLACE_EXISTING\n );\n} catch (Exception e) {\n System.out.println("Something went wrong!");\n throw new RuntimeException(e);\n}\n```\n\nOr transfer the response content to any [`OutputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStream.html):\n\n```java\nimport com.metronome.api.core.http.HttpResponse;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\ntry (HttpResponse response = client.v1().customers().invoices().retrievePdf(params)) {\n response.body().transferTo(Files.newOutputStream(Paths.get(path)));\n} catch (Exception e) {\n System.out.println("Something went wrong!");\n throw new RuntimeException(e);\n}\n```\n\n## Raw responses\n\nThe SDK defines methods that deserialize responses into instances of Java classes. However, these methods don\'t provide access to the response headers, status code, or the raw response body.\n\nTo access this data, prefix any HTTP method call on a client or service with `withRawResponse()`:\n\n```java\nimport com.metronome.api.core.http.Headers;\nimport com.metronome.api.core.http.HttpResponseFor;\nimport com.metronome.api.models.v1.contracts.ContractCreateParams;\nimport com.metronome.api.models.v1.contracts.ContractCreateResponse;\nimport java.time.OffsetDateTime;\n\nContractCreateParams params = ContractCreateParams.builder()\n .customerId("13117714-3f05-48e5-a6e9-a66093f13b4d")\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .build();\nHttpResponseFor contract = client.v1().contracts().withRawResponse().create(params);\n\nint statusCode = contract.statusCode();\nHeaders headers = contract.headers();\n```\n\nYou can still deserialize the response into an instance of a Java class if needed:\n\n```java\nimport com.metronome.api.models.v1.contracts.ContractCreateResponse;\n\nContractCreateResponse parsedContract = contract.parse();\n```\n\n## Error handling\n\nThe SDK throws custom unchecked exception types:\n\n- [`MetronomeServiceException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code:\n\n | Status | Exception |\n | ------ | -------------------------------------------------- |\n | 400 | [`BadRequestException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/BadRequestException.kt) |\n | 401 | [`UnauthorizedException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/UnauthorizedException.kt) |\n | 403 | [`PermissionDeniedException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/PermissionDeniedException.kt) |\n | 404 | [`NotFoundException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/NotFoundException.kt) |\n | 422 | [`UnprocessableEntityException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/UnprocessableEntityException.kt) |\n | 429 | [`RateLimitException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/RateLimitException.kt) |\n | 5xx | [`InternalServerException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/InternalServerException.kt) |\n | others | [`UnexpectedStatusCodeException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/UnexpectedStatusCodeException.kt) |\n\n- [`MetronomeIoException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeIoException.kt): I/O networking errors.\n\n- [`MetronomeRetryableException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeRetryableException.kt): Generic error indicating a failure that could be retried by the client.\n\n- [`MetronomeInvalidDataException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that\'s supposed to be required, but the API unexpectedly omitted it from the response.\n\n- [`MetronomeException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class.\n\n## Pagination\n\nThe SDK defines methods that return a paginated lists of results. It provides convenient ways to access the results either one page at a time or item-by-item across all pages.\n\n### Auto-pagination\n\nTo iterate through all results across all pages, use the `autoPager()` method, which automatically fetches more pages as needed.\n\nWhen using the synchronous client, the method returns an [`Iterable`](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html)\n\n```java\nimport com.metronome.api.models.v1.contracts.products.ProductListPage;\nimport com.metronome.api.models.v1.contracts.products.ProductListResponse;\n\nProductListPage page = client.v1().contracts().products().list();\n\n// Process as an Iterable\nfor (ProductListResponse product : page.autoPager()) {\n System.out.println(product);\n}\n\n// Process as a Stream\npage.autoPager()\n .stream()\n .limit(50)\n .forEach(product -> System.out.println(product));\n```\n\nWhen using the asynchronous client, the method returns an [`AsyncStreamResponse`](metronome-java-core/src/main/kotlin/com/metronome/api/core/http/AsyncStreamResponse.kt):\n\n```java\nimport com.metronome.api.core.http.AsyncStreamResponse;\nimport com.metronome.api.models.v1.contracts.products.ProductListPageAsync;\nimport com.metronome.api.models.v1.contracts.products.ProductListResponse;\nimport java.util.Optional;\nimport java.util.concurrent.CompletableFuture;\n\nCompletableFuture pageFuture = client.async().v1().contracts().products().list();\n\npageFuture.thenRun(page -> page.autoPager().subscribe(product -> {\n System.out.println(product);\n}));\n\n// If you need to handle errors or completion of the stream\npageFuture.thenRun(page -> page.autoPager().subscribe(new AsyncStreamResponse.Handler<>() {\n @Override\n public void onNext(ProductListResponse product) {\n System.out.println(product);\n }\n\n @Override\n public void onComplete(Optional error) {\n if (error.isPresent()) {\n System.out.println("Something went wrong!");\n throw new RuntimeException(error.get());\n } else {\n System.out.println("No more!");\n }\n }\n}));\n\n// Or use futures\npageFuture.thenRun(page -> page.autoPager()\n .subscribe(product -> {\n System.out.println(product);\n })\n .onCompleteFuture()\n .whenComplete((unused, error) -> {\n if (error != null) {\n System.out.println("Something went wrong!");\n throw new RuntimeException(error);\n } else {\n System.out.println("No more!");\n }\n }));\n```\n\n### Manual pagination\n\nTo access individual page items and manually request the next page, use the `items()`,\n`hasNextPage()`, and `nextPage()` methods:\n\n```java\nimport com.metronome.api.models.v1.contracts.products.ProductListPage;\nimport com.metronome.api.models.v1.contracts.products.ProductListResponse;\n\nProductListPage page = client.v1().contracts().products().list();\nwhile (true) {\n for (ProductListResponse product : page.items()) {\n System.out.println(product);\n }\n\n if (!page.hasNextPage()) {\n break;\n }\n\n page = page.nextPage();\n}\n```\n\n## Logging\n\nEnable logging by setting the `METRONOME_LOG` environment variable to `info`:\n\n```sh\nexport METRONOME_LOG=info\n```\n\nOr to `debug` for more verbose logging:\n\n```sh\nexport METRONOME_LOG=debug\n```\n\nOr configure the client manually using the `logLevel` method:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.LogLevel;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .logLevel(LogLevel.INFO)\n .build();\n```\n\n## ProGuard and R8\n\nAlthough the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `metronome-java-core` is published with a [configuration file](metronome-java-core/src/main/resources/META-INF/proguard/metronome-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage).\n\nProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.\n\n\n\n\n\n## Jackson\n\nThe SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.\n\nThe SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).\n\nIf the SDK threw an exception, but you\'re _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`MetronomeOkHttpClient`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClient.kt) or [`MetronomeOkHttpClientAsync`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClientAsync.kt).\n\n> [!CAUTION]\n> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.\n\nAlso note that there are bugs in older Jackson versions that can affect the SDK. We don\'t work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.\n\n## Network options\n\n### Retries\n\nThe SDK automatically retries 2 times by default, with a short exponential backoff between requests.\n\nOnly the following error types are retried:\n- Connection errors (for example, due to a network connectivity problem)\n- 408 Request Timeout\n- 409 Conflict\n- 429 Rate Limit\n- 5xx Internal\n\nThe API may also explicitly instruct the SDK to retry or not retry a request.\n\nTo set a custom number of retries, configure the client using the `maxRetries` method:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .maxRetries(4)\n .build();\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default.\n\nTo set a custom timeout, configure the method call using the `timeout` method:\n\n```java\nimport com.metronome.api.models.v1.contracts.ContractCreateResponse;\n\nContractCreateResponse contract = client.v1().contracts().create(\n params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()\n);\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport java.time.Duration;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .timeout(Duration.ofSeconds(30))\n .build();\n```\n\n### Proxies\n\nTo route requests through a proxy, configure the client using the `proxy` method:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport java.net.InetSocketAddress;\nimport java.net.Proxy;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .proxy(new Proxy(\n Proxy.Type.HTTP, new InetSocketAddress(\n "https://example.com", 8080\n )\n ))\n .build();\n```\n\nIf the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport com.metronome.api.core.http.ProxyAuthenticator;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .proxy(...)\n // Or a custom implementation of `ProxyAuthenticator`.\n .proxyAuthenticator(ProxyAuthenticator.basic("username", "password"))\n .build();\n```\n\n### Connection pooling\n\nTo customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\nimport java.time.Duration;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n // If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.\n .maxIdleConnections(10)\n .keepAliveDuration(Duration.ofMinutes(2))\n .build();\n```\n\nIf both options are unset, OkHttp\'s default connection pool settings are used.\n\n### HTTPS\n\n> [!NOTE]\n> Most applications should not call these methods, and instead use the system defaults. The defaults include\n> special optimizations that can be lost if the implementations are modified.\n\nTo configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa.\n .sslSocketFactory(yourSSLSocketFactory)\n .trustManager(yourTrustManager)\n .hostnameVerifier(yourHostnameVerifier)\n .build();\n```\n\n\n\n### Custom HTTP client\n\nThe SDK consists of three artifacts:\n- `metronome-java-core`\n - Contains core SDK logic\n - Does not depend on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`MetronomeClient`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClient.kt), [`MetronomeClientAsync`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientAsync.kt), [`MetronomeClientImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientImpl.kt), and [`MetronomeClientAsyncImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientAsyncImpl.kt), all of which can work with any HTTP client\n- `metronome-java-client-okhttp`\n - Depends on [OkHttp](https://square.github.io/okhttp)\n - Exposes [`MetronomeOkHttpClient`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClient.kt) and [`MetronomeOkHttpClientAsync`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClientAsync.kt), which provide a way to construct [`MetronomeClientImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientImpl.kt) and [`MetronomeClientAsyncImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientAsyncImpl.kt), respectively, using OkHttp\n- `metronome-java`\n - Depends on and exposes the APIs of both `metronome-java-core` and `metronome-java-client-okhttp`\n - Does not have its own logic\n\nThis structure allows replacing the SDK\'s default HTTP client without pulling in unnecessary dependencies.\n\n#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html)\n\n> [!TIP]\n> Try the available [network options](#network-options) before replacing the default client.\n\nTo use a customized `OkHttpClient`:\n\n1. Replace your [`metronome-java` dependency](#installation) with `metronome-java-core`\n2. Copy `metronome-java-client-okhttp`\'s [`OkHttpClient`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/OkHttpClient.kt) class into your code and customize it\n3. Construct [`MetronomeClientImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientImpl.kt) or [`MetronomeClientAsyncImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientAsyncImpl.kt), similarly to [`MetronomeOkHttpClient`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClient.kt) or [`MetronomeOkHttpClientAsync`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClientAsync.kt), using your customized client\n\n### Completely custom HTTP client\n\nTo use a completely custom HTTP client:\n\n1. Replace your [`metronome-java` dependency](#installation) with `metronome-java-core`\n2. Write a class that implements the [`HttpClient`](metronome-java-core/src/main/kotlin/com/metronome/api/core/http/HttpClient.kt) interface\n3. Construct [`MetronomeClientImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientImpl.kt) or [`MetronomeClientAsyncImpl`](metronome-java-core/src/main/kotlin/com/metronome/api/client/MetronomeClientAsyncImpl.kt), similarly to [`MetronomeOkHttpClient`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClient.kt) or [`MetronomeOkHttpClientAsync`](metronome-java-client-okhttp/src/main/kotlin/com/metronome/api/client/okhttp/MetronomeOkHttpClientAsync.kt), using your new client class\n\n## Undocumented API functionality\n\nThe SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.\n\n### Parameters\n\nTo set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class:\n\n```java\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\n\nUsageIngestParams params = UsageIngestParams.builder()\n .putAdditionalHeader("Secret-Header", "42")\n .putAdditionalQueryParam("secret_query_param", "42")\n .putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))\n .build();\n```\n\nThese can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods.\n\nTo set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class:\n\n```java\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.contracts.ContractCreateParams;\n\nContractCreateParams params = ContractCreateParams.builder()\n .billingProviderConfiguration(ContractCreateParams.BillingProviderConfiguration.builder()\n .putAdditionalProperty("secretProperty", JsonValue.from("42"))\n .build())\n .build();\n```\n\nThese properties can be accessed on the nested built object later using the `_additionalProperties()` method.\n\nTo set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](metronome-java-core/src/main/kotlin/com/metronome/api/core/Values.kt) object to its setter:\n\n```java\nimport com.metronome.api.core.JsonValue;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\n\nUsageIngestParams params = UsageIngestParams.builder()\n .usage(JsonValue.from(42))\n .build();\n```\n\nThe most straightforward way to create a [`JsonValue`](metronome-java-core/src/main/kotlin/com/metronome/api/core/Values.kt) is using its `from(...)` method:\n\n```java\nimport com.metronome.api.core.JsonValue;\nimport java.util.List;\nimport java.util.Map;\n\n// Create primitive JSON values\nJsonValue nullValue = JsonValue.from(null);\nJsonValue booleanValue = JsonValue.from(true);\nJsonValue numberValue = JsonValue.from(42);\nJsonValue stringValue = JsonValue.from("Hello World!");\n\n// Create a JSON array value equivalent to `["Hello", "World"]`\nJsonValue arrayValue = JsonValue.from(List.of(\n "Hello", "World"\n));\n\n// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }`\nJsonValue objectValue = JsonValue.from(Map.of(\n "a", 1,\n "b", 2\n));\n\n// Create an arbitrarily nested JSON equivalent to:\n// {\n// "a": [1, 2],\n// "b": [3, 4]\n// }\nJsonValue complexValue = JsonValue.from(Map.of(\n "a", List.of(\n 1, 2\n ),\n "b", List.of(\n 3, 4\n )\n));\n```\n\nNormally a `Builder` class\'s `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.\n\nTo forcibly omit a required parameter or property, pass [`JsonMissing`](metronome-java-core/src/main/kotlin/com/metronome/api/core/Values.kt):\n\n```java\nimport com.metronome.api.core.JsonMissing;\nimport com.metronome.api.models.v1.contracts.ContractCreateParams;\nimport com.metronome.api.models.v1.usage.UsageIngestParams;\nimport java.time.OffsetDateTime;\n\nUsageIngestParams params = ContractCreateParams.builder()\n .startingAt(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))\n .customerId(JsonMissing.of())\n .build();\n```\n\n### Response properties\n\nTo access undocumented response properties, call the `_additionalProperties()` method:\n\n```java\nimport com.metronome.api.core.JsonValue;\nimport java.util.Map;\n\nMap additionalProperties = client.v1().contracts().create(params)._additionalProperties();\nJsonValue secretPropertyValue = additionalProperties.get("secretProperty");\n\nString result = secretPropertyValue.accept(new JsonValue.Visitor<>() {\n @Override\n public String visitNull() {\n return "It\'s null!";\n }\n\n @Override\n public String visitBoolean(boolean value) {\n return "It\'s a boolean!";\n }\n\n @Override\n public String visitNumber(Number value) {\n return "It\'s a number!";\n }\n\n // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject`\n // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden\n});\n```\n\nTo access a property\'s raw JSON value, which may be undocumented, call its `_` prefixed method:\n\n```java\nimport com.metronome.api.core.JsonField;\nimport java.util.Optional;\n\nJsonField customerId = client.v1().contracts().create(params)._customerId();\n\nif (customerId.isMissing()) {\n // The property is absent from the JSON response\n} else if (customerId.isNull()) {\n // The property was set to literal null\n} else {\n // Check if value was provided as a string\n // Other methods include `asNumber()`, `asBoolean()`, etc.\n Optional jsonString = customerId.asString();\n\n // Try to deserialize into a custom type\n MyClass myObject = customerId.asUnknown().orElseThrow().convert(MyClass.class);\n}\n```\n\n### Response validation\n\nIn rare cases, the API may return a response that doesn\'t match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else.\n\nBy default, the SDK will not throw an exception in this case. It will throw [`MetronomeInvalidDataException`](metronome-java-core/src/main/kotlin/com/metronome/api/errors/MetronomeInvalidDataException.kt) only if you directly access the property.\n\nValidating the response is _not_ forwards compatible with new types from the API for existing fields.\n\nIf you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`:\n\n```java\nimport com.metronome.api.models.v1.contracts.ContractCreateResponse;\n\nContractCreateResponse contract = client.v1().contracts().create(params).validate();\n```\n\nOr configure the method call to validate the response using the `responseValidation` method:\n\n```java\nclient.v1().usage().ingest(RequestOptions.builder().responseValidation(true).build());\n```\n\nOr configure the default for all method calls at the client level:\n\n```java\nimport com.metronome.api.client.MetronomeClient;\nimport com.metronome.api.client.okhttp.MetronomeOkHttpClient;\n\nMetronomeClient client = MetronomeOkHttpClient.builder()\n .fromEnv()\n .responseValidation(true)\n .build();\n```\n\n## FAQ\n\n### Why don\'t you use plain `enum` classes?\n\nJava `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.\n\n### Why do you represent fields using `JsonField` instead of just plain `T`?\n\nUsing `JsonField` enables a few features:\n\n- Allowing usage of [undocumented API functionality](#undocumented-api-functionality)\n- Lazily [validating the API response against the expected shape](#response-validation)\n- Representing absent vs explicitly null values\n\n### Why don\'t you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)?\n\nIt is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don\'t want to introduce a breaking change every time we add a field to a class.\n\n### Why don\'t you use checked exceptions?\n\nChecked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason.\n\nChecked exceptions:\n\n- Are verbose to handle\n- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error\n- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function)\n- Don\'t play well with lambdas (also due to the function coloring problem)\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/Metronome-Industries/metronome-java/issues) with questions, bugs, or suggestions.\n', }, { language: 'python', content: '# Metronome Python API library\n\n\n[![PyPI version](https://img.shields.io/pypi/v/metronome-sdk.svg?label=pypi%20(stable))](https://pypi.org/project/metronome-sdk/)\n\nThe Metronome Python library provides convenient access to the Metronome REST API from any Python 3.9+\napplication. The library includes type definitions for all request params and response fields,\nand offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).\n\n\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nThe REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\n# install from PyPI\npip install metronome-sdk\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n```python\nimport os\nfrom metronome import Metronome\n\nclient = Metronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\n\nclient.v1.usage.ingest(\n usage=[{\n "transaction_id": "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n "customer_id": "team@example.com",\n "event_type": "heartbeat",\n "timestamp": "2024-01-01T00:00:00Z",\n "properties": {\n "cluster_id": "42",\n "cpu_seconds": 60,\n "region": "Europe",\n },\n }],\n)\n```\n\nWhile you can provide a `bearer_token` keyword argument,\nwe recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)\nto add `METRONOME_BEARER_TOKEN="My Bearer Token"` to your `.env` file\nso that your Bearer Token is not stored in source control.\n\n## Async usage\n\nSimply import `AsyncMetronome` instead of `Metronome` and use `await` with each API call:\n\n```python\nimport os\nimport asyncio\nfrom metronome import AsyncMetronome\n\nclient = AsyncMetronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n)\n\nasync def main() -> None:\n await client.v1.usage.ingest(\n usage=[{\n "transaction_id": "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n "customer_id": "team@example.com",\n "event_type": "heartbeat",\n "timestamp": "2024-01-01T00:00:00Z",\n "properties": {\n "cluster_id": "42",\n "cpu_seconds": 60,\n "region": "Europe",\n },\n }],\n )\n\nasyncio.run(main())\n```\n\nFunctionality between the synchronous and asynchronous clients is otherwise identical.\n\n### With aiohttp\n\nBy default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.\n\nYou can enable this by installing `aiohttp`:\n\n```sh\n# install from PyPI\npip install metronome-sdk[aiohttp]\n```\n\nThen you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:\n\n```python\nimport os\nimport asyncio\nfrom metronome import DefaultAioHttpClient\nfrom metronome import AsyncMetronome\n\nasync def main() -> None:\n async with AsyncMetronome(\n bearer_token=os.environ.get("METRONOME_BEARER_TOKEN"), # This is the default and can be omitted\n http_client=DefaultAioHttpClient(),\n) as client:\n await client.v1.usage.ingest(\n usage=[{\n "transaction_id": "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n "customer_id": "team@example.com",\n "event_type": "heartbeat",\n "timestamp": "2024-01-01T00:00:00Z",\n "properties": {\n "cluster_id": "42",\n "cpu_seconds": 60,\n "region": "Europe",\n },\n }],\n )\n\nasyncio.run(main())\n```\n\n\n\n## Using types\n\nNested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:\n\n- Serializing back into JSON, `model.to_json()`\n- Converting to a dictionary, `model.to_dict()`\n\nTyped requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.\n\n## Pagination\n\nList methods in the Metronome API are paginated.\n\nThis library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:\n\n```python\nfrom metronome import Metronome\n\nclient = Metronome()\n\nall_products = []\n# Automatically fetches more pages as needed.\nfor product in client.v1.contracts.products.list():\n # Do something with product here\n all_products.append(product)\nprint(all_products)\n```\n\nOr, asynchronously:\n\n```python\nimport asyncio\nfrom metronome import AsyncMetronome\n\nclient = AsyncMetronome()\n\nasync def main() -> None:\n all_products = []\n # Iterate through items across all pages, issuing requests as needed.\n async for product in client.v1.contracts.products.list():\n all_products.append(product)\n print(all_products)\n\nasyncio.run(main())\n```\n\nAlternatively, you can use the `.has_next_page()`, `.next_page_info()`, or `.get_next_page()` methods for more granular control working with pages:\n\n```python\nfirst_page = await client.v1.contracts.products.list()\nif first_page.has_next_page():\n print(f"will fetch next page using these details: {first_page.next_page_info()}")\n next_page = await first_page.get_next_page()\n print(f"number of items we just fetched: {len(next_page.data)}")\n\n# Remove `await` for non-async usage.\n```\n\nOr just work directly with the returned data:\n\n```python\nfirst_page = await client.v1.contracts.products.list()\n\nprint(f"next page cursor: {first_page.next_page}") # => "next page cursor: ..."\nfor product in first_page.data:\n print(product.id)\n\n# Remove `await` for non-async usage.\n```\n\nfrom datetime import datetime\n\n## Nested params\n\nNested parameters are dictionaries, typed using `TypedDict`, for example:\n\n```python\nfrom metronome import Metronome\n\nclient = Metronome()\n\ncontract = client.v1.contracts.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n billing_provider_configuration={\n "billing_provider": "stripe",\n "delivery_method": "direct_to_billing_provider",\n },\n)\nprint(contract.billing_provider_configuration)\n```\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `metronome.APIConnectionError` is raised.\n\nWhen the API returns a non-success status code (that is, 4xx or 5xx\nresponse), a subclass of `metronome.APIStatusError` is raised, containing `status_code` and `response` properties.\n\nAll errors inherit from `metronome.APIError`.\n\n```python\nfrom datetime import datetime\n\nimport metronome\nfrom metronome import Metronome\n\nclient = Metronome()\n\ntry:\n client.v1.contracts.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n )\nexcept metronome.APIConnectionError as e:\n print("The server could not be reached")\n print(e.__cause__) # an underlying Exception, likely raised within httpx.\nexcept metronome.RateLimitError as e:\n print("A 429 status code was received; we should back off a bit.")\nexcept metronome.APIStatusError as e:\n print("Another non-200-range status code was received")\n print(e.status_code)\n print(e.response)\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors are automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors are all retried by default.\n\nYou can use the `max_retries` option to configure or disable retry settings:\n\n```python\nfrom datetime import datetime\n\nfrom metronome import Metronome\n\n# Configure the default for all requests:\nclient = Metronome(\n # default is 2\n max_retries=0,\n)\n\n# Or, configure per-request:\nclient.with_options(max_retries = 5).v1.contracts.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\n```\n\n### Timeouts\n\nBy default requests time out after 1 minute. You can configure this with a `timeout` option,\nwhich accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:\n\n```python\nfrom datetime import datetime\n\nfrom metronome import Metronome\n\n# Configure the default for all requests:\nclient = Metronome(\n # 20 seconds (default is 1 minute)\n timeout=20.0,\n)\n\n# More granular control:\nclient = Metronome(\n timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),\n)\n\n# Override per-request:\nclient.with_options(timeout = 5.0).v1.contracts.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\n```\n\nOn timeout, an `APITimeoutError` is thrown.\n\nNote that requests that time out are [retried twice by default](#retries).\n\n\n\n## Advanced\n\n### Logging\n\nWe use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.\n\nYou can enable logging by setting the environment variable `METRONOME_LOG` to `info`.\n\n```shell\n$ export METRONOME_LOG=info\n```\n\nOr to `debug` for more verbose logging.\n\n### How to tell whether `None` means `null` or missing\n\nIn an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:\n\n```py\nif response.my_field is None:\n if \'my_field\' not in response.model_fields_set:\n print(\'Got json like {}, without a "my_field" key present at all.\')\n else:\n print(\'Got json like {"my_field": null}.\')\n```\n\n### Accessing raw response data (e.g. headers)\n\nThe "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,\n\n```py\nfrom datetime import datetime\n\nfrom metronome import Metronome\n\nclient = Metronome()\nresponse = client.v1.contracts.with_raw_response.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n)\nprint(response.headers.get(\'X-My-Header\'))\n\ncontract = response.parse() # get the object that `v1.contracts.create()` would have returned\nprint(contract.data)\n```\n\nfrom datetime import datetime\n\nThese methods return an [`APIResponse`](https://github.com/Metronome-Industries/metronome-python/tree/main/src/metronome/_response.py) object.\n\nThe async client returns an [`AsyncAPIResponse`](https://github.com/Metronome-Industries/metronome-python/tree/main/src/metronome/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.\n\n#### `.with_streaming_response`\n\nThe above interface eagerly reads the full response body when you make the request, which may not always be what you want.\n\nTo stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.\n\n```python\nwith client.v1.contracts.with_streaming_response.create(\n customer_id="13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at=datetime.fromisoformat("2020-01-01T00:00:00.000"),\n) as response :\n print(response.headers.get(\'X-My-Header\'))\n\n for line in response.iter_lines():\n print(line)\n```\n\nThe context manager is required so that the response will reliably be closed.\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API.\n\nIf you need to access undocumented endpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other\nhttp verbs. Options on the client will be respected (such as retries) when making this request.\n\n```py\nimport httpx\n\nresponse = client.post(\n "/foo",\n cast_to=httpx.Response,\n body={"my_param": True},\n)\n\nprint(response.headers.get("x-foo"))\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You\ncan also get all the extra fields on the Pydantic model as a dict with\n[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).\n\n### Configuring the HTTP client\n\nYou can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:\n\n- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)\n- Custom [transports](https://www.python-httpx.org/advanced/transports/)\n- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality\n\n```python\nimport httpx\nfrom metronome import Metronome, DefaultHttpxClient\n\nclient = Metronome(\n # Or use the `METRONOME_BASE_URL` env var\n base_url="http://my.test.server.example.com:8083",\n http_client=DefaultHttpxClient(proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0")),\n)\n```\n\nYou can also customize the client on a per-request basis by using `with_options()`:\n\n```python\nclient.with_options(http_client=DefaultHttpxClient(...))\n```\n\n### Managing HTTP resources\n\nBy default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.\n\n```py\nfrom metronome import Metronome\n\nwith Metronome() as client:\n # make requests here\n ...\n\n# HTTP client is now closed\n```\n\n## Versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/Metronome-Industries/metronome-python/issues) with questions, bugs, or suggestions.\n\n### Determining the installed version\n\nIf you\'ve upgraded to the latest version but aren\'t seeing any new features you were expecting then your python environment is likely still using an older version.\n\nYou can determine the version that is being used at runtime with:\n\n```py\nimport metronome\nprint(metronome.__version__)\n```\n\n## Requirements\n\nPython 3.9 or higher.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'ruby', content: '# Metronome Ruby API library\n\nThe Metronome Ruby library provides convenient access to the Metronome REST API from any Ruby 3.2.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – [see below](https://github.com/Metronome-Industries/metronome-ruby#Sorbet) for usage with Sorbet. The standard library\'s `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.\n\n\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Documentation\n\nDocumentation for releases of this gem can be found [on RubyDoc](https://gemdocs.org/gems/metronome-sdk).\n\nThe REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com).\n\n## Installation\n\nTo use this gem, install via Bundler by adding the following to your application\'s `Gemfile`:\n\n\n\n```ruby\ngem "metronome-sdk", "~> 0.0.1"\n```\n\n\n\n## Usage\n\n```ruby\nrequire "bundler/setup"\nrequire "metronome_sdk"\n\nmetronome = MetronomeSDK::Client.new(\n bearer_token: ENV["METRONOME_BEARER_TOKEN"] # This is the default and can be omitted\n)\n\nresult = metronome.v1.usage.ingest(\n usage: [\n {\n transaction_id: "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n customer_id: "team@example.com",\n event_type: "heartbeat",\n timestamp: "2024-01-01T00:00:00Z",\n properties: {cluster_id: "42", cpu_seconds: 60, region: "Europe"}\n }\n ]\n)\n\nputs(result)\n```\n\n\n\n### Pagination\n\nList methods in the Metronome API are paginated.\n\nThis library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:\n\n```ruby\npage = metronome.v1.contracts.products.list\n\n# Fetch single item from page.\nproduct = page.data[0]\nputs(product.id)\n\n# Automatically fetches more pages as needed.\npage.auto_paging_each do |product|\n puts(product.id)\nend\n```\n\nAlternatively, you can use the `#next_page?` and `#next_page` methods for more granular control working with pages.\n\n```ruby\nif page.next_page?\n new_page = page.next_page\n puts(new_page.data[0].id)\nend\n```\n\n\n\n### Handling errors\n\nWhen the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `MetronomeSDK::Errors::APIError` will be thrown:\n\n```ruby\nbegin\n contract = metronome.v1.contracts.create(\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z"\n )\nrescue MetronomeSDK::Errors::APIConnectionError => e\n puts("The server could not be reached")\n puts(e.cause) # an underlying Exception, likely raised within `net/http`\nrescue MetronomeSDK::Errors::RateLimitError => e\n puts("A 429 status code was received; we should back off a bit.")\nrescue MetronomeSDK::Errors::APIStatusError => e\n puts("Another non-200-range status code was received")\n puts(e.status)\nend\n```\n\nError codes are as follows:\n\n| Cause | Error Type |\n| ---------------- | -------------------------- |\n| HTTP 400 | `BadRequestError` |\n| HTTP 401 | `AuthenticationError` |\n| HTTP 403 | `PermissionDeniedError` |\n| HTTP 404 | `NotFoundError` |\n| HTTP 409 | `ConflictError` |\n| HTTP 422 | `UnprocessableEntityError` |\n| HTTP 429 | `RateLimitError` |\n| HTTP >= 500 | `InternalServerError` |\n| Other HTTP error | `APIStatusError` |\n| Timeout | `APITimeoutError` |\n| Network error | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\n\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.\n\nYou can use the `max_retries` option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nmetronome = MetronomeSDK::Client.new(\n max_retries: 0 # default is 2\n)\n\n# Or, configure per-request:\nmetronome.v1.contracts.create(\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z",\n request_options: {max_retries: 5}\n)\n```\n\n### Timeouts\n\nBy default, requests will time out after 60 seconds. You can use the timeout option to configure or disable this:\n\n```ruby\n# Configure the default for all requests:\nmetronome = MetronomeSDK::Client.new(\n timeout: nil # default is 60\n)\n\n# Or, configure per-request:\nmetronome.v1.contracts.create(\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z",\n request_options: {timeout: 5}\n)\n```\n\nOn timeout, `MetronomeSDK::Errors::APITimeoutError` is raised.\n\nNote that requests that time out are retried by default.\n\n## Advanced concepts\n\n### BaseModel\n\nAll parameter and response objects inherit from `MetronomeSDK::Internal::Type::BaseModel`, which provides several conveniences, including:\n\n1. All fields, including unknown ones, are accessible with `obj[:prop]` syntax, and can be destructured with `obj => {prop: prop}` or pattern-matching syntax.\n\n2. Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.\n\n3. Both instances and the classes themselves can be pretty-printed.\n\n4. Helpers such as `#to_h`, `#deep_to_h`, `#to_json`, and `#to_yaml`.\n\n### Making custom or undocumented requests\n\n#### Undocumented properties\n\nYou can send undocumented parameters to any endpoint, and read undocumented response properties, like so:\n\nNote: the `extra_` parameters of the same name overrides the documented parameters.\n\n```ruby\ncontract =\n metronome.v1.contracts.create(\n customer_id: "13117714-3f05-48e5-a6e9-a66093f13b4d",\n starting_at: "2020-01-01T00:00:00.000Z",\n request_options: {\n extra_query: {my_query_parameter: value},\n extra_body: {my_body_parameter: value},\n extra_headers: {"my-header": value}\n }\n )\n\nputs(contract[:my_undocumented_property])\n```\n\n#### Undocumented request params\n\nIf you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a request, as seen in the examples above.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests using `client.request`, like so:\n\n```ruby\nresponse = client.request(\n method: :post,\n path: \'/undocumented/endpoint\',\n query: {"dog": "woof"},\n headers: {"useful-header": "interesting-value"},\n body: {"hello": "world"}\n)\n```\n\n### Concurrency & connection pooling\n\nThe `MetronomeSDK::Client` instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.\n\nEach instance of `MetronomeSDK::Client` has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.\n\nWhen all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.\n\nUnless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.\n\n## Sorbet\n\nThis library provides comprehensive [RBI](https://sorbet.org/docs/rbi) definitions, and has no dependency on sorbet-runtime.\n\nYou can provide typesafe request parameters like so:\n\n```ruby\nmetronome.v1.usage.ingest(\n usage: [\n MetronomeSDK::V1::UsageIngestParams::Usage.new(\n transaction_id: "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n customer_id: "team@example.com",\n event_type: "heartbeat",\n timestamp: "2024-01-01T00:00:00Z",\n properties: {cluster_id: "42", cpu_seconds: 60, region: "Europe"}\n )\n ]\n)\n```\n\nOr, equivalently:\n\n```ruby\n# Hashes work, but are not typesafe:\nmetronome.v1.usage.ingest(\n usage: [\n {\n transaction_id: "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n customer_id: "team@example.com",\n event_type: "heartbeat",\n timestamp: "2024-01-01T00:00:00Z",\n properties: {cluster_id: "42", cpu_seconds: 60, region: "Europe"}\n }\n ]\n)\n\n# You can also splat a full Params class:\nparams = MetronomeSDK::V1::UsageIngestParams.new(\n usage: [\n MetronomeSDK::V1::UsageIngestParams::Usage.new(\n transaction_id: "90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72",\n customer_id: "team@example.com",\n event_type: "heartbeat",\n timestamp: "2024-01-01T00:00:00Z",\n properties: {cluster_id: "42", cpu_seconds: 60, region: "Europe"}\n )\n ]\n)\nmetronome.v1.usage.ingest(**params)\n```\n\n### Enums\n\nSince this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:\n\n```ruby\n# :LIST_RATE\nputs(MetronomeSDK::V2::ContractEditCommitParams::RateType::LIST_RATE)\n\n# Revealed type: `T.all(MetronomeSDK::V2::ContractEditCommitParams::RateType, Symbol)`\nT.reveal_type(MetronomeSDK::V2::ContractEditCommitParams::RateType::LIST_RATE)\n```\n\nEnum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:\n\n```ruby\n# Using the enum constants preserves the tagged type information:\nmetronome.v2.contracts.edit_commit(\n rate_type: MetronomeSDK::V2::ContractEditCommitParams::RateType::LIST_RATE,\n # …\n)\n\n# Literal values are also permissible:\nmetronome.v2.contracts.edit_commit(\n rate_type: :LIST_RATE,\n # …\n)\n```\n\n## Versioning\n\nThis package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.\n\nThis package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.\n\n## Requirements\n\nRuby 3.2.0 or higher.\n\n## Contributing\n\nSee [the contributing documentation](https://github.com/Metronome-Industries/metronome-ruby/tree/main/CONTRIBUTING.md).\n', }, { language: 'terraform', content: '# Metronome Terraform Provider\n\nThe [Metronome Terraform provider](https://registry.terraform.io/providers/Metronome-Industries/metronome/latest/docs) provides convenient access to\nthe [Metronome REST API](https://docs.metronome.com) from Terraform.\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## Requirements\n\nThis provider requires Terraform CLI 1.0 or later. You can [install it for your system](https://developer.hashicorp.com/terraform/install)\non Hashicorp\'s website.\n\n## Usage\n\nAdd the following to your `main.tf` file:\n\n\n\n```hcl\n# Declare the provider and version\nterraform {\n required_providers {\n SDK_ProviderTypeName = {\n source = "Metronome-Industries/metronome"\n version = "~> 0.0.1"\n }\n }\n}\n\n# Initialize the provider\nprovider "metronome" {\n bearer_token = "My Bearer Token" # or set METRONOME_BEARER_TOKEN env variable\n webhook_secret = "My Webhook Secret" # or set METRONOME_WEBHOOK_SECRET env variable\n}\n\n# Configure a resource\n\n```\n\n\n\nInitialize your project by running `terraform init` in the directory.\n\nAdditional examples can be found in the [./examples](./examples) folder within this repository, and you can\nrefer to the full documentation on [the Terraform Registry](https://registry.terraform.io/providers/Metronome-Industries/metronome/latest/docs).\n\n### Provider Options\nWhen you initialize the provider, the following options are supported. It is recommended to use environment variables for sensitive values like access tokens.\nIf an environment variable is provided, then the option does not need to be set in the terraform source.\n\n| Property | Environment variable | Required | Default value |\n| -------------- | -------------------------- | -------- | ------------- |\n| bearer_token | `METRONOME_BEARER_TOKEN` | true | — |\n| webhook_secret | `METRONOME_WEBHOOK_SECRET` | false | — |\n\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n2. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/Metronome-Industries/terraform-provider-metronome/issues) with questions, bugs, or suggestions.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n', }, { language: 'typescript', content: "# Metronome TypeScript API Library\n\n[![NPM version](https://img.shields.io/npm/v/@metronome/sdk.svg?label=npm%20(stable))](https://npmjs.org/package/@metronome/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@metronome/sdk)\n\nThis library provides convenient access to the Metronome REST API from server-side TypeScript or JavaScript.\n\n\n\nThe REST API documentation can be found on [docs.metronome.com](https://docs.metronome.com). The full API of this library can be found in [api.md](api.md).\n\nIt is generated with [Stainless](https://www.stainless.com/).\n\n## MCP Server\n\nUse the Metronome MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.\n\n[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=%40metronome%2Fmcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBtZXRyb25vbWUvbWNwIl0sImVudiI6eyJNRVRST05PTUVfQkVBUkVSX1RPS0VOIjoiTXkgQmVhcmVyIFRva2VuIiwiTUVUUk9OT01FX1dFQkhPT0tfU0VDUkVUIjoiTXkgV2ViaG9vayBTZWNyZXQifX0)\n[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22%40metronome%2Fmcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40metronome%2Fmcp%22%5D%2C%22env%22%3A%7B%22METRONOME_BEARER_TOKEN%22%3A%22My%20Bearer%20Token%22%2C%22METRONOME_WEBHOOK_SECRET%22%3A%22My%20Webhook%20Secret%22%7D%7D)\n\n> Note: You may need to set environment variables in your MCP client.\n\n## Installation\n\n```sh\nnpm install @metronome/sdk\n```\n\n\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n\n```js\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nawait client.v1.usage.ingest({\n usage: [\n {\n transaction_id: '90e9401f-0f8c-4cd3-9a9f-d6beb56d8d72',\n customer_id: 'team@example.com',\n event_type: 'heartbeat',\n timestamp: '2024-01-01T00:00:00Z',\n properties: {\n cluster_id: '42',\n cpu_seconds: 60,\n region: 'Europe',\n },\n },\n ],\n});\n```\n\n\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n\n```ts\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n bearerToken: process.env['METRONOME_BEARER_TOKEN'], // This is the default and can be omitted\n});\n\nconst params: Metronome.V1.ContractCreateParams = {\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n};\nconst contract: Metronome.V1.ContractCreateResponse = await client.v1.contracts.create(params);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n\n\n\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n\n```ts\nconst contract = await client.v1.contracts\n .create({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n })\n .catch(async (err) => {\n if (err instanceof Metronome.APIError) {\n console.log(err.status); // 400\n console.log(err.name); // BadRequestError\n console.log(err.headers); // {server: 'nginx', ...}\n } else {\n throw err;\n }\n });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type |\n| ----------- | -------------------------- |\n| 400 | `BadRequestError` |\n| 401 | `AuthenticationError` |\n| 403 | `PermissionDeniedError` |\n| 404 | `NotFoundError` |\n| 422 | `UnprocessableEntityError` |\n| 429 | `RateLimitError` |\n| >=500 | `InternalServerError` |\n| N/A | `APIConnectionError` |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n\n```js\n// Configure the default for all requests:\nconst client = new Metronome({\n maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.v1.contracts.create({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', starting_at: '2020-01-01T00:00:00.000Z' }, {\n maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n\n```ts\n// Configure the default for all requests:\nconst client = new Metronome({\n timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.v1.contracts.create({ customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d', starting_at: '2020-01-01T00:00:00.000Z' }, {\n timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n## Auto-pagination\n\nList methods in the Metronome API are paginated.\nYou can use the `for await … of` syntax to iterate through items across all pages:\n\n```ts\nasync function fetchAllProductListResponses(params) {\n const allProductListResponses = [];\n // Automatically fetches more pages as needed.\n for await (const productListResponse of client.v1.contracts.products.list()) {\n allProductListResponses.push(productListResponse);\n }\n return allProductListResponses;\n}\n```\n\nAlternatively, you can request a single page at a time:\n\n```ts\nlet page = await client.v1.contracts.products.list();\nfor (const productListResponse of page.data) {\n console.log(productListResponse);\n}\n\n// Convenience methods are provided for manually paginating:\nwhile (page.hasNextPage()) {\n page = await page.getNextPage();\n // ...\n}\n```\n\n\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n\n```ts\nconst client = new Metronome();\n\nconst response = await client.v1.contracts\n .create({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n })\n .asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: contract, response: raw } = await client.v1.contracts\n .create({\n customer_id: '13117714-3f05-48e5-a6e9-a66093f13b4d',\n starting_at: '2020-01-01T00:00:00.000Z',\n })\n .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(contract.data);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `METRONOME_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport Metronome from '@metronome/sdk';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new Metronome({\n logger: logger.child({ name: 'Metronome' }),\n logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Making custom/undocumented requests\n\nThis library is typed for convenient access to the documented API. If you need to access undocumented\nendpoints, params, or response properties, the library can still be used.\n\n#### Undocumented endpoints\n\nTo make requests to undocumented endpoints, you can use `client.get`, `client.post`, and other HTTP verbs.\nOptions on the client, such as retries, will be respected when making these requests.\n\n```ts\nawait client.post('/some/path', {\n body: { some_prop: 'foo' },\n query: { some_query_arg: 'bar' },\n});\n```\n\n#### Undocumented request params\n\nTo make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented\nparameter. This library doesn't validate at runtime that the request matches the type, so any extra values you\nsend will be sent as-is.\n\n```ts\nclient.v1.usage.ingest({\n // ...\n // @ts-expect-error baz is not yet public\n baz: 'undocumented option',\n});\n```\n\nFor requests with the `GET` verb, any extra params will be in the query, all other requests will send the\nextra param in the body.\n\nIf you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request\noptions.\n\n#### Undocumented response properties\n\nTo access undocumented response properties, you may access the response object with `// @ts-expect-error` on\nthe response object, or cast the response object to the requisite type. Like the request params, we do not\nvalidate or strip extra properties from the response from the API.\n\n### Customizing the fetch client\n\nBy default, this library expects a global `fetch` function is defined.\n\nIf you want to use a different `fetch` function, you can either polyfill the global:\n\n```ts\nimport fetch from 'my-fetch';\n\nglobalThis.fetch = fetch;\n```\n\nOr pass it to the client:\n\n```ts\nimport Metronome from '@metronome/sdk';\nimport fetch from 'my-fetch';\n\nconst client = new Metronome({ fetch });\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n fetchOptions: {\n // `RequestInit` options\n },\n});\n```\n\n#### Configuring proxies\n\nTo modify proxy behavior, you can provide custom `fetchOptions` that add runtime-specific proxy\noptions to requests:\n\n **Node** [[docs](https://github.com/nodejs/undici/blob/main/docs/docs/api/ProxyAgent.md#example---proxyagent-with-fetch)]\n\n```ts\nimport Metronome from '@metronome/sdk';\nimport * as undici from 'undici';\n\nconst proxyAgent = new undici.ProxyAgent('http://localhost:8888');\nconst client = new Metronome({\n fetchOptions: {\n dispatcher: proxyAgent,\n },\n});\n```\n\n **Bun** [[docs](https://bun.sh/guides/http/proxy)]\n\n```ts\nimport Metronome from '@metronome/sdk';\n\nconst client = new Metronome({\n fetchOptions: {\n proxy: 'http://localhost:8888',\n },\n});\n```\n\n **Deno** [[docs](https://docs.deno.com/api/deno/~/Deno.createHttpClient)]\n\n```ts\nimport Metronome from 'npm:@metronome/sdk';\n\nconst httpClient = Deno.createHttpClient({ proxy: { url: 'http://localhost:8888' } });\nconst client = new Metronome({\n fetchOptions: {\n client: httpClient,\n },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/Metronome-Industries/metronome-node/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n", }, ]; const INDEX_OPTIONS = { fields: [ 'name', 'endpoint', 'summary', 'description', 'qualified', 'stainlessPath', 'content', 'sectionContext', ], storeFields: ['kind', '_original'], searchOptions: { prefix: true, fuzzy: 0.1, boost: { name: 5, stainlessPath: 3, endpoint: 3, qualified: 3, summary: 2, content: 1, description: 1, } as Record, }, }; /** * Self-contained local search engine backed by MiniSearch. * Method data is embedded at SDK build time; prose documents * can be loaded from an optional docs directory at runtime. */ export class LocalDocsSearch { private methodIndex: MiniSearch; private proseIndex: MiniSearch; private constructor() { this.methodIndex = new MiniSearch(INDEX_OPTIONS); this.proseIndex = new MiniSearch(INDEX_OPTIONS); } static async create(opts?: { docsDir?: string }): Promise { const instance = new LocalDocsSearch(); instance.indexMethods(EMBEDDED_METHODS); for (const readme of EMBEDDED_READMES) { instance.indexProse(readme.content, `readme:${readme.language}`); } if (opts?.docsDir) { await instance.loadDocsDirectory(opts.docsDir); } return instance; } search(props: { query: string; language?: string; detail?: string; maxResults?: number; maxLength?: number; }): SearchResult { const { query, language = 'typescript', detail = 'default', maxResults = 5, maxLength = 100_000 } = props; const useMarkdown = detail === 'verbose' || detail === 'high'; // Search both indices and merge results by score. // Filter prose hits so language-tagged content (READMEs and docs with // frontmatter) only matches the requested language. const methodHits = this.methodIndex .search(query) .map((hit) => ({ ...hit, _kind: 'http_method' as const })); const proseHits = this.proseIndex .search(query) .filter((hit) => { const source = ((hit as Record)['_original'] as ProseChunk | undefined)?.source; if (!source) return true; // Check for language-tagged sources: "readme:" or "lang::" let taggedLang: string | undefined; if (source.startsWith('readme:')) taggedLang = source.slice('readme:'.length); else if (source.startsWith('lang:')) taggedLang = source.split(':')[1]; if (!taggedLang) return true; return taggedLang === language || (language === 'javascript' && taggedLang === 'typescript'); }) .map((hit) => ({ ...hit, _kind: 'prose' as const })); const merged = [...methodHits, ...proseHits].sort((a, b) => b.score - a.score); const top = merged.slice(0, maxResults); const fullResults: (string | Record)[] = []; for (const hit of top) { const original = (hit as Record)['_original']; if (hit._kind === 'http_method') { const m = original as MethodEntry; if (useMarkdown && m.markdown) { fullResults.push(m.markdown); } else { // Use per-language data when available, falling back to the // top-level fields (which are TypeScript-specific in the // legacy codepath). const langData = m.perLanguage?.[language]; fullResults.push({ method: langData?.method ?? m.qualified, summary: m.summary, description: m.description, endpoint: `${m.httpMethod.toUpperCase()} ${m.endpoint}`, ...(langData?.example ? { example: langData.example } : {}), ...(m.params ? { params: m.params } : {}), ...(m.response ? { response: m.response } : {}), }); } } else { const c = original as ProseChunk; fullResults.push({ content: c.content, ...(c.source ? { source: c.source } : {}), }); } } let totalLength = 0; const results: (string | Record)[] = []; for (const result of fullResults) { const len = typeof result === 'string' ? result.length : JSON.stringify(result).length; totalLength += len; if (totalLength > maxLength) break; results.push(result); } if (results.length < fullResults.length) { results.unshift(`Truncated; showing ${results.length} of ${fullResults.length} results.`); } return { results }; } private indexMethods(methods: MethodEntry[]): void { const docs: MiniSearchDocument[] = methods.map((m, i) => ({ id: `method-${i}`, kind: 'http_method' as const, name: m.name, endpoint: m.endpoint, summary: m.summary, description: m.description, qualified: m.qualified, stainlessPath: m.stainlessPath, _original: m as unknown as Record, })); if (docs.length > 0) { this.methodIndex.addAll(docs); } } private async loadDocsDirectory(docsDir: string): Promise { let entries; try { entries = await fs.readdir(docsDir, { withFileTypes: true }); } catch (err) { getLogger().warn({ err, docsDir }, 'Could not read docs directory'); return; } const files = entries .filter((e) => e.isFile()) .filter((e) => e.name.endsWith('.md') || e.name.endsWith('.markdown') || e.name.endsWith('.json')); for (const file of files) { try { const filePath = path.join(docsDir, file.name); const content = await fs.readFile(filePath, 'utf-8'); if (file.name.endsWith('.json')) { const texts = extractTexts(JSON.parse(content)); if (texts.length > 0) { this.indexProse(texts.join('\n\n'), file.name); } } else { // Parse optional YAML frontmatter for language tagging. // Files with a "language" field in frontmatter will only // surface in searches for that language. // // Example: // --- // language: python // --- // # Error handling in Python // ... const frontmatter = parseFrontmatter(content); const source = frontmatter.language ? `lang:${frontmatter.language}:${file.name}` : file.name; this.indexProse(content, source); } } catch (err) { getLogger().warn({ err, file: file.name }, 'Failed to index docs file'); } } } private indexProse(markdown: string, source: string): void { const chunks = chunkMarkdown(markdown); const baseId = this.proseIndex.documentCount; const docs: MiniSearchDocument[] = chunks.map((chunk, i) => ({ id: `prose-${baseId + i}`, kind: 'prose' as const, content: chunk.content, ...(chunk.sectionContext != null ? { sectionContext: chunk.sectionContext } : {}), _original: { ...chunk, source } as unknown as Record, })); if (docs.length > 0) { this.proseIndex.addAll(docs); } } } /** Lightweight markdown chunker — splits on headers, chunks by word count. */ function chunkMarkdown(markdown: string): { content: string; tag: string; sectionContext?: string }[] { // Strip YAML frontmatter const stripped = markdown.replace(/^---\n[\s\S]*?\n---\n?/, ''); const lines = stripped.split('\n'); const chunks: { content: string; tag: string; sectionContext?: string }[] = []; const headers: string[] = []; let current: string[] = []; const flush = () => { const text = current.join('\n').trim(); if (!text) return; const sectionContext = headers.length > 0 ? headers.join(' > ') : undefined; // Split into ~200-word chunks const words = text.split(/\s+/); for (let i = 0; i < words.length; i += 200) { const slice = words.slice(i, i + 200).join(' '); if (slice) { chunks.push({ content: slice, tag: 'p', ...(sectionContext != null ? { sectionContext } : {}) }); } } current = []; }; for (const line of lines) { const headerMatch = line.match(/^(#{1,6})\s+(.+)/); if (headerMatch) { flush(); const level = headerMatch[1]!.length; const text = headerMatch[2]!.trim(); while (headers.length >= level) headers.pop(); headers.push(text); } else { current.push(line); } } flush(); return chunks; } /** Recursively extracts string values from a JSON structure. */ function extractTexts(data: unknown, depth = 0): string[] { if (depth > 10) return []; if (typeof data === 'string') return data.trim() ? [data] : []; if (Array.isArray(data)) return data.flatMap((item) => extractTexts(item, depth + 1)); if (typeof data === 'object' && data !== null) { return Object.values(data).flatMap((v) => extractTexts(v, depth + 1)); } return []; } /** Parses YAML frontmatter from a markdown string, extracting the language field if present. */ function parseFrontmatter(markdown: string): { language?: string } { const match = markdown.match(/^---\n([\s\S]*?)\n---/); if (!match) return {}; const body = match[1] ?? ''; const langMatch = body.match(/^language:\s*(.+)$/m); return langMatch ? { language: langMatch[1]!.trim() } : {}; }