metronome

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Metronome API base:
https://api.metronome.com
. Authenticate with a Bearer token in the
Authorization
header. Always use Contracts (not legacy Plans) for new integrations.
Metronome API 基础地址:
https://api.metronome.com
。使用
Authorization
请求头中的 Bearer token 进行身份验证。新集成始终使用 Contracts(而非旧版 Plans)。

Integration routing

集成路由

Building…Recommended APIDetails
Ingesting usage events
POST /v1/ingest
(batch)
Send usage events, the API quickstart, the Ingest API reference, and Set ingest aliases
Defining what to measureBillable Metrics APICreate billable metrics
Enterprise pricing agreementsContracts + Rate CardsProvision a customer contract, Create and manage rate cards, and the Create a contract and Add rates API references
Mid-term contract changesContract EditsEdit a contract, Contract edits and overrides, and Manage contract lifecycle
Invoice lifecycle and finalizationInvoices APIHow Metronome invoices work
Prepaid or postpaid commitments and one-off top-upsCommits + CreditsApply credits and commits to contracts and Payment-gated commits
Syncing invoices to StripeStripe billing provider configInvoice with Stripe
Prepaid balances, auto-recharge, spend alerts, and thresholdsNotifications APISet prepaid balance thresholds, Enforce spend thresholds, and Threshold notifications
Read the linked page before answering any integration question or writing code; the links return plain Markdown. If no row fits, use the documentation index to find the right page, and append
.md
to the page URL to fetch it as Markdown.
构建内容…推荐的 API详情
摄取用量事件
POST /v1/ingest
(批量)
发送用量事件、API 快速入门、Ingest API 参考以及设置 ingest 别名
定义计量内容Billable Metrics API创建 Billable Metrics
企业级定价协议Contracts + Rate Cards配置客户合同、创建和管理 Rate Cards,以及创建合同和添加费率 API 参考
合同期中变更Contract Edits编辑合同、合同编辑与覆盖项以及管理合同生命周期
发票生命周期与最终确定Invoices APIMetronome 的发票如何运作
预付或后付 Commits 以及一次性充值Commits + Credits将 Credits 和 Commits 应用到合同以及付款门控 Commits
将发票同步到 StripeStripe billing provider 配置使用 Stripe 开票
预付余额、自动充值、消费提醒和阈值Notifications API设置预付余额阈值、强制执行消费阈值以及阈值通知
在回答任何集成问题或编写代码前,请阅读链接页面;这些链接会返回纯 Markdown。如果没有适合的条目,请使用文档索引查找正确页面,并在页面 URL 后追加
.md
以获取 Markdown 格式。

Operational workflows

操作工作流

Metronome publishes step-by-step skills for the tasks below. Read the linked skill in full before starting the task. Several of them create real Metronome objects through the API using the token in the environment: confirm which environment that token targets (sandbox and production share
https://api.metronome.com
; the token determines the environment) and get the user’s explicit confirmation before any write. Where a step also writes to Stripe, as the migration cutover does when it ends subscriptions, identify the Stripe account and mode behind the Stripe key (for example with
GET /v1/account
) and confirm those writes separately.
TaskMetronome skillWhat it does
Migrating from Stripe Billing Meters, Subscriptions, and Credit Grants to Metronomestripe-to-metronome-migrationChanges production state when executed: creates Metronome customers, contracts, and credits, flips billable status, and ends Stripe subscriptions at cutover. Also covers scoping, concept mapping, group key design, the parallel run, and rollback.
Designing
group_keys
,
pricing_group_key
, and
presentation_group_key
for a billable metric
metronome-group-keysCreates the billable metric and product after a confirmation gate. Sizes cardinality risk first: a compound key’s cost is the product of each dimension’s cardinality, and
group_keys
is immutable.
Setting up Metronome from scratch: billable metrics, products, rate card, customer, and contractmetronome-setup-catalogCreates objects. End-to-end setup from pricing intent to a verified draft invoice.
Creating a customer recordmetronome-create-customerCreates objects. Duplicate check and preview, then
POST /v1/customers
with name, ingest alias, Salesforce ID, and Slack channel.
Creating a new contract from signed order-form termsmetronome-create-contractCreates objects. Commits, credits, and rate overrides on a new contract, including commit-specific discounts; for an existing contract use Contract Edits (routing table above).
Billing an AI application for token usagemetronome-token-billingCreates objects. Models AI plans, builds the managed rate card with your markup over Stripe’s model catalog, provisions the customer, and validates the Stripe and Metronome flow.
Self-serve (PLG) billing setup, pricing changes, and single-customer diagnostics, in business termsmetronome-plg-billingCreates and changes objects in its start-billing and change-pricing modes; customer-story mode is a read-only diagnostic.
Customer health reviews for Metronome CSMs: anomalies, commit burn, portfolio briefing, renewal prepmetronome-csm-reviewsRead-only. Written for Metronome’s account team rather than for building an integration.
Metronome 为以下任务发布了分步骤 skill。开始任务前,请完整阅读链接中的 skill。其中几个 skill 会使用环境中的 token 通过 API 创建真实的 Metronome 对象:请确认该 token 所指向的环境(sandbox 和 production 共用
https://api.metronome.com
;环境由 token 决定),并在任何写入操作前获得用户的明确确认。如果某个步骤还会写入 Stripe,例如迁移切换在终止 subscriptions 时会执行此操作,则应确定 Stripe key 对应的 Stripe account 和 mode(例如通过
GET /v1/account
),并单独确认这些写入操作。
任务Metronome skill作用
从 Stripe Billing Meters、Subscriptions 和 Credit Grants 迁移到 Metronomestripe-to-metronome-migration执行时会更改生产状态:创建 Metronome 客户、合同和 Credits,切换可计费状态,并在切换时终止 Stripe subscriptions。还涵盖范围界定、概念映射、分组键设计、并行运行和回滚。
为 Billable Metric 设计
group_keys
、
pricing_group_key
和
presentation_group_key
metronome-group-keys在确认门控后创建 Billable Metric 和产品。首先评估基数风险:复合键的成本是每个维度基数的乘积,而且
group_keys
不可变。
从头设置 Metronome:Billable Metrics、产品、Rate Card、客户和合同metronome-setup-catalog创建对象。提供从定价意图到经验证的草稿 invoice 的端到端设置。
创建客户记录metronome-create-customer创建对象。执行重复检查和预览后,通过
POST /v1/customers
提交名称、ingest alias、Salesforce ID 和 Slack channel。
根据已签署 order form 的条款创建新合同metronome-create-contract创建对象。在新合同上设置 Commits、Credits 和费率覆盖项,包括 commit 专属折扣;如需修改现有合同,请使用 Contract Edits(见上方路由表)。
为 AI 应用 的 token 用量计费metronome-token-billing创建对象。为 AI plans 建模,基于 Stripe model catalog 构建包含加价的托管 Rate Card,配置客户,并验证 Stripe 与 Metronome 流程。
以业务术语设置自助服务 (PLG) 计费、进行定价变更和执行单客户诊断metronome-plg-billing在 start-billing 和 change-pricing 模式下创建及修改对象;customer-story 模式是只读诊断模式。
面向 Metronome CSM 的客户健康度审查:异常、commit 消耗、投资组合简报和续约准备metronome-csm-reviews只读。面向 Metronome 的客户团队编写,而非用于构建集成。

Critical rules

关键规则

  • Always read the linked documentation page before naming a Metronome endpoint, field, or amount. Endpoint paths, request shapes, and units can be misremembered; the routing table above points to the page for each task.
  • Always use Contracts, not legacy Plans, for new customers. Plans are deprecated and lack rate card overrides, commits, and flexible scheduling. An existing Plans integration keeps working: don’t propose migrating it unless asked, and when migrating move credit balances with
    POST /v1/credits/migrateToContracts
    .
  • Always use Edits (
    POST /v2/contracts/edit
    ), not deprecated Amendments (
    /v1/contracts/amend
    ), for mid-term changes to a contract (new products, commits, overrides). Edits are the actively invested path and required for v2 subscription features. Create a new contract with
    transition: {type: "renewal", from_contract_id}
    only for renewals.
  • Always use batch ingestion (
    POST /v1/ingest
    with a bare JSON array of 1 to 100 event objects as the request body, not wrapped in an object) for production workloads. Single-event ingestion is acceptable only for testing. A
    200
    means the events were accepted, not rated: events whose
    event_type
    matches no billable metric are stored but excluded from usage, so create billable metrics before sending.
  • Always include a unique
    transaction_id
    on every event, fixed when the event is recorded and re-sent unchanged on every retry: a UUID stored with the event, or a value derived from the source record. This is the idempotency key that prevents double-counting on retries; an ID regenerated per attempt defeats it.
  • Always deliver usage for a billing period before its grace period ends (24 hours after
    billing_period_end_date
    by default). A finalized invoice ignores late events and can only be corrected by voiding and regenerating it; if your pipeline’s worst-case lag exceeds the grace period, ask Metronome support to lengthen it (it isn’t configurable through the API).
  • Always set a
    usage_filter
    (
    group_key
    and
    group_values
    ) on each contract when a customer has more than one concurrent contract, so usage is rated on one contract instead of all of them. The group key must be a group key on the streaming billable metric (an event property for SQL metrics).
  • Never schedule a contract-level commit or credit access segment past the contract’s
    ending_before
    .
    Usage after the contract ends isn’t rated on it, so balance released after that date is stranded; end the last segment at the contract term and use
    rollover_fraction
    to carry a remaining balance into a renewal.
  • Never put
    applicable_product_ids
    ,
    applicable_product_tags
    , or
    specifiers
    on a
    spend_threshold_configuration
    commit.
    Spend-threshold commits apply to all usage and take only
    product_id
    ,
    name
    ,
    description
    , and
    priority
    ; only
    prepaid_balance_threshold_configuration
    commits accept product filters.
  • Never process multiple Metronome invoices for the same Stripe customer simultaneously. Concurrent processing causes race conditions on pending line items.
  • Never hardcode pricing directly in contracts. Define pricing in rate cards and use contract-level overrides for custom rates. This ensures un-overridden pricing stays current when the rate card changes.
  • Always send USD amounts in cents. Metronome’s default USD credit type is denominated in cents (
    1000
    is 10.00 USD) for thresholds, commits, credits, and rate or override prices; other currencies use whole units.
  • Never finalize a Stripe invoice before tax calculation completes. If using Stripe Tax, Avalara, or Anrok, the tax provider must process the invoice before finalization.
  • Never exceed 250 line items per Stripe invoice. Exceeding this limit causes all line items to collapse into a single entry, losing per-product detail. Plan product granularity and use composite products to aggregate high-cardinality metrics.
  • Always reconcile payments against the Stripe invoice total, never the Metronome invoice
    total
    .
    Metronome sends untaxed line items and Stripe adds tax at finalization, so the Metronome total is pre-tax and can differ by sub-cent rounding.
  • Never set NetSuite as both a contract’s
    billing_provider_configuration
    and its
    revenue_system_configuration
    .
    Use the billing configuration when NetSuite issues and collects the invoice; use the revenue system configuration only when another provider such as Stripe bills and NetSuite needs the invoice for revenue recognition.
  • 始终先阅读链接的文档页面,再提及任何 Metronome endpoint、field 或 amount。 Endpoint 路径、请求结构和单位可能被记错;上方的路由表指明了每个任务对应的页面。
  • 新客户始终使用 Contracts,而不是旧版 Plans。 Plans 已弃用,且不支持 Rate Card 覆盖项、Commits 和灵活排期。已有的 Plans 集成仍可继续使用:除非用户提出要求,否则不要建议迁移;迁移时,使用
    POST /v1/credits/migrateToContracts
    转移 credit 余额。
  • 合同的期中变更始终使用 Edits(
    POST /v2/contracts/edit
    ),而不是已弃用的 Amendments(
    /v1/contracts/amend
    ),以添加新产品、Commits 或覆盖项。Edits 是当前持续投入维护的路径,也是 v2 subscription 功能所必需的。仅在续约时,使用
    transition: {type: "renewal", from_contract_id}
    创建新合同。
  • 生产工作负载始终使用批量摄取(
    POST /v1/ingest
    ,请求体为包含 1 到 100 个事件对象的纯 JSON 数组,而不是包装在对象中)。单事件摄取仅可用于测试。
    200
    表示事件已被接受,并不表示已完成计费:
    event_type
    与任何 Billable Metric 均不匹配的事件会被存储,但不会计入用量,因此请先创建 Billable Metrics,再发送事件。
  • 每个事件始终包含唯一的
    transaction_id
    ,该 ID 在记录事件时固定,并在每次重试时原样重新发送:可以是与事件一起存储的 UUID,也可以是从源记录派生的值。这是防止重试时重复计数的幂等键;每次尝试都重新生成 ID 会使幂等性失效。
  • 始终在计费周期的宽限期结束前交付该周期的用量(默认是
    billing_period_end_date
    后 24 小时)。已最终确定的发票会忽略迟到事件,只能通过作废并重新生成来更正;如果流水线的最坏延迟超过宽限期,请联系 Metronome 支持团队延长宽限期(无法通过 API 配置)。
  • 当客户同时存在多份合同时,始终在每份合同上设置
    usage_filter
    (
    group_key
    和
    group_values
    ),使用量仅在一份合同上计费,而不是在所有合同上计费。该 group key 必须是流式 Billable Metric 上的 group key(对于 SQL 指标,则为事件属性)。
  • 绝不将合同级 commit 或 credit access segment 安排在合同的
    ending_before
    之后。
    合同结束后的用量不会在该合同上计费,因此在该日期之后释放的余额将被搁置;最后一个 segment 应在合同期限内结束,并使用
    rollover_fraction
    将剩余余额结转到续约合同。
  • 绝不在
    spend_threshold_configuration
    commit 上设置
    applicable_product_ids
    、
    applicable_product_tags
    或
    specifiers
    。
    消费阈值 commit 适用于所有用量,并且只接受
    product_id
    、
    name
    、
    description
    和
    priority
    ;只有
    prepaid_balance_threshold_configuration
    commit 接受产品过滤器。
  • 绝不同时处理同一 Stripe 客户的多张 Metronome 发票。 并发处理会导致待处理行项目出现竞态条件。
  • 绝不直接在合同中硬编码定价。 请在 Rate Cards 中定义定价,并使用合同级覆盖项处理自定义费率。这样,当 Rate Card 发生变化时,未被覆盖的定价仍能保持最新。
  • 始终以 cents 发送 USD 金额。 Metronome 默认的 USD credit type 以 cents 为单位(
    1000
    表示 10.00 USD),适用于阈值、Commits、Credits 以及费率或覆盖价格;其他货币使用完整货币单位。
  • 绝不在税务计算完成前最终确定 Stripe 发票。 如果使用 Stripe Tax、Avalara 或 Anrok,税务提供商必须先处理该发票,然后才能最终确定。
  • 每张 Stripe 发票绝不能超过 250 个行项目。 超出此限制会导致所有行项目合并成单个条目,从而丢失各产品的明细。请合理规划产品粒度,并使用组合产品聚类高基数指标。
  • 始终根据 Stripe 发票总额进行付款对账,绝不能根据 Metronome 发票的
    total
    对账。
    Metronome 发送的是未计税行项目,而 Stripe 会在最终确定时添加税费,因此 Metronome 总额是税前金额,并且可能因不足 1 美分的舍入而存在差异。
  • 绝不能将 NetSuite 同时设置为合同的
    billing_provider_configuration
    和
    revenue_system_configuration
    。
    当由 NetSuite开具并收取发票时,使用 billing configuration;只有当 Stripe 等其他提供商负责开票,而 NetSuite 需要该发票进行收入确认时,才使用 revenue system configuration。

Key documentation

关键文档

When the user’s request doesn’t clearly fit a single domain above, consult:
当用户请求无法明确归入上述单一领域时,请查阅: