Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
Billing
    Overview
    About the Billing APIs
    Subscriptions
    Invoicing
    Usage-based billing
      Choose a usage-based billing setup
      Record usage for billing
        Create a meter
        Configure a meter
        Record usage with the API
        Record usage in the Dashboard
        Record usage with S3
        Configure grace period
      Offer billing credits
      Monitor usage
      Usage-based pricing models
    Connect and Billing
    Tax and Billing
    Quotes
    Revenue recovery
    Automations
    Scripts
    Revenue recognition
    Customer management
    Entitlements
    Test your integration
Tax
Reporting
Data
Startup incorporation
HomeFinance automationBillingUsage-based billingRecord usage for billing

Configure meters

Configure meters for usage-based billing.

Copy page

Before you can record customer usage, you must create a Meter, then configure it. After you configure the meter, you can’t make any changes aside from the display name.

Meter configuration attributes

Meter attributeDescription
Event nameThe name of the meter event that you want to record usage for with the meter. When you send usage to Stripe, specify this event name in the event_name field for the Meter Event. This allows the correct meter to record and aggregate the usage. You can only use an event name with a single meter.

Event ingestion

Specify how to send events to Stripe:

  • Raw: Handle all meter events as standalone events. Multiple events sent for the same timestamp don’t overwrite each other. The aggregation includes the multiple events. This is the default option if you don’t specify anything.
  • Pre-aggregated: If you send events for a specific time interval (hourly or daily), Stripe only uses the most recently received meter event in that time interval. A newer event sent within the same hourly or daily window overwrites the previous one. The meter event timestamp in UTC dictates the hour and day boundaries.

Aggregation formula

Specify how to aggregate usage over the billing period:

  • Sum: Bill customers based on the sum of all usage values for the billing period.
  • Count: Bill customers based on the count of all usage for the billing period.
  • Last: Bill customers based on the most recent usage event’s value for the billing period.

Payload key overrides

Specify which keys in the event payload refer to the customer and numerical usage values:

  • value_settings: Use this parameter to define the key in the event payload that refers to the numerical usage value. The default key is value, but you can specify a different key, such as tokens.
  • customer_mapping: Use this parameter to define the key in the event payload that refers to the Customer ID. The default key is stripe_customer_id, but you can specify a different key, such as customer_id.

Fix incorrect usage data

If you identify incorrectly recorded events in the current billing period, you can create a Meter Event Adjustment to cancel those events. You must specify the identifier for the meter event.

You can only cancel events sent to Stripe within the last 24 hours. If you cancel usage that’s included on a finalized invoice, we won’t update the invoice or issue a corrected invoice for the canceled usage. We don’t support billing adjustments for canceled usage on a finalized invoice sent to a customer.

You can also fix incorrectly recorded usage data by recording negative quantities. If the overall cycle usage is negative, Stripe reports the invoice line item usage quantity as 0.

Command Line
cURL
curl https://api.stripe.com/v1/billing/meter_event_adjustments \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d type=cancel \ -d event_name=alpaca_ai_tokens \ -d "cancel[identifier]"={{METER_EVENT_IDENTIFIER}}
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc
Related Guides
Usage-based pricing models
Products Used
Billing