metronome
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMetronome API base: . Authenticate with a Bearer token in the header. Always use Contracts (not legacy Plans) for new integrations.
https://api.metronome.comAuthorizationMetronome API 基础地址:。使用 请求头中的 Bearer token 进行身份验证。新集成始终使用 Contracts(而非旧版 Plans)。
https://api.metronome.comAuthorizationIntegration routing
集成路由
| Building… | Recommended API | Details |
|---|---|---|
| Ingesting usage events | | Send usage events, the API quickstart, the Ingest API reference, and Set ingest aliases |
| Defining what to measure | Billable Metrics API | Create billable metrics |
| Enterprise pricing agreements | Contracts + Rate Cards | Provision a customer contract, Create and manage rate cards, and the Create a contract and Add rates API references |
| Mid-term contract changes | Contract Edits | Edit a contract, Contract edits and overrides, and Manage contract lifecycle |
| Invoice lifecycle and finalization | Invoices API | How Metronome invoices work |
| Prepaid or postpaid commitments and one-off top-ups | Commits + Credits | Apply credits and commits to contracts and Payment-gated commits |
| Syncing invoices to Stripe | Stripe billing provider config | Invoice with Stripe |
| Prepaid balances, auto-recharge, spend alerts, and thresholds | Notifications API | Set 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 to the page URL to fetch it as Markdown.
.md| 构建内容… | 推荐的 API | 详情 |
|---|---|---|
| 摄取用量事件 | | 发送用量事件、API 快速入门、Ingest API 参考以及设置 ingest 别名 |
| 定义计量内容 | Billable Metrics API | 创建 Billable Metrics |
| 企业级定价协议 | Contracts + Rate Cards | 配置客户合同、创建和管理 Rate Cards,以及创建合同和添加费率 API 参考 |
| 合同期中变更 | Contract Edits | 编辑合同、合同编辑与覆盖项以及管理合同生命周期 |
| 发票生命周期与最终确定 | Invoices API | Metronome 的发票如何运作 |
| 预付或后付 Commits 以及一次性充值 | Commits + Credits | 将 Credits 和 Commits 应用到合同以及付款门控 Commits |
| 将发票同步到 Stripe | Stripe billing provider 配置 | 使用 Stripe 开票 |
| 预付余额、自动充值、消费提醒和阈值 | Notifications API | 设置预付余额阈值、强制执行消费阈值以及阈值通知 |
在回答任何集成问题或编写代码前,请阅读链接页面;这些链接会返回纯 Markdown。如果没有适合的条目,请使用文档索引查找正确页面,并在页面 URL 后追加 以获取 Markdown 格式。
.mdOperational 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 ; 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 ) and confirm those writes separately.
https://api.metronome.comGET /v1/account| Task | Metronome skill | What it does |
|---|---|---|
| Migrating from Stripe Billing Meters, Subscriptions, and Credit Grants to Metronome | stripe-to-metronome-migration | Changes 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 | metronome-group-keys | Creates 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 |
| Setting up Metronome from scratch: billable metrics, products, rate card, customer, and contract | metronome-setup-catalog | Creates objects. End-to-end setup from pricing intent to a verified draft invoice. |
| Creating a customer record | metronome-create-customer | Creates objects. Duplicate check and preview, then |
| Creating a new contract from signed order-form terms | metronome-create-contract | Creates 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 usage | metronome-token-billing | Creates 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 terms | metronome-plg-billing | Creates 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 prep | metronome-csm-reviews | Read-only. Written for Metronome’s account team rather than for building an integration. |
Metronome 为以下任务发布了分步骤 skill。开始任务前,请完整阅读链接中的 skill。其中几个 skill 会使用环境中的 token 通过 API 创建真实的 Metronome 对象:请确认该 token 所指向的环境(sandbox 和 production 共用 ;环境由 token 决定),并在任何写入操作前获得用户的明确确认。如果某个步骤还会写入 Stripe,例如迁移切换在终止 subscriptions 时会执行此操作,则应确定 Stripe key 对应的 Stripe account 和 mode(例如通过 ),并单独确认这些写入操作。
https://api.metronome.comGET /v1/account| 任务 | Metronome skill | 作用 |
|---|---|---|
| 从 Stripe Billing Meters、Subscriptions 和 Credit Grants 迁移到 Metronome | stripe-to-metronome-migration | 执行时会更改生产状态:创建 Metronome 客户、合同和 Credits,切换可计费状态,并在切换时终止 Stripe subscriptions。还涵盖范围界定、概念映射、分组键设计、并行运行和回滚。 |
为 Billable Metric 设计 | metronome-group-keys | 在确认门控后创建 Billable Metric 和产品。首先评估基数风险:复合键的成本是每个维度基数的乘积,而且 |
| 从头设置 Metronome:Billable Metrics、产品、Rate Card、客户和合同 | metronome-setup-catalog | 创建对象。提供从定价意图到经验证的草稿 invoice 的端到端设置。 |
| 创建客户记录 | metronome-create-customer | 创建对象。执行重复检查和预览后,通过 |
| 根据已签署 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 (), not deprecated Amendments (
POST /v2/contracts/edit), 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/v1/contracts/amendonly for renewals.transition: {type: "renewal", from_contract_id} - Always use batch ingestion (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
POST /v1/ingestmeans the events were accepted, not rated: events whose200matches no billable metric are stored but excluded from usage, so create billable metrics before sending.event_type - Always include a unique 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.
transaction_id - Always deliver usage for a billing period before its grace period ends (24 hours after 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).
billing_period_end_date - Always set a (
usage_filterandgroup_key) 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).group_values - Never schedule a contract-level commit or credit access segment past the contract’s . 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
ending_beforeto carry a remaining balance into a renewal.rollover_fraction - Never put ,
applicable_product_ids, orapplicable_product_tagson aspecifierscommit. Spend-threshold commits apply to all usage and take onlyspend_threshold_configuration,product_id,name, anddescription; onlyprioritycommits accept product filters.prepaid_balance_threshold_configuration - 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 (is 10.00 USD) for thresholds, commits, credits, and rate or override prices; other currencies use whole units.
1000 - 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 . 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.
total - Never set NetSuite as both a contract’s and its
billing_provider_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.revenue_system_configuration
- 始终先阅读链接的文档页面,再提及任何 Metronome endpoint、field 或 amount。 Endpoint 路径、请求结构和单位可能被记错;上方的路由表指明了每个任务对应的页面。
- 新客户始终使用 Contracts,而不是旧版 Plans。 Plans 已弃用,且不支持 Rate Card 覆盖项、Commits 和灵活排期。已有的 Plans 集成仍可继续使用:除非用户提出要求,否则不要建议迁移;迁移时,使用 转移 credit 余额。
POST /v1/credits/migrateToContracts - 合同的期中变更始终使用 Edits(),而不是已弃用的 Amendments(
POST /v2/contracts/edit),以添加新产品、Commits 或覆盖项。Edits 是当前持续投入维护的路径,也是 v2 subscription 功能所必需的。仅在续约时,使用/v1/contracts/amend创建新合同。transition: {type: "renewal", from_contract_id} - 生产工作负载始终使用批量摄取(,请求体为包含 1 到 100 个事件对象的纯 JSON 数组,而不是包装在对象中)。单事件摄取仅可用于测试。
POST /v1/ingest表示事件已被接受,并不表示已完成计费:200与任何 Billable Metric 均不匹配的事件会被存储,但不会计入用量,因此请先创建 Billable Metrics,再发送事件。event_type - 每个事件始终包含唯一的 ,该 ID 在记录事件时固定,并在每次重试时原样重新发送:可以是与事件一起存储的 UUID,也可以是从源记录派生的值。这是防止重试时重复计数的幂等键;每次尝试都重新生成 ID 会使幂等性失效。
transaction_id - 始终在计费周期的宽限期结束前交付该周期的用量(默认是 后 24 小时)。已最终确定的发票会忽略迟到事件,只能通过作废并重新生成来更正;如果流水线的最坏延迟超过宽限期,请联系 Metronome 支持团队延长宽限期(无法通过 API 配置)。
billing_period_end_date - 当客户同时存在多份合同时,始终在每份合同上设置 (
usage_filter和group_key),使用量仅在一份合同上计费,而不是在所有合同上计费。该 group key 必须是流式 Billable Metric 上的 group key(对于 SQL 指标,则为事件属性)。group_values - 绝不将合同级 commit 或 credit access segment 安排在合同的 之后。 合同结束后的用量不会在该合同上计费,因此在该日期之后释放的余额将被搁置;最后一个 segment 应在合同期限内结束,并使用
ending_before将剩余余额结转到续约合同。rollover_fraction - 绝不在 commit 上设置
spend_threshold_configuration、applicable_product_ids或applicable_product_tags。 消费阈值 commit 适用于所有用量,并且只接受specifiers、product_id、name和description;只有prioritycommit 接受产品过滤器。prepaid_balance_threshold_configuration - 绝不同时处理同一 Stripe 客户的多张 Metronome 发票。 并发处理会导致待处理行项目出现竞态条件。
- 绝不直接在合同中硬编码定价。 请在 Rate Cards 中定义定价,并使用合同级覆盖项处理自定义费率。这样,当 Rate Card 发生变化时,未被覆盖的定价仍能保持最新。
- 始终以 cents 发送 USD 金额。 Metronome 默认的 USD credit type 以 cents 为单位(表示 10.00 USD),适用于阈值、Commits、Credits 以及费率或覆盖价格;其他货币使用完整货币单位。
1000 - 绝不在税务计算完成前最终确定 Stripe 发票。 如果使用 Stripe Tax、Avalara 或 Anrok,税务提供商必须先处理该发票,然后才能最终确定。
- 每张 Stripe 发票绝不能超过 250 个行项目。 超出此限制会导致所有行项目合并成单个条目,从而丢失各产品的明细。请合理规划产品粒度,并使用组合产品聚类高基数指标。
- 始终根据 Stripe 发票总额进行付款对账,绝不能根据 Metronome 发票的 对账。 Metronome 发送的是未计税行项目,而 Stripe 会在最终确定时添加税费,因此 Metronome 总额是税前金额,并且可能因不足 1 美分的舍入而存在差异。
total - 绝不能将 NetSuite 同时设置为合同的 和
billing_provider_configuration。 当由 NetSuite开具并收取发票时,使用 billing configuration;只有当 Stripe 等其他提供商负责开票,而 NetSuite 需要该发票进行收入确认时,才使用 revenue system configuration。revenue_system_configuration
Key documentation
关键文档
When the user’s request doesn’t clearly fit a single domain above, consult:
- Metronome Documentation: Start here for any Metronome question.
- API Reference: Full endpoint reference.
- LLM-friendly doc index: Machine-readable documentation index.
- Stripe Integration Guide: Syncing Metronome invoices with Stripe.
- How Metronome works with Stripe: The Stripe guide to the integration patterns and what stays on Stripe.
当用户请求无法明确归入上述单一领域时,请查阅:
- Metronome 文档:回答任何 Metronome 问题时请从此开始。
- API 参考:完整的 endpoint 参考。
- 适合 LLM 的文档索引:机器可读的文档索引。
- Stripe 集成指南:将 Metronome 发票与 Stripe 同步。
- Metronome 如何与 Stripe 协同工作:介绍集成模式以及哪些内容仍由 Stripe 处理的 Stripe 指南。