> ## Documentation Index
> Fetch the complete documentation index at: https://docs.creem.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview an unsaved meter definition

> Dry-run a candidate meter definition against your real usage over the last 7 whole UTC days (today included, future-dated events excluded) WITHOUT creating anything: matched events, aggregated units, distinct customers, and a zero-filled per-day series, oldest first. Useful for checking a definition before committing to it. The scan is capped defensively and runs newest-first, so a very high-volume store gets the most recent slice of the window rather than an unbounded scan — the recent days stay complete and the oldest day of the series degrades.



## OpenAPI

````yaml post /v1/meters/preview
openapi: 3.0.0
info:
  title: Creem API
  description: >-
    Creem is an all-in-one platform for managing subscriptions and recurring
    revenue, tailored specifically for today's SaaS companies. It enables you to
    boost revenue, enhance customer retention, and scale your operations
    seamlessly.
  version: v1
  contact:
    name: Creem Support
    url: https://creem.io
    email: support@creem.io
  license:
    name: Commercial
    url: https://creem.io/terms
  termsOfService: https://creem.io/terms
servers:
  - url: https://api.creem.io
    description: Production — live API for processing real transactions and data.
    x-speakeasy-server-id: prod
  - url: https://test-api.creem.io
    description: Test — sandbox API for development and testing with no real charges.
    x-speakeasy-server-id: test
security: []
tags: []
externalDocs:
  description: Creem Documentation
  url: https://docs.creem.io
paths:
  /v1/meters/preview:
    post:
      tags:
        - Meters
      summary: Preview an unsaved meter definition
      description: >-
        Dry-run a candidate meter definition against your real usage over the
        last 7 whole UTC days (today included, future-dated events excluded)
        WITHOUT creating anything: matched events, aggregated units, distinct
        customers, and a zero-filled per-day series, oldest first. Useful for
        checking a definition before committing to it. The scan is capped
        defensively and runs newest-first, so a very high-volume store gets the
        most recent slice of the window rather than an unbounded scan — the
        recent days stay complete and the oldest day of the series degrades.
      operationId: previewMeter
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewMeterApiRequestDto'
      responses:
        '200':
          description: Preview of the candidate definition
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MeterPreviewApiResponseDto'
        '400':
          description: Bad Request - Invalid input parameters
        '401':
          description: Unauthorized - Invalid or missing API key
        '404':
          description: Not Found - Resource does not exist
        '422':
          description: The candidate definition is not satisfiable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageMeteringErrorApiResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    PreviewMeterApiRequestDto:
      type: object
      properties:
        event_name:
          type: string
          description: The usage event name the candidate meter would consume
          example: image.generated
        aggregation:
          type: string
          description: Aggregation to dry-run
          enum:
            - count
            - sum
            - average
            - min
            - max
            - unique
          example: count
        aggregation_property:
          type: string
          description: >-
            Event property the aggregation reduces. Required for every
            aggregation except "count".
          example: tokens
        filter:
          description: Optional filter to dry-run alongside the aggregation
          allOf:
            - $ref: '#/components/schemas/MeterFilterApiRequestDto'
        unit_label:
          type: string
          description: >-
            Display unit for the preview. Cosmetic (nothing is persisted);
            defaults to "units".
          example: images
          default: units
      required:
        - event_name
        - aggregation
    MeterPreviewApiResponseDto:
      type: object
      properties:
        matched_events:
          type: number
          description: Events the meter would count over the preview window
          example: 137
        units:
          type: string
          description: >-
            Aggregated units over the whole window, as a string for BigInt
            safety
          example: '4820'
        distinct_customers:
          type: number
          description: Distinct customers among the matching events
          example: 12
        daily:
          description: The last 7 UTC days (today included), oldest first and zero-filled
          type: array
          items:
            $ref: '#/components/schemas/MeterPreviewDailyApiResponseDto'
      required:
        - matched_events
        - units
        - distinct_customers
        - daily
    UsageMeteringErrorApiResponseDto:
      type: object
      properties:
        error:
          description: Error details
          allOf:
            - $ref: '#/components/schemas/UsageMeteringErrorDetailApiDto'
      required:
        - error
    MeterFilterApiRequestDto:
      type: object
      properties:
        conjunction:
          type: string
          description: How the clauses combine
          enum:
            - and
            - or
          example: and
        clauses:
          description: >-
            Filter clauses. An empty list means the meter counts every event
            with the given event name.
          type: array
          items:
            $ref: '#/components/schemas/FilterClauseApiRequestDto'
      required:
        - conjunction
        - clauses
    MeterPreviewDailyApiResponseDto:
      type: object
      properties:
        date:
          type: string
          description: UTC calendar day
          example: '2026-08-16'
        event_count:
          type: number
          description: Matching events on this day
          example: 42
        value:
          type: string
          description: >-
            The aggregation folded over this day alone, as a string for BigInt
            safety
          example: '1280'
      required:
        - date
        - event_count
        - value
    UsageMeteringErrorDetailApiDto:
      type: object
      properties:
        type:
          type: string
          description: Error category
          enum:
            - invalid_request_error
            - api_error
            - authentication_error
            - rate_limit_error
          example: invalid_request_error
        code:
          type: string
          description: Machine-readable error code
          example: meter_name_taken
          nullable: true
        message:
          type: string
          description: Human-readable error message
          example: A meter named "Image generations" already exists in this store
        param:
          type: string
          description: The parameter related to the error, if applicable
          example: events[3].customer_id
          nullable: true
        details:
          type: object
          description: >-
            Structured, machine-readable context for errors that support an
            action, omitted entirely when there is none. Currently emitted for
            `meter_name_taken` when the colliding name is held by an ARCHIVED
            meter: `archived_holder` is true and `archived_holder_id` is that
            meter, which can be restored via POST /v1/meters/{id}/unarchive.
            Additive — treat unknown keys as ignorable.
          example:
            archived_holder: true
            archived_holder_id: mtr_abc123
        request_id:
          type: string
          description: Unique request identifier for support
          example: req_abc123def456
      required:
        - type
        - code
        - message
        - request_id
    FilterClauseApiRequestDto:
      type: object
      properties:
        property:
          type: string
          description: >-
            Event property to test. Resolved as a top-level property first, then
            as a metadata key — never prefixed with "metadata.".
          example: tier
        operator:
          type: string
          description: Comparison operator
          enum:
            - equals
            - not_equals
            - gt
            - gte
            - lt
            - lte
            - contains
            - not_contains
          example: equals
        value:
          description: >-
            Value to compare against. Auto-parsed (number → boolean → string) on
            both sides before comparison, so "10" and 10 behave the same — which
            is why a raw number or boolean is accepted here as well as a string.
          example: pro
          oneOf:
            - type: string
            - type: number
            - type: boolean
      required:
        - property
        - operator
        - value
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. You can find your API key in the Creem
        dashboard under Settings > API Keys.

````