openapi: 3.0.1
info:
title: Metronome Alerts Invoices API
version: 1.0.0
description: '[Alerts](https://docs.metronome.com/connecting-metronome/alerts/) monitor customer spending, balances, and other billing factors. Use these endpoints to create, retrieve, and archive customer alerts. To view sample alert payloads by alert type, navigate [here.](https://docs.metronome.com/manage-product-access/create-manage-alerts/#webhook-notifications)'
servers:
- url: https://api.metronome.com
description: Production server
security:
- bearerAuth: []
tags:
- name: Invoices
description: '[Invoices](https://docs.metronome.com/invoicing/) reflect how much a customer spent during a period, which is the basis for billing. Metronome automatically generates invoices based upon your pricing, packaging, and usage events. Use these endpoints to retrieve invoices.'
paths:
/v1/customers/{customer_id}/invoices/invoice_seats:
post:
x-mint:
groups:
- ff:seats
description: 'Creates an prorated invoice for a seat addition. As an alternative to this endpoint, you can elect to use automatic seat invoicing feature. Metronome will check for new seat usage every hour and automatically invoice for any new seats. For newly created active customer plans, there will be up to 4 hour delay before the first automatic seat invoice is generated.
'
operationId: chargeSeats-v1
summary: Invoice seats
parameters:
- $ref: '#/components/parameters/CustomerId'
requestBody:
description: Invoice seats parameters. List of seat charges and additional seats to charge for.
content:
application/json:
schema:
type: object
required:
- seat_charges
properties:
seat_charges:
type: array
items:
type: object
required:
- charge_id
- seat_count
properties:
charge_id:
type: string
format: uuid
seat_count:
type: integer
minimum: 1
current_seat_count:
type: integer
example:
seat_charges:
- charge_id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
seat_count: 10
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
$ref: '#/components/schemas/Invoice'
example:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: SEAT_PURCHASE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
plan_name: test plan
plan_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
type: usage
sub_line_items:
- name: CPU hours
quantity: 1488
subtotal: 14392
charge_id: 3f1541ac-00df-40ee-a1a3-ec3373933669
tiers:
- starting_at: 0
quantity: 1000
price: 10
subtotal: 10000
- starting_at: 1001
quantity: 488
price: 9
subtotal: 4392
custom_fields:
x_account_id: KyVnHhSBWl7eY2bl
name: Cloud database
quantity: 1
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
custom_fields:
x_account_id: KyVnHhSBWl7eY2bl
invoice_adjustments: []
status: FINALIZED
subtotal: 14392
total: 14392
'404':
$ref: '#/components/responses/NotFound'
/v1/customers/{customer_id}/invoices:
get:
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"
operationId: listInvoices-v1
summary: List invoices
x-slo-tier: 1
parameters:
- $ref: '#/components/parameters/CustomerId'
- $ref: '#/components/parameters/PageLimit'
- $ref: '#/components/parameters/NextPage'
- $ref: '#/components/parameters/InvoiceStatus'
- $ref: '#/components/parameters/InvoiceType'
- $ref: '#/components/parameters/SkipZeroQtyLineItems'
- in: query
name: sort
description: Invoice sort order by issued_at, e.g. date_asc or date_desc. Defaults to date_asc.
required: false
schema:
type: string
enum:
- date_asc
- date_desc
- in: query
name: credit_type_id
description: Only return invoices for the specified credit type
required: false
schema:
type: string
- in: query
name: contract_id
description: Only return invoices for the specified contract
required: false
schema:
type: string
format: uuid
- in: query
name: starting_on
description: RFC 3339 timestamp (inclusive). Invoices will only be returned for billing periods that start at or after this time.
required: false
schema:
type: string
format: date-time
- in: query
name: ending_before
description: RFC 3339 timestamp (exclusive). Invoices will only be returned for billing periods that end before this time.
required: false
schema:
type: string
format: date-time
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required:
- data
- next_page
properties:
data:
type: array
items:
$ref: '#/components/schemas/Invoice'
next_page:
type: string
nullable: true
examples:
contracts:
value:
data:
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
total: 14392
status: FINALIZED
next_page: null
'404':
$ref: '#/components/responses/NotFound'
/v1/customers/{customer_id}/invoices/breakdowns:
get:
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.
### Use this endpoint to:
- Build usage analytics dashboards showing daily or hourly consumption trends
- Identify peak usage periods for capacity planning and cost optimization
- Generate detailed billing reports for finance teams and customer success
- Troubleshoot billing disputes by examining usage patterns at specific times
- Power real-time cost monitoring and alerting systems
### Key response fields:
An array of BreakdownInvoice objects, each containing:
- All standard invoice fields (ID, customer, commit, line items, totals, status)
- Line items with quantities and costs for that specific period
- `breakdown_start_timestamp`: Start of the specific time window
- `breakdown_end_timestamp`: End of the specific time window
- `next_page`: Pagination cursor for large result sets
### Usage guidelines:
- Time granularity: Set `window_size` to hour or day based on your analysis needs
- Response limits: Daily breakdowns return up to 35 days; hourly breakdowns return up to 24 hours per request
- Date filtering: Use `starting_on` and `ending_before` to focus on specific periods
- Performance: For large date ranges, use pagination to retrieve all data efficiently
- Backdated usage: If usage events arrive after invoice finalization, breakdowns will reflect the updated usage
- Zero quantity filtering: Use `skip_zero_qty_line_items=true` to exclude periods with no usage'
operationId: listBreakdownInvoices-v1
summary: List invoice breakdowns
x-slo-tier: 1
x-gateway-timeout-millis: 60100
parameters:
- $ref: '#/components/parameters/CustomerId'
- $ref: '#/components/parameters/NextPage'
- $ref: '#/components/parameters/InvoiceStatusNonVoid'
- $ref: '#/components/parameters/SkipZeroQtyLineItems'
- in: query
name: limit
description: 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.
required: false
schema:
type: integer
minimum: 1
maximum: 100
- in: query
name: window_size
description: The granularity of the breakdowns to return. Defaults to day.
required: false
schema:
type: string
enum:
- hour
- day
- HOUR
- DAY
- Hour
- Day
- in: query
name: sort
description: Invoice sort order by issued_at, e.g. date_asc or date_desc. Defaults to date_asc.
required: false
schema:
type: string
enum:
- date_asc
- date_desc
- in: query
name: credit_type_id
description: Only return invoices for the specified credit type
required: false
schema:
type: string
- in: query
name: starting_on
description: RFC 3339 timestamp. Breakdowns will only be returned for time windows that start on or after this time.
required: true
schema:
type: string
format: date-time
example: '2024-01-01T00:00:00Z'
- in: query
name: ending_before
description: RFC 3339 timestamp. Breakdowns will only be returned for time windows that end on or before this time.
required: true
schema:
type: string
format: date-time
example: '2024-02-01T00:00:00Z'
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required:
- data
- next_page
properties:
data:
type: array
items:
$ref: '#/components/schemas/BreakdownInvoice'
next_page:
type: string
nullable: true
example:
data:
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
breakdown_start_timestamp: '2021-01-01T00:00:00Z'
breakdown_end_timestamp: '2021-01-02T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
status: DRAFT
subtotal: 14392
total: 14392
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
breakdown_start_timestamp: '2021-01-02T00:00:00Z'
breakdown_end_timestamp: '2021-01-03T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
status: DRAFT
subtotal: 14392
total: 14392
next_page: null
'404':
$ref: '#/components/responses/NotFound'
/v1/customers/{customer_id}/invoices/{invoice_id}/pdf:
get:
x-mint:
metadata:
tag: Beta
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.
### Use this endpoint to:
- Provide customers with downloadable or emailable copies of their invoices
- Support accounting and finance teams with official billing documents
- Maintain accurate records of billing transactions for audits and compliance
### Key response details:
- The response is a binary PDF file representing the full invoice
- The PDF includes all standard invoice information such as line items, totals, billing period, and customer details
- The document is formatted for clarity and professionalism, suitable for official use
### Usage guidelines:
- Ensure the `invoice_id` corresponds to an existing invoice for the specified `customer_id`
- The PDF is generated on-demand; frequent requests for the same invoice may impact performance
- Use appropriate headers to handle the binary response in your application (e.g., setting `Content-Type: application/pdf`)
'
operationId: getInvoicePdf-v1
summary: Get an invoice PDF
x-slo-tier: 1
parameters:
- $ref: '#/components/parameters/CustomerId'
- $ref: '#/components/parameters/InvoiceId'
tags:
- Invoices
responses:
'200':
description: Success
content:
application/pdf:
schema:
type: object
'404':
$ref: '#/components/responses/NotFound'
/v1/customers/{customer_id}/invoices/{invoice_id}:
get:
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"
operationId: getInvoice-v1
summary: Get an invoice
x-slo-tier: 1
parameters:
- $ref: '#/components/parameters/CustomerId'
- $ref: '#/components/parameters/InvoiceId'
- $ref: '#/components/parameters/SkipZeroQtyLineItems'
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
$ref: '#/components/schemas/Invoice'
examples:
contracts:
value:
data:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
total: 14392
status: FINALIZED
'404':
$ref: '#/components/responses/NotFound'
/v1/customers/{customer_id}/invoices/spend-breakdowns:
post:
x-mint:
groups:
- ff:spend-breakdowns
description: "Granularly analyze customer spend patterns by dynamically slicing and dicing costs across any dimension. This endpoint empowers you to break down spending by granular properties like user, organization, model, region, or any custom event property—even if these aren't the default groupings on your invoices. Unlike standard invoice breakdowns, this endpoint focuses purely on spend analysis, making helpful for building powerful cost analytics dashboards that show spend before credit/commit application.\n\n### Use this endpoint to:\n- Identify cost drivers: Pinpoint which users, teams, or resources are driving the most spend\n- Build usage analytics dashboards: Let customers explore their costs by any event property (user_id, org_id, model_id, region, etc.)\n- Enable showback/chargeback: Allocate costs to specific departments, projects, or cost centers\n- Detect anomalies: Find unexpected spending patterns by analyzing costs across different dimensions\n- Optimize resource usage: Help customers identify underutilized or over-provisioned resources\n- Support multi-tenancy: Show spending breakdowns for specific organizations within a single account\n- Create custom reports: Generate executive dashboards with spending by any business-relevant dimension\n\n### Key response fields:\nSpend-focused invoice data with:\n- Pure spend information: No commits or credits—just raw spending data for cleaner analysis\n- Dynamic grouping: Line items grouped by your specified group_keys (overriding default presentation groups)\n- Filtered results: Only line items matching your group_filters criteria\n- Flexible time windows: Daily, hourly, or full-period (none) breakdowns\n- Complete line item details: Including quantities, unit prices, and custom presentation group values\n\n### Usage guidelines:\n- Group key setup: All keys used in group_keys, group_filters, and pricing groups must exist in the same compound group key on the billable metric\n- Supported window sizes: hour, day, or none (for full period analysis)\n- Filtering power: Use group_filters to focus on specific values (e.g., only show data for specific user_ids)\n- Override flexibility: Change how costs are grouped without affecting actual invoicing\n\nLimitations:\n- Cannot override group keys when using:\n - MAX aggregation billable metrics\n - Tiered pricing\n - Quantity rounding\n - Commit-specific overrides\n - Overrides on presentation group values"
operationId: listSpendBreakdownInvoices-v1
summary: List spend invoice breakdowns
x-slo-tier: 1
parameters:
- $ref: '#/components/parameters/CustomerId'
- $ref: '#/components/parameters/IncludeListPrices'
tags:
- Invoices
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SpendBreakdownInvoicesQueryPayload'
example:
starting_on: '2021-01-01T00:00:00Z'
ending_before: '2021-02-01T00:00:00Z'
credit_type_id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
window_size: day
sort: date_desc
group_keys:
- region
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required:
- data
- next_page
properties:
data:
type: array
items:
$ref: '#/components/schemas/SpendBreakdownInvoice'
next_page:
type: string
nullable: true
example:
data:
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
breakdown_start_timestamp: '2021-01-01T00:00:00Z'
breakdown_end_timestamp: '2021-01-02T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
status: DRAFT
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
breakdown_start_timestamp: '2021-01-02T00:00:00Z'
breakdown_end_timestamp: '2021-01-03T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
name: CPU hours
type: usage
quantity: 1488
total: 14392
product_id: 5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8
status: DRAFT
next_page: null
'404':
$ref: '#/components/responses/NotFound'
/v1/invoices/void:
post:
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.
'
operationId: voidInvoice-v1
summary: Void an invoice
requestBody:
description: The invoice id to void
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
description: The invoice id to void
type: string
format: uuid
example:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
data:
type: object
required:
- id
properties:
id:
type: string
format: uuid
example:
data:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
/v1/invoices/regenerate:
post:
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.
### Use this endpoint to:
Recalculate an invoice with updated rate terms, available balance, and fees to correct billing disputes or discrepancies
### Key response fields:
The regenerated invoice id, which is distinct from the previously voided invoice.
### Usage guidelines:
If an invoice is attached to a contract with a billing provider on it, the regenerated invoice will be distributed based on the configuration.
'
operationId: regenerateInvoice-v1
summary: Regenerate an invoice
requestBody:
description: The invoice id to regenerate
content:
application/json:
schema:
type: object
required:
- id
properties:
id:
description: The invoice id to regenerate
type: string
format: uuid
example:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
properties:
data:
type: object
required:
- id
properties:
id:
type: string
format: uuid
description: The new invoice id
example:
data:
id: 6a37bb88-8538-48c5-b37b-a41c836328bd
/v1/customers/{customer_id}/previewEvents:
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.
'
operationId: previewCustomerEvents-v1
tags:
- Invoices
responses:
'200':
description: Success
content:
application/json:
schema:
type: object
required:
- data
properties:
data:
type: array
items:
$ref: '#/components/schemas/Invoice'
example:
data:
- id: 6a37bb88-8538-48c5-b37b-a41c836328bd
customer_id: 617e39d8-68f4-4592-b8d2-c2bf26a76989
type: USAGE
start_timestamp: '2021-01-01T00:00:00Z'
end_timestamp: '2021-02-01T00:00:00Z'
credit_type:
id: 2714e483-4ff1-48e4-9e25-ac732e8f24f2
name: USD (cents)
contract_id: 9de042a1-b955-43ce-9ab4-e3c2004570d1
line_items:
- credit_type:
# --- truncated at 32 KB (66 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/metronome/refs/heads/main/openapi/metronome-invoices-api-openapi.yml