Class: MetronomeSDK::Resources::V1::Contracts
- Inherits:
-
Object
- Object
- MetronomeSDK::Resources::V1::Contracts
- Defined in:
- lib/metronome_sdk/resources/v1/contracts.rb,
lib/metronome_sdk/resources/v1/contracts/products.rb,
lib/metronome_sdk/resources/v1/contracts/rate_cards.rb,
lib/metronome_sdk/resources/v1/contracts/named_schedules.rb,
lib/metronome_sdk/resources/v1/contracts/rate_cards/rates.rb,
lib/metronome_sdk/resources/v1/contracts/rate_cards/product_orders.rb,
lib/metronome_sdk/resources/v1/contracts/rate_cards/named_schedules.rb,
sig/metronome_sdk/resources/v1/contracts.rbs,
sig/metronome_sdk/resources/v1/contracts/products.rbs,
sig/metronome_sdk/resources/v1/contracts/rate_cards.rbs,
sig/metronome_sdk/resources/v1/contracts/named_schedules.rbs,
sig/metronome_sdk/resources/v1/contracts/rate_cards/rates.rbs,
sig/metronome_sdk/resources/v1/contracts/rate_cards/product_orders.rbs,
sig/metronome_sdk/resources/v1/contracts/rate_cards/named_schedules.rbs
Defined Under Namespace
Classes: NamedSchedules, Products, RateCards
Instance Attribute Summary collapse
-
#named_schedules ⇒ MetronomeSDK::Resources::V1::Contracts::NamedSchedules
readonly
Named schedules are used for storing custom data that can change over time.
-
#products ⇒ MetronomeSDK::Resources::V1::Contracts::Products
readonly
Products are the items that customers purchase.
-
#rate_cards ⇒ MetronomeSDK::Resources::V1::Contracts::RateCards
readonly
Rate cards are used to define default pricing for products.
Instance Method Summary collapse
-
#add_manual_balance_entry(id:, amount:, customer_id:, reason:, segment_id:, contract_id: nil, per_group_amounts: nil, timestamp: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::V1::ContractAddManualBalanceEntryParams for more details.
-
#amend(contract_id:, customer_id:, starting_at:, commits: nil, credits: nil, custom_fields: nil, discounts: nil, netsuite_sales_order_id: nil, overrides: nil, professional_services: nil, reseller_royalties: nil, salesforce_opportunity_id: nil, scheduled_charges: nil, total_contract_value: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractAmendResponse
Amendments will be replaced by Contract editing.
-
#archive(contract_id:, customer_id:, void_invoices:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractArchiveResponse
Some parameter documentations has been truncated, see Models::V1::ContractArchiveParams for more details.
-
#create(customer_id:, starting_at:, billing_provider_configuration: nil, commits: nil, credits: nil, custom_fields: nil, discounts: nil, ending_before: nil, hierarchy_configuration: nil, multiplier_override_prioritization: nil, name: nil, net_payment_terms_days: nil, netsuite_sales_order_id: nil, overrides: nil, package_alias: nil, package_id: nil, prepaid_balance_threshold_configuration: nil, professional_services: nil, rate_card_alias: nil, rate_card_id: nil, recurring_commits: nil, recurring_credits: nil, reseller_royalties: nil, revenue_system_configuration: nil, salesforce_opportunity_id: nil, scheduled_charges: nil, scheduled_charges_on_usage_invoices: nil, spend_threshold_configuration: nil, spend_trackers: nil, subscriptions: nil, total_contract_value: nil, transition: nil, uniqueness_key: nil, usage_filter: nil, usage_statement_schedule: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractCreateResponse
Some parameter documentations has been truncated, see Models::V1::ContractCreateParams for more details.
-
#create_historical_invoices(invoices:, preview:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractCreateHistoricalInvoicesResponse
Create historical usage invoices for past billing periods on specific contracts.
-
#get_net_balance(customer_id:, credit_type_id: nil, filters: nil, invoice_inclusion_mode: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractGetNetBalanceResponse
Some parameter documentations has been truncated, see Models::V1::ContractGetNetBalanceParams for more details.
-
#get_subscription_seats_history(contract_id:, customer_id:, subscription_id:, covering_date: nil, cursor: nil, ending_before: nil, limit: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractGetSubscriptionSeatsHistoryResponse
Some parameter documentations has been truncated, see Models::V1::ContractGetSubscriptionSeatsHistoryParams for more details.
-
#initialize(client:) ⇒ Contracts
constructor
private
A new instance of Contracts.
-
#list(customer_id:, covering_date: nil, include_archived: nil, include_balance: nil, include_ledgers: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractListResponse
Some parameter documentations has been truncated, see Models::V1::ContractListParams for more details.
-
#list_balances(customer_id:, id: nil, covering_date: nil, effective_before: nil, exclude_zero_balances: nil, include_archived: nil, include_balance: nil, include_contract_balances: nil, include_ledgers: nil, limit: nil, next_page: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Internal::BodyCursorPage<MetronomeSDK::Models::Commit, MetronomeSDK::Models::Credit>
Some parameter documentations has been truncated, see Models::V1::ContractListBalancesParams for more details.
-
#list_seat_balances(contract_id:, customer_id:, covering_date: nil, cursor: nil, effective_before: nil, include_credits_and_commits: nil, include_ledgers: nil, limit: nil, seat_ids: nil, skip_missing_seat_ids: nil, starting_at: nil, subscription_ids: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractListSeatBalancesResponse
Some parameter documentations has been truncated, see Models::V1::ContractListSeatBalancesParams for more details.
-
#retrieve(contract_id:, customer_id:, include_balance: nil, include_ledgers: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveParams for more details.
-
#retrieve_rate_schedule(contract_id:, customer_id:, limit: nil, next_page: nil, at: nil, selectors: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveRateScheduleResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveRateScheduleParams for more details.
-
#retrieve_subscription_quantity_history(contract_id:, customer_id:, subscription_id:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveSubscriptionQuantityHistoryResponse
Get the history of subscription quantities and prices over time for a given
subscription_id. -
#schedule_pro_services_invoice(contract_id:, customer_id:, issued_at:, line_items:, netsuite_invoice_header_end: nil, netsuite_invoice_header_start: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractScheduleProServicesInvoiceResponse
Create a new scheduled invoice for Professional Services terms on a contract.
-
#set_usage_filter(contract_id:, customer_id:, group_key:, group_values:, starting_at:, request_options: {}) ⇒ nil
If a customer has multiple contracts with overlapping rates, the usage filter routes usage to the appropriate contract based on a predefined group key.
-
#update_end_date(contract_id:, customer_id:, allow_ending_before_finalized_invoice: nil, ending_before: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractUpdateEndDateResponse
Some parameter documentations has been truncated, see Models::V1::ContractUpdateEndDateParams for more details.
Constructor Details
#initialize(client:) ⇒ Contracts
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Contracts.
980 981 982 983 984 985 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 980 def initialize(client:) @client = client @products = MetronomeSDK::Resources::V1::Contracts::Products.new(client: client) @rate_cards = MetronomeSDK::Resources::V1::Contracts::RateCards.new(client: client) @named_schedules = MetronomeSDK::Resources::V1::Contracts::NamedSchedules.new(client: client) end |
Instance Attribute Details
#named_schedules ⇒ MetronomeSDK::Resources::V1::Contracts::NamedSchedules (readonly)
Named schedules are used for storing custom data that can change over time. Named schedules are often used in custom pricing logic.
18 19 20 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 18 def named_schedules @named_schedules end |
#products ⇒ MetronomeSDK::Resources::V1::Contracts::Products (readonly)
Products are the items that customers purchase.
9 10 11 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 9 def products @products end |
#rate_cards ⇒ MetronomeSDK::Resources::V1::Contracts::RateCards (readonly)
Rate cards are used to define default pricing for products.
13 14 15 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 13 def rate_cards @rate_cards end |
Instance Method Details
#add_manual_balance_entry(id:, amount:, customer_id:, reason:, segment_id:, contract_id: nil, per_group_amounts: nil, timestamp: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::V1::ContractAddManualBalanceEntryParams for more details.
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.
Use this endpoint to:
- Address incorrect usage burn-down caused by malformed usage or invalid config
- Decrease available balance to account for outages where usage may have not been tracked or sent to Metronome
- Issue credits to customers in the form of increased balance on existing commit or credit
Usage guidelines:
Manual 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.
354 355 356 357 358 359 360 361 362 363 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 354 def add_manual_balance_entry(params) parsed, = MetronomeSDK::V1::ContractAddManualBalanceEntryParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/addManualBalanceLedgerEntry", body: parsed, model: NilClass, options: ) end |
#amend(contract_id:, customer_id:, starting_at:, commits: nil, credits: nil, custom_fields: nil, discounts: nil, netsuite_sales_order_id: nil, overrides: nil, professional_services: nil, reseller_royalties: nil, salesforce_opportunity_id: nil, scheduled_charges: nil, total_contract_value: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractAmendResponse
Amendments will be replaced by Contract editing. New clients should implement
using the editContract endpoint. Read more about the migration to contract
editing here and
reach out to your Metronome representative for more details. Once contract
editing is enabled, access to this endpoint will be removed.
406 407 408 409 410 411 412 413 414 415 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 406 def amend(params) parsed, = MetronomeSDK::V1::ContractAmendParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/amend", body: parsed, model: MetronomeSDK::Models::V1::ContractAmendResponse, options: ) end |
#archive(contract_id:, customer_id:, void_invoices:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractArchiveResponse
Some parameter documentations has been truncated, see Models::V1::ContractArchiveParams for more details.
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.
Impact on commits and credits:
When 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.
Archived contract visibility:
Archived 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.
454 455 456 457 458 459 460 461 462 463 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 454 def archive(params) parsed, = MetronomeSDK::V1::ContractArchiveParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/archive", body: parsed, model: MetronomeSDK::Models::V1::ContractArchiveResponse, options: ) end |
#create(customer_id:, starting_at:, billing_provider_configuration: nil, commits: nil, credits: nil, custom_fields: nil, discounts: nil, ending_before: nil, hierarchy_configuration: nil, multiplier_override_prioritization: nil, name: nil, net_payment_terms_days: nil, netsuite_sales_order_id: nil, overrides: nil, package_alias: nil, package_id: nil, prepaid_balance_threshold_configuration: nil, professional_services: nil, rate_card_alias: nil, rate_card_id: nil, recurring_commits: nil, recurring_credits: nil, reseller_royalties: nil, revenue_system_configuration: nil, salesforce_opportunity_id: nil, scheduled_charges: nil, scheduled_charges_on_usage_invoices: nil, spend_threshold_configuration: nil, spend_trackers: nil, subscriptions: nil, total_contract_value: nil, transition: nil, uniqueness_key: nil, usage_filter: nil, usage_statement_schedule: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractCreateResponse
Some parameter documentations has been truncated, see Models::V1::ContractCreateParams for more details.
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.
Use this endpoint to:
- PLG onboarding: Automatically provision new self-serve customers with contracts when they sign up.
- Enterprise sales: Push negotiated contracts from Salesforce with custom pricing and commitments
- Promotional pricing: Implement time-limited discounts and free trials through overrides
Key components:
Contract Term and Billing Schedule
- Set contract duration using
starting_atandending_beforefields. 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.
Rate Card
If 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. Read more about
Rate Cards.
Overrides and discounts
Customize pricing on the contract through time-bounded overrides that can target specific products, product families, or complex usage scenarios. Overrides enable two key capabilities:
- Discounts: Apply percentage discounts, fixed rate reductions, or quantity-based pricing tiers
- Entitlements: Provide special pricing or access to specific products for negotiated deals
Read more about Contract Overrides.
Commits and Credits
Using 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.
In 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.
These objects can also also be configured to have a recurrence schedule to easily model customer packaging which includes recurring monthly or quarterly allotments.
Commits support rollover settings (rollover_fraction) to transfer unused
balances between contract periods, either entirely or as a percentage.
Read more about Credits and Commits.
Subscriptions
You 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:
- Define whether the subscription is paid for in-advance or in-arrears
(
collection_schedule) - Define the proration behavior (
proration) - Specify an initial quantity (
initial_quantity) - Define which subscription rate on the rate card should be used
(
subscription_rate)
Read more about Subscriptions.
Scheduled Charges
Set 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.
Threshold Billing
Metronome 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.
Read more about Spend Threshold and Prepaid Balance Thresholds.
Usage guidelines:
- You can always
Edit Contracts
after it has been created, using the
editContractendpoint. Metronome keeps track of all edits, both in the audit log and over thegetEditHistoryendpoint. - Customers in Metronome can have multiple concurrent contracts at one time. Use
usage_filtersto route the correct usage to each contract. Read more about usage filters.
224 225 226 227 228 229 230 231 232 233 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 224 def create(params) parsed, = MetronomeSDK::V1::ContractCreateParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/create", body: parsed, model: MetronomeSDK::Models::V1::ContractCreateResponse, options: ) end |
#create_historical_invoices(invoices:, preview:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractCreateHistoricalInvoicesResponse
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.
480 481 482 483 484 485 486 487 488 489 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 480 def create_historical_invoices(params) parsed, = MetronomeSDK::V1::ContractCreateHistoricalInvoicesParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/createHistoricalInvoices", body: parsed, model: MetronomeSDK::Models::V1::ContractCreateHistoricalInvoicesResponse, options: ) end |
#get_net_balance(customer_id:, credit_type_id: nil, filters: nil, invoice_inclusion_mode: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractGetNetBalanceResponse
Some parameter documentations has been truncated, see Models::V1::ContractGetNetBalanceParams for more details.
Retrieve the combined current balance across any grouping of credits and commits for a customer in a single API call.
- Display real-time available balance to customers in billing dashboards
- Build finance dashboards showing credit utilization across customer segments
- Validate expected vs. actual balance during billing reconciliation
Key response fields:
balance: The combined net balance available to use at this moment across all matching commits and creditscredit_type_id: The credit type (fiat or custom pricing unit) the balance is denominated in
Filtering options:
Balance 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.
- Balance types: Include any combination of
PREPAID_COMMIT,POSTPAID_COMMIT, andCREDIT(e.g.,["PREPAID_COMMIT", "CREDIT"]to exclude postpaid commits). If not specified, all balance types are included. - Specific IDs: Target exact commit or credit IDs for precise balance queries
- Custom fields: Filter by custom field key-value pairs; when multiple pairs are provided, commits must match all of them
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.
Usage guidelines:
- Balance ledger details: Use the listBalances endpoint instead to understand detailed ledger drawdowns for each individual balance
- Draft invoice handling: Use
invoice_inclusion_modeto control whether pending draft invoice deductions are included (FINALIZED_AND_DRAFT, the default) or excluded (FINALIZED) from the balance calculation - 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
- Negative balances: Manual ledger entries can cause negative segment balances; these are treated as zero when calculating the net balance
- Credit types: If
credit_type_idis not specified, the balance defaults to USD (cents)
560 561 562 563 564 565 566 567 568 569 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 560 def get_net_balance(params) parsed, = MetronomeSDK::V1::ContractGetNetBalanceParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/customerBalances/getNetBalance", body: parsed, model: MetronomeSDK::Models::V1::ContractGetNetBalanceResponse, options: ) end |
#get_subscription_seats_history(contract_id:, customer_id:, subscription_id:, covering_date: nil, cursor: nil, ending_before: nil, limit: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractGetSubscriptionSeatsHistoryResponse
Some parameter documentations has been truncated, see Models::V1::ContractGetSubscriptionSeatsHistoryParams for more details.
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.
Use this endpoint to:
- Track changes to seat assignments over time
- Get seat schedule for a specific date using the
covering_dateparameter - Get seat schedule history with optional date range filtering using
starting_atandending_before
Key response fields:
- data: array of seat schedule entries with time periods, quantity, and assignments
- next_page: cursor for pagination to retrieve additional results
Usage guidelines:
- Use
covering_dateto get the active seats for a specific point in time.covering_datecannot be used withstarting_atorending_before. - Use
starting_atandending_beforeto filter results by time range.starting_atandending_beforecannot be used withcovering_date. - Maximum limit is 10 seat schedule entries per request
- Results are ordered by
starting_attimestamp
625 626 627 628 629 630 631 632 633 634 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 625 def get_subscription_seats_history(params) parsed, = MetronomeSDK::V1::ContractGetSubscriptionSeatsHistoryParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/getSubscriptionSeatsHistory", body: parsed, model: MetronomeSDK::Models::V1::ContractGetSubscriptionSeatsHistoryResponse, options: ) end |
#list(customer_id:, covering_date: nil, include_archived: nil, include_balance: nil, include_ledgers: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractListResponse
Some parameter documentations has been truncated, see Models::V1::ContractListParams for more details.
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.
⚠️ Note: This is the legacy v1 endpoint - new integrations should use the v2 endpoint for enhanced features.
297 298 299 300 301 302 303 304 305 306 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 297 def list(params) parsed, = MetronomeSDK::V1::ContractListParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/list", body: parsed, model: MetronomeSDK::Models::V1::ContractListResponse, options: ) end |
#list_balances(customer_id:, id: nil, covering_date: nil, effective_before: nil, exclude_zero_balances: nil, include_archived: nil, include_balance: nil, include_contract_balances: nil, include_ledgers: nil, limit: nil, next_page: nil, starting_at: nil, request_options: {}) ⇒ MetronomeSDK::Internal::BodyCursorPage<MetronomeSDK::Models::Commit, MetronomeSDK::Models::Credit>
Some parameter documentations has been truncated, see Models::V1::ContractListBalancesParams for more details.
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.
Use this endpoint to:
- Display current available balances in customer dashboards
- Verify available funds before approving high-usage operations
- Generate balance reports for finance teams
- Filter balances by contract or date ranges
Key response fields:
An array of balance objects (all credits and commits) containing:
- Balance details: Current available amount for each commit or credit
- Metadata: Product associations, priorities, applicable date ranges
- Optional ledger entries: Detailed transaction history (if
include_ledgers=true) - Balance calculations: Including pending transactions and future-dated entries
- Custom fields: Any additional metadata attached to balances
Usage guidelines:
- Use the getNetBalance endpoint to retrieve a single combined current balance
- Date filtering: Use
effective_beforeto include only balances with access before a specific date (exclusive) - Set
include_balance=truefor calculated balance amounts on each commit or credit - Set
include_ledgers=truefor full transaction history - Set
include_contract_balances = trueto see contract level balances - Balance logic: Reflects currently accessible amounts, excluding expired/future segments
- Manual adjustments: Includes all manual ledger entries, even future-dated ones
708 709 710 711 712 713 714 715 716 717 718 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 708 def list_balances(params) parsed, = MetronomeSDK::V1::ContractListBalancesParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/customerBalances/list", body: parsed, page: MetronomeSDK::Internal::BodyCursorPage, model: MetronomeSDK::Models::V1::ContractListBalancesResponse, options: ) end |
#list_seat_balances(contract_id:, customer_id:, covering_date: nil, cursor: nil, effective_before: nil, include_credits_and_commits: nil, include_ledgers: nil, limit: nil, seat_ids: nil, skip_missing_seat_ids: nil, starting_at: nil, subscription_ids: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractListSeatBalancesResponse
Some parameter documentations has been truncated, see Models::V1::ContractListSeatBalancesParams for more details.
Retrieve detailed balance for seat-based credits and commits from the contract's subscriptions, broken down by individual seats.
Use this endpoint to:
- Display per-seat balance information in customer dashboards
- Filter balance data by subscription or specific seats
Key response fields:
An array of seat balance objects containing:
- Seat id
- Balance: current total balance across all commits and credits
Usage guidelines:
- Date filtering: use
covering_dateORstarting_at/ending_beforeto filter balance data by time range - Set
include_credits_and_commits=truefor detailed commits and credits breakdown per seat - Set
include_ledgers=truefor detailed transaction history per commit/credit per seat
778 779 780 781 782 783 784 785 786 787 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 778 def list_seat_balances(params) parsed, = MetronomeSDK::V1::ContractListSeatBalancesParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/seatBalances/list", body: parsed, model: MetronomeSDK::Models::V1::ContractListSeatBalancesResponse, options: ) end |
#retrieve(contract_id:, customer_id:, include_balance: nil, include_ledgers: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveParams for more details.
This is the v1 endpoint to get a contract. New clients should implement using the v2 endpoint.
256 257 258 259 260 261 262 263 264 265 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 256 def retrieve(params) parsed, = MetronomeSDK::V1::ContractRetrieveParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/get", body: parsed, model: MetronomeSDK::Models::V1::ContractRetrieveResponse, options: ) end |
#retrieve_rate_schedule(contract_id:, customer_id:, limit: nil, next_page: nil, at: nil, selectors: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveRateScheduleResponse
Some parameter documentations has been truncated, see Models::V1::ContractRetrieveRateScheduleParams for more details.
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.
For 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.
819 820 821 822 823 824 825 826 827 828 829 830 831 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 819 def retrieve_rate_schedule(params) query_params = [:limit, :next_page] parsed, = MetronomeSDK::V1::ContractRetrieveRateScheduleParams.dump_request(params) query = MetronomeSDK::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :post, path: "v1/contracts/getContractRateSchedule", query: query, body: parsed.except(*query_params), model: MetronomeSDK::Models::V1::ContractRetrieveRateScheduleResponse, options: ) end |
#retrieve_subscription_quantity_history(contract_id:, customer_id:, subscription_id:, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractRetrieveSubscriptionQuantityHistoryResponse
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.
Subscriptions 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.
854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 854 def retrieve_subscription_quantity_history(params) parsed, = MetronomeSDK::V1::ContractRetrieveSubscriptionQuantityHistoryParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/getSubscriptionQuantityHistory", body: parsed, model: MetronomeSDK::Models::V1::ContractRetrieveSubscriptionQuantityHistoryResponse, options: ) end |
#schedule_pro_services_invoice(contract_id:, customer_id:, issued_at:, line_items:, netsuite_invoice_header_end: nil, netsuite_invoice_header_start: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractScheduleProServicesInvoiceResponse
Create a new scheduled invoice for Professional Services terms on a contract. This endpoint's availability is dependent on your client's configuration.
888 889 890 891 892 893 894 895 896 897 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 888 def schedule_pro_services_invoice(params) parsed, = MetronomeSDK::V1::ContractScheduleProServicesInvoiceParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/scheduleProServicesInvoice", body: parsed, model: MetronomeSDK::Models::V1::ContractScheduleProServicesInvoiceResponse, options: ) end |
#set_usage_filter(contract_id:, customer_id:, group_key:, group_values:, starting_at:, request_options: {}) ⇒ nil
If a customer has multiple contracts with overlapping rates, the usage filter routes usage to the appropriate contract based on a predefined group key.
As 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 on each contract, and route usage for project_1 to the
first contract and project_2 to the second contract.
Use this endpoint to:
- Support enterprise contracting scenarios where multiple contracts are associated to the same customer with the same rates.
- Update the usage filter associated with the contract over time.
Usage guidelines:
To use usage filters, the group_key must be defined on the billable metrics
underlying the rate card on the contracts.
930 931 932 933 934 935 936 937 938 939 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 930 def set_usage_filter(params) parsed, = MetronomeSDK::V1::ContractSetUsageFilterParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/setUsageFilter", body: parsed, model: NilClass, options: ) end |
#update_end_date(contract_id:, customer_id:, allow_ending_before_finalized_invoice: nil, ending_before: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::ContractUpdateEndDateResponse
Some parameter documentations has been truncated, see Models::V1::ContractUpdateEndDateParams for more details.
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.
966 967 968 969 970 971 972 973 974 975 |
# File 'lib/metronome_sdk/resources/v1/contracts.rb', line 966 def update_end_date(params) parsed, = MetronomeSDK::V1::ContractUpdateEndDateParams.dump_request(params) @client.request( method: :post, path: "v1/contracts/updateEndDate", body: parsed, model: MetronomeSDK::Models::V1::ContractUpdateEndDateResponse, options: ) end |