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

# Create credit note

> Use when issuing a refund or adjustment (e.g. customer dispute or proration). Links to an invoice; create as draft then finalize.



## OpenAPI

````yaml /api-reference/openapi.json post /creditnotes
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /creditnotes:
    post:
      tags:
        - Credit Notes
      summary: Create credit note
      description: >-
        Use when issuing a refund or adjustment (e.g. customer dispute or
        proration). Links to an invoice; create as draft then finalize.
      operationId: createCreditNote
      requestBody:
        description: Credit note request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCreditNoteRequest'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNoteResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    CreateCreditNoteRequest:
      required:
        - invoice_id
        - reason
      type: object
      properties:
        credit_note_number:
          type: string
          description: >-
            credit_note_number is an optional human-readable identifier for the
            credit note
        idempotency_key:
          type: string
          description: >-
            idempotency_key is an optional key used to prevent duplicate credit
            note creation
        invoice_id:
          type: string
          description: >-
            invoice_id is the unique identifier of the invoice this credit note
            is applied to
        line_items:
          type: array
          description: >-
            line_items contains the individual line items that make up this
            credit note (minimum 1 required)
          items:
            $ref: '#/components/schemas/CreateCreditNoteLineItemRequest'
        memo:
          type: string
          description: >-
            memo is an optional free-text field for additional notes about the
            credit note
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        process_credit_note:
          type: boolean
          description: >-
            process_credit_note is a flag to process the credit note after
            creation
          default: true
        reason:
          $ref: '#/components/schemas/types.CreditNoteReason'
    CreditNoteResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        credit_note_number:
          type: string
          description: credit_note_number is the unique identifier for credit notes
        credit_note_status:
          $ref: '#/components/schemas/types.CreditNoteStatus'
        credit_note_type:
          $ref: '#/components/schemas/types.CreditNoteType'
        currency:
          type: string
          description: >-
            currency is the three-letter ISO currency code (e.g., USD, EUR) for
            the credit note
        customer:
          $ref: '#/components/schemas/Customer'
        customer_id:
          type: string
          description: >-
            customer_id is the unique identifier of the customer who owns this
            credit note
        environment_id:
          type: string
          description: >-
            environment_id is the unique identifier of the environment this
            credit note belongs to
        finalized_at:
          type: string
          description: finalized_at is the timestamp when the credit note was finalized
          format: date-time
        id:
          type: string
          description: id is the unique identifier for the credit note
        idempotency_key:
          type: string
          description: >-
            idempotency_key is an optional key used to prevent duplicate credit
            note creation
        invoice:
          $ref: '#/components/schemas/InvoiceResponse'
        invoice_id:
          type: string
          description: >-
            invoice_id is the id of the invoice resource that this credit note
            is applied to
        line_items:
          type: array
          description: >-
            line_items contains all of the line items associated with this
            credit note
          items:
            $ref: '#/components/schemas/creditnote.CreditNoteLineItem'
        memo:
          type: string
          description: memo is an optional memo supplied on the credit note
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        reason:
          $ref: '#/components/schemas/types.CreditNoteReason'
        refund_status:
          $ref: '#/components/schemas/types.PaymentStatus'
        status:
          $ref: '#/components/schemas/types.Status'
        subscription:
          $ref: '#/components/schemas/SubscriptionResponse'
        subscription_id:
          type: string
          description: >-
            subscription_id is the optional unique identifier of the
            subscription related to this credit note
        tenant_id:
          type: string
        total_amount:
          type: string
          description: >-
            total_amount is the total including creditable invoice-level
            discounts or minimums, and tax
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        voided_at:
          type: string
          description: voided_at is the timestamp when the credit note was voided
          format: date-time
    errors.ErrorResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - not_found
            - already_exists
            - version_conflict
            - validation_error
            - invalid_operation
            - permission_denied
            - http_client_error
            - database_error
            - system_error
            - internal_error
            - service_unavailable
        details:
          type: object
          additionalProperties:
            type: object
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    CreateCreditNoteLineItemRequest:
      required:
        - amount
        - invoice_line_item_id
      type: object
      properties:
        amount:
          type: string
          description: amount is the monetary amount to be credited for this line item
        display_name:
          type: string
          description: >-
            display_name is an optional human-readable name for this credit note
            line item
        invoice_line_item_id:
          type: string
          description: >-
            invoice_line_item_id is the unique identifier of the invoice line
            item being credited
        metadata:
          $ref: '#/components/schemas/types.Metadata'
    types.Metadata:
      type: object
      additionalProperties:
        type: string
      x-speakeasy-name-override: Metadata
    types.CreditNoteReason:
      type: string
      enum:
        - DUPLICATE
        - FRAUDULENT
        - ORDER_CHANGE
        - UNSATISFACTORY
        - SERVICE_ISSUE
        - BILLING_ERROR
        - SUBSCRIPTION_CANCELLATION
      x-enum-varnames:
        - CreditNoteReasonDuplicate
        - CreditNoteReasonFraudulent
        - CreditNoteReasonOrderChange
        - CreditNoteReasonUnsatisfactory
        - CreditNoteReasonService
        - CreditNoteReasonBillingError
        - CreditNoteReasonSubscriptionCancellation
      x-speakeasy-name-override: CreditNoteReason
    types.CreditNoteStatus:
      type: string
      enum:
        - DRAFT
        - FINALIZED
        - VOIDED
      x-enum-varnames:
        - CreditNoteStatusDraft
        - CreditNoteStatusFinalized
        - CreditNoteStatusVoided
      x-speakeasy-name-override: CreditNoteStatus
    types.CreditNoteType:
      type: string
      enum:
        - ADJUSTMENT
        - REFUND
      x-enum-varnames:
        - CreditNoteTypeAdjustment
        - CreditNoteTypeRefund
      x-speakeasy-name-override: CreditNoteType
    Customer:
      type: object
      properties:
        address_city:
          type: string
          description: AddressCity is the city of the customer's address
        address_country:
          type: string
          description: >-
            AddressCountry is the country of the customer's address (ISO 3166-1
            alpha-2)
        address_line1:
          type: string
          description: AddressLine1 is the first line of the customer's address
        address_line2:
          type: string
          description: AddressLine2 is the second line of the customer's address
        address_postal_code:
          type: string
          description: AddressPostalCode is the postal code of the customer's address
        address_state:
          type: string
          description: AddressState is the state of the customer's address
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        email:
          type: string
          description: Email is the email of the customer
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the customer
        external_id:
          type: string
          description: ExternalID is the external identifier for the customer
        id:
          type: string
          description: ID is the unique identifier for the customer
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Metadata
        name:
          type: string
          description: Name is the name of the customer
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    InvoiceResponse:
      type: object
      properties:
        adjustment_amount:
          type: string
          description: >-
            adjustment_amount is the total sum of credit notes of type
            "adjustment".

            These are non-cash reductions applied to the invoice (e.g. goodwill
            credit, billing correction).
        amount_due:
          type: string
          description: >-
            amount_due is the total amount that needs to be paid for this
            invoice
        amount_paid:
          type: string
          description: >-
            amount_paid is the amount that has already been paid towards this
            invoice
        amount_remaining:
          type: string
          description: >-
            amount_remaining is the outstanding amount still owed on this
            invoice (calculated as amount_due minus amount_paid)
        billing_period:
          type: string
          description: >-
            billing_period describes the billing period this invoice covers
            (e.g., "January 2024", "Q1 2024")
        billing_reason:
          type: string
          description: >-
            billing_reason indicates why this invoice was generated (e.g.,
            "subscription_billing", "manual_charge")
        billing_sequence:
          type: integer
          description: >-
            billing_sequence is the sequential number indicating the billing
            cycle for subscription invoices
        coupon_applications:
          type: array
          description: >-
            coupon_applications contains the coupon applications associated with
            this invoice (overrides embedded field)
          items:
            $ref: '#/components/schemas/CouponApplicationResponse'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
          description: >-
            currency is the three-letter ISO currency code (e.g., USD, EUR, GBP)
            that applies to all monetary amounts on this invoice
        customer:
          $ref: '#/components/schemas/CustomerResponse'
        customer_id:
          type: string
          description: customer_id is the ID of the customer who will receive this invoice
        description:
          type: string
          description: description is an optional description or notes about this invoice
        due_date:
          type: string
          description: due_date is the date when payment for this invoice is due
          format: date-time
        environment_id:
          type: string
          description: >-
            environment_id is the ID of the environment this invoice belongs to
            (for multi-environment setups)
        finalized_at:
          type: string
          description: >-
            finalized_at is the timestamp when this invoice was finalized and
            made ready for payment
          format: date-time
        id:
          type: string
          description: id is the unique identifier for this invoice
        idempotency_key:
          type: string
          description: >-
            idempotency_key is a unique key used to prevent duplicate invoice
            creation when retrying API calls
        invoice_number:
          type: string
          description: >-
            invoice_number is the human-readable invoice number displayed to
            customers (e.g., INV-2024-001)
        invoice_pdf_url:
          type: string
          description: >-
            invoice_pdf_url is the URL where customers can download the PDF
            version of this invoice
        invoice_status:
          $ref: '#/components/schemas/types.InvoiceStatus'
        invoice_type:
          $ref: '#/components/schemas/types.InvoiceType'
        last_computed_at:
          type: string
          description: >-
            last_computed_at is the timestamp when this invoice was last
            computed by ComputeInvoice
          format: date-time
        line_items:
          type: array
          description: >-
            line_items contains the individual items that make up this invoice
            (overrides embedded field)
          items:
            $ref: '#/components/schemas/InvoiceLineItemResponse'
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        overpaid_amount:
          type: string
          description: >-
            overpaid_amount is the amount overpaid if payment_status is OVERPAID
            (amount_paid - total)
        paid_at:
          type: string
          description: paid_at is the timestamp when this invoice was fully paid
          format: date-time
        payment_status:
          $ref: '#/components/schemas/types.PaymentStatus'
        period_end:
          type: string
          description: >-
            period_end is the end date of the billing period covered by this
            invoice
          format: date-time
        period_start:
          type: string
          description: >-
            period_start is the start date of the billing period covered by this
            invoice
          format: date-time
        recalculated_invoice_id:
          type: string
          description: >-
            recalculated_invoice_id is the ID of the replacement invoice created
            when this invoice was voided and recalculated.

            When set, it forms a parent→child link from this (voided) invoice to
            the new replacement invoice.
        refunded_amount:
          type: string
          description: |-
            refunded_amount is the total sum of credit notes of type "refund".
            These are actual refunds issued to the customer.
        status:
          $ref: '#/components/schemas/types.Status'
        subscription:
          $ref: '#/components/schemas/SubscriptionResponse'
        subscription_customer_id:
          type: string
          description: >-
            subscription_customer_id is the subscription owner's customer ID
            (Subscription.CustomerID).

            It may differ from customer_id when the subscription uses an
            invoicing customer. Set internally; nullable in DB.
        subscription_id:
          type: string
          description: >-
            subscription_id is the ID of the subscription this invoice is
            associated with (only present for subscription-based invoices)
        subtotal:
          type: string
          description: >-
            subtotal is the sum of all line items before any taxes, discounts,
            or additional fees
        taxes:
          type: array
          description: >-
            tax_applied_records contains the tax applied records associated with
            this invoice
          items:
            $ref: '#/components/schemas/TaxAppliedResponse'
        tenant_id:
          type: string
        total:
          type: string
          description: total is the final amount including taxes, fees, and discounts
        total_discount:
          type: string
          description: >-
            total_discount is the sum of all coupon discounts applied to the
            invoice
        total_prepaid_credits_applied:
          type: string
          description: >-
            total_prepaid_credits_applied is the total amount of prepaid credits
            applied to this invoice.
        total_tax:
          type: string
          description: total_tax is the sum of all taxes combined at the invoice level.
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        version:
          type: integer
          description: version is the version number for tracking changes to this invoice
        voided_at:
          type: string
          description: voided_at is the timestamp when this invoice was voided or cancelled
          format: date-time
    creditnote.CreditNoteLineItem:
      type: object
      properties:
        amount:
          type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        credit_note_id:
          type: string
        currency:
          type: string
        display_name:
          type: string
        environment_id:
          type: string
        id:
          type: string
        invoice_line_item_id:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.PaymentStatus:
      type: string
      enum:
        - INITIATED
        - PENDING
        - PROCESSING
        - SUCCEEDED
        - OVERPAID
        - FAILED
        - REFUNDED
        - PARTIALLY_REFUNDED
      x-enum-varnames:
        - PaymentStatusInitiated
        - PaymentStatusPending
        - PaymentStatusProcessing
        - PaymentStatusSucceeded
        - PaymentStatusOverpaid
        - PaymentStatusFailed
        - PaymentStatusRefunded
        - PaymentStatusPartiallyRefunded
      x-speakeasy-name-override: PaymentStatus
    types.Status:
      type: string
      enum:
        - published
        - deleted
        - archived
      x-enum-varnames:
        - StatusPublished
        - StatusDeleted
        - StatusArchived
      x-speakeasy-name-override: Status
    SubscriptionResponse:
      type: object
      properties:
        active_pause_id:
          type: string
          description: |-
            ActivePauseID references the current active pause configuration
            This will be null if no pause is active or scheduled
        billing_anchor:
          type: string
          description: >-
            BillingAnchor is the reference point that aligns future billing
            cycle dates.

            It sets the day of week for week intervals, the day of month for
            month and year intervals,

            and the month of year for year intervals. The timestamp is in UTC
            format.
          format: date-time
        billing_cadence:
          $ref: '#/components/schemas/types.BillingCadence'
        billing_cycle:
          $ref: '#/components/schemas/types.BillingCycle'
        billing_period:
          $ref: '#/components/schemas/types.BillingPeriod'
        billing_period_count:
          type: integer
          description: BillingPeriodCount is the total number units of the billing period.
        cancel_at:
          type: string
          description: CancelAt is the date the subscription will be canceled
          format: date-time
        cancel_at_period_end:
          type: boolean
          description: >-
            CancelAtPeriodEnd is whether the subscription was canceled at the
            end of the current period
        cancelled_at:
          type: string
          description: CanceledAt is the date the subscription was canceled
          format: date-time
        collection_method:
          type: string
          description: CollectionMethod determines how invoices are collected
        commitment_amount:
          type: string
          description: >-
            CommitmentAmount is the minimum amount a customer commits to paying
            for a billing period
        commitment_duration:
          $ref: '#/components/schemas/types.BillingPeriod'
        coupon_associations:
          type: array
          description: CouponAssociations are the coupon associations for this subscription
          items:
            $ref: '#/components/schemas/CouponAssociationResponse'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        credit_grants:
          type: array
          description: Credit grants are the credit grants for this subscription
          items:
            $ref: '#/components/schemas/CreditGrantResponse'
        currency:
          type: string
          description: >-
            Currency is the currency of the subscription in lowercase 3 digit
            ISO codes
        current_period_end:
          type: string
          description: >-
            CurrentPeriodEnd is the end of the current period that the
            subscription has been invoiced for.

            At the end of this period, a new invoice will be created.
          format: date-time
        current_period_start:
          type: string
          description: >-
            CurrentPeriodStart is the end of the current period that the
            subscription has been invoiced for.

            At the end of this period, a new invoice will be created.
          format: date-time
        customer:
          $ref: '#/components/schemas/CustomerResponse'
        customer_id:
          type: string
          description: CustomerID is the identifier for the customer in our system
        customer_timezone:
          type: string
        enable_true_up:
          type: boolean
        end_date:
          type: string
          description: EndDate is the end date of the subscription
          format: date-time
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the subscription
        gateway_payment_method_id:
          type: string
          description: >-
            GatewayPaymentMethodID is the gateway payment method ID for this
            subscription
        id:
          type: string
          description: ID is the unique identifier for the subscription
        invoicing_customer_id:
          type: string
          description: >-
            InvoicingCustomerID is the customer ID to use for invoicing

            This can differ from the subscription customer (e.g., parent company
            invoicing for child company)
        latest_invoice:
          $ref: '#/components/schemas/InvoiceResponse'
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/subscription.SubscriptionLineItem'
        lookup_key:
          type: string
          description: LookupKey is the key used to lookup the subscription in our system
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        overage_factor:
          type: string
          description: >-
            OverageFactor is a multiplier applied to usage beyond the commitment
            amount
        parent_subscription_id:
          type: string
          description: >-
            ParentSubscriptionID is the parent subscription ID for hierarchy
            (e.g. child subscription under a parent)
        pause_status:
          $ref: '#/components/schemas/types.PauseStatus'
        pauses:
          type: array
          items:
            $ref: '#/components/schemas/subscription.SubscriptionPause'
        payment_behavior:
          type: string
          description: PaymentBehavior determines how subscription payments are handled
        payment_terms:
          $ref: '#/components/schemas/types.PaymentTerms'
        phases:
          type: array
          description: Phases are the subscription phases for this subscription
          items:
            $ref: '#/components/schemas/SubscriptionPhaseResponse'
        plan:
          $ref: '#/components/schemas/PlanResponse'
        plan_id:
          type: string
          description: PlanID is the identifier for the plan in our system
        proration_behavior:
          $ref: '#/components/schemas/types.ProrationBehavior'
        start_date:
          type: string
          description: StartDate is the start date of the subscription
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_status:
          $ref: '#/components/schemas/types.SubscriptionStatus'
        subscription_type:
          $ref: '#/components/schemas/types.SubscriptionType'
        tenant_id:
          type: string
        trial_end:
          type: string
          description: TrialEnd is the end date of the trial period
          format: date-time
        trial_start:
          type: string
          description: TrialStart is the start date of the trial period
          format: date-time
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        version:
          type: integer
          description: Version is used for optimistic locking
    CouponApplicationResponse:
      type: object
      properties:
        applied_at:
          type: string
          format: date-time
        coupon_association_id:
          type: string
        coupon_id:
          type: string
        coupon_snapshot:
          type: object
          additionalProperties: true
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
        discount_percentage:
          type: string
        discount_type:
          $ref: '#/components/schemas/types.CouponType'
        discounted_amount:
          type: string
        environment_id:
          type: string
        final_price:
          type: string
        id:
          type: string
        invoice_id:
          type: string
        invoice_line_item_id:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        original_price:
          type: string
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    CustomerResponse:
      type: object
      properties:
        address_city:
          type: string
          description: AddressCity is the city of the customer's address
        address_country:
          type: string
          description: >-
            AddressCountry is the country of the customer's address (ISO 3166-1
            alpha-2)
        address_line1:
          type: string
          description: AddressLine1 is the first line of the customer's address
        address_line2:
          type: string
          description: AddressLine2 is the second line of the customer's address
        address_postal_code:
          type: string
          description: AddressPostalCode is the postal code of the customer's address
        address_state:
          type: string
          description: AddressState is the state of the customer's address
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        email:
          type: string
          description: Email is the email of the customer
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the customer
        external_id:
          type: string
          description: ExternalID is the external identifier for the customer
        id:
          type: string
          description: ID is the unique identifier for the customer
        integrations:
          type: array
          items:
            $ref: '#/components/schemas/EntityIntegrationMappingResponse'
        metadata:
          type: object
          additionalProperties:
            type: string
          description: Metadata
        name:
          type: string
          description: Name is the name of the customer
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
      description: Customer response object containing all customer information
    types.InvoiceStatus:
      type: string
      enum:
        - DRAFT
        - FINALIZED
        - VOIDED
        - SKIPPED
      x-enum-varnames:
        - InvoiceStatusDraft
        - InvoiceStatusFinalized
        - InvoiceStatusVoided
        - InvoiceStatusSkipped
      x-speakeasy-name-override: InvoiceStatus
    types.InvoiceType:
      type: string
      enum:
        - SUBSCRIPTION
        - ONE_OFF
        - CREDIT
      x-enum-varnames:
        - InvoiceTypeSubscription
        - InvoiceTypeOneOff
        - InvoiceTypeCredit
      x-speakeasy-name-override: InvoiceType
    InvoiceLineItemResponse:
      type: object
      properties:
        amount:
          type: string
        commitment_info:
          $ref: '#/components/schemas/types.CommitmentInfo'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
        customer_id:
          type: string
        display_name:
          type: string
        entity_id:
          type: string
        entity_type:
          type: string
        environment_id:
          type: string
        id:
          type: string
        invoice_id:
          type: string
        invoice_level_discount:
          type: string
          description: >-
            invoice_level_discount is the discount amount in invoice currency
            applied to all line items on the invoice.
        line_item_discount:
          type: string
          description: >-
            line_item_discount is the discount amount in invoice currency
            applied directly to this line item.
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        meter_display_name:
          type: string
        meter_id:
          type: string
        period_end:
          type: string
          format: date-time
        period_start:
          type: string
          format: date-time
        plan_display_name:
          type: string
        prepaid_credits_applied:
          type: string
          description: >-
            prepaid_credits_applied is the amount in invoice currency reduced
            from this line item due to prepaid credits application.
        price_id:
          type: string
        price_type:
          type: string
        price_unit:
          type: string
        price_unit_amount:
          type: string
        price_unit_id:
          type: string
        quantity:
          type: string
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        usage_analytics:
          type: array
          description: >-
            usage_analytics contains usage analytics for this line item (legacy
            - grouped by source)
          items:
            $ref: '#/components/schemas/SourceUsageItem'
        usage_breakdown:
          type: array
          description: >-
            usage_breakdown contains flexible usage breakdown for this line item
            (supports any grouping)
          items:
            $ref: '#/components/schemas/UsageBreakdownItem'
    TaxAppliedResponse:
      type: object
      properties:
        applied_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
        entity_id:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.TaxRateEntityType'
        environment_id:
          type: string
        id:
          type: string
        idempotency_key:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        status:
          $ref: '#/components/schemas/types.Status'
        tax_amount:
          type: string
        tax_association_id:
          type: string
        tax_rate:
          $ref: '#/components/schemas/TaxRateResponse'
        tax_rate_id:
          type: string
        taxable_amount:
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.BillingCadence:
      type: string
      enum:
        - RECURRING
      x-enum-varnames:
        - BILLING_CADENCE_RECURRING
      x-speakeasy-name-override: BillingCadence
    types.BillingCycle:
      type: string
      enum:
        - anniversary
        - calendar
      x-enum-varnames:
        - BillingCycleAnniversary
        - BillingCycleCalendar
      x-speakeasy-name-override: BillingCycle
    types.BillingPeriod:
      type: string
      enum:
        - MONTHLY
        - ANNUAL
        - WEEKLY
        - DAILY
        - QUARTERLY
        - HALF_YEARLY
        - ONETIME
      x-enum-varnames:
        - BILLING_PERIOD_MONTHLY
        - BILLING_PERIOD_ANNUAL
        - BILLING_PERIOD_WEEKLY
        - BILLING_PERIOD_DAILY
        - BILLING_PERIOD_QUARTER
        - BILLING_PERIOD_HALF_YEAR
        - BILLING_PERIOD_ONETIME
      x-speakeasy-name-override: BillingPeriod
    CouponAssociationResponse:
      type: object
      properties:
        coupon:
          $ref: '#/components/schemas/Coupon'
        coupon_id:
          type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        end_date:
          type: string
          description: Optional
          format: date-time
        environment_id:
          type: string
        id:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        start_date:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
          description: Mandatory
        subscription_line_item_id:
          type: string
          description: Optional
        subscription_phase_id:
          type: string
          description: Optional
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    CreditGrantResponse:
      type: object
      properties:
        cadence:
          $ref: '#/components/schemas/types.CreditGrantCadence'
        conversion_rate:
          type: string
          description: |-
            amount in the currency =  number of credits * conversion_rate
            ex if conversion_rate is 1, then 1 USD = 1 credit
            ex if conversion_rate is 2, then 1 USD = 0.5 credits
            ex if conversion_rate is 0.5, then 1 USD = 2 credits
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        credit_grant_anchor:
          type: string
          format: date-time
        credits:
          type: string
        end_date:
          type: string
          format: date-time
        environment_id:
          type: string
        expiration_duration:
          type: integer
        expiration_duration_unit:
          $ref: '#/components/schemas/types.CreditGrantExpiryDurationUnit'
        expiration_type:
          $ref: '#/components/schemas/types.CreditGrantExpiryType'
        id:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        name:
          type: string
        period:
          $ref: '#/components/schemas/types.CreditGrantPeriod'
        period_count:
          type: integer
        plan_id:
          type: string
        priority:
          type: integer
        scope:
          $ref: '#/components/schemas/types.CreditGrantScope'
        start_date:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
        tenant_id:
          type: string
        topup_conversion_rate:
          type: string
          description: >-
            topup_conversion_rate is the conversion rate for the topup to the
            currency

            ex if topup_conversion_rate is 1, then 1 USD = 1 credit

            ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits

            ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    subscription.SubscriptionLineItem:
      type: object
      properties:
        addon_association_id:
          type: string
        billing_period:
          $ref: '#/components/schemas/types.BillingPeriod'
        billing_period_count:
          type: integer
          description: from price at create; default 1
        commitment_amount:
          type: string
          description: Commitment fields
        commitment_duration:
          $ref: '#/components/schemas/types.BillingPeriod'
        commitment_overage_factor:
          type: string
        commitment_quantity:
          type: string
        commitment_true_up_enabled:
          type: boolean
        commitment_type:
          $ref: '#/components/schemas/types.CommitmentType'
        commitment_windowed:
          type: boolean
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
        customer_id:
          type: string
        display_name:
          type: string
        end_date:
          type: string
          format: date-time
        entity_id:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.SubscriptionLineItemEntityType'
        environment_id:
          type: string
        id:
          type: string
        invoice_cadence:
          $ref: '#/components/schemas/types.InvoiceCadence'
        metadata:
          type: object
          additionalProperties:
            type: string
        meter_display_name:
          type: string
        meter_id:
          type: string
        plan_display_name:
          type: string
        price:
          $ref: '#/components/schemas/price.Price'
        price_id:
          type: string
        price_type:
          $ref: '#/components/schemas/types.PriceType'
        price_unit:
          type: string
        price_unit_id:
          type: string
        quantity:
          type: string
        start_date:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
        subscription_phase_id:
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.PauseStatus:
      type: string
      enum:
        - none
        - active
        - scheduled
        - completed
        - cancelled
      x-enum-varnames:
        - PauseStatusNone
        - PauseStatusActive
        - PauseStatusScheduled
        - PauseStatusCompleted
        - PauseStatusCancelled
      x-speakeasy-name-override: PauseStatus
    subscription.SubscriptionPause:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the pause
        id:
          type: string
          description: ID is the unique identifier for the subscription pause
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        original_period_end:
          type: string
          description: >-
            OriginalPeriodEnd is the end of the billing period when the pause
            was created
          format: date-time
        original_period_start:
          type: string
          description: >-
            OriginalPeriodStart is the start of the billing period when the
            pause was created
          format: date-time
        pause_end:
          type: string
          description: PauseEnd is when the pause will end (null for indefinite)
          format: date-time
        pause_mode:
          $ref: '#/components/schemas/types.PauseMode'
        pause_start:
          type: string
          description: PauseStart is when the pause actually started
          format: date-time
        pause_status:
          $ref: '#/components/schemas/types.PauseStatus'
        reason:
          type: string
          description: Reason is the reason for pausing
        resume_mode:
          $ref: '#/components/schemas/types.ResumeMode'
        resumed_at:
          type: string
          description: ResumedAt is when the pause was actually ended (if manually resumed)
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
          description: SubscriptionID is the identifier for the subscription
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.PaymentTerms:
      type: string
      enum:
        - 15 NET
        - 30 NET
        - 45 NET
        - 60 NET
        - 75 NET
        - 90 NET
      x-enum-varnames:
        - PaymentTerms15Net
        - PaymentTerms30Net
        - PaymentTerms45Net
        - PaymentTerms60Net
        - PaymentTerms75Net
        - PaymentTerms90Net
      x-speakeasy-name-override: PaymentTerms
    SubscriptionPhaseResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        end_date:
          type: string
          description: >-
            EndDate is when the phase ends (nil if phase is still active or
            indefinite)
          format: date-time
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the phase
        id:
          type: string
          description: ID is the unique identifier for the subscription phase
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        start_date:
          type: string
          description: StartDate is when the phase starts
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        subscription_id:
          type: string
          description: SubscriptionID is the identifier for the subscription
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    PlanResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        credit_grants:
          type: array
          items:
            $ref: '#/components/schemas/CreditGrantResponse'
        description:
          type: string
        display_order:
          type: integer
        entitlements:
          type: array
          items:
            $ref: '#/components/schemas/EntitlementResponse'
        environment_id:
          type: string
        id:
          type: string
        lookup_key:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        name:
          type: string
        prices:
          type: array
          description: 'TODO: Add inline addons'
          items:
            $ref: '#/components/schemas/PriceResponse'
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.ProrationBehavior:
      type: string
      enum:
        - create_prorations
        - none
      x-enum-comments:
        ProrationBehaviorCreateProrations: 'Default: Create credits/charges on invoice'
        ProrationBehaviorNone: Calculate but don't apply (e.g., for previews)
      x-enum-varnames:
        - ProrationBehaviorCreateProrations
        - ProrationBehaviorNone
      x-speakeasy-name-override: ProrationBehavior
    types.SubscriptionStatus:
      type: string
      enum:
        - active
        - paused
        - cancelled
        - incomplete
        - trialing
        - draft
      x-enum-varnames:
        - SubscriptionStatusActive
        - SubscriptionStatusPaused
        - SubscriptionStatusCancelled
        - SubscriptionStatusIncomplete
        - SubscriptionStatusTrialing
        - SubscriptionStatusDraft
      x-speakeasy-name-override: SubscriptionStatus
    types.SubscriptionType:
      type: string
      enum:
        - standalone
        - parent
        - inherited
      x-enum-varnames:
        - SubscriptionTypeStandalone
        - SubscriptionTypeParent
        - SubscriptionTypeInherited
      x-speakeasy-name-override: SubscriptionType
    types.CouponType:
      type: string
      enum:
        - fixed
        - percentage
      x-enum-varnames:
        - CouponTypeFixed
        - CouponTypePercentage
      x-speakeasy-name-override: CouponType
    EntityIntegrationMappingResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        entity_id:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.IntegrationEntityType'
        environment_id:
          type: string
        id:
          type: string
        provider_entity_id:
          type: string
        provider_type:
          type: string
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.CommitmentInfo:
      type: object
      properties:
        amount:
          type: string
        computed_commitment_utilized_amount:
          type: string
        computed_overage_amount:
          type: string
        computed_true_up_amount:
          type: string
          description: >-
            total_cost = computed_commitment_utilized_amount +
            computed_overage_amount + computed_true_up_amount
        duration:
          $ref: '#/components/schemas/types.BillingPeriod'
        is_windowed:
          type: boolean
        overage_factor:
          type: string
        quantity:
          type: string
          description: Only used for quantity-based commitments
        true_up_enabled:
          type: boolean
        type:
          $ref: '#/components/schemas/types.CommitmentType'
      x-speakeasy-name-override: CommitmentInfo
    SourceUsageItem:
      type: object
      properties:
        cost:
          type: string
          description: cost is the cost attributed to this source for the line item
        event_count:
          type: integer
          description: event_count is the number of events from this source (optional)
        percentage:
          type: string
          description: >-
            percentage is the percentage of total line item cost from this
            source (optional)
        source:
          type: string
          description: source is the name of the event source
        usage:
          type: string
          description: >-
            usage is the total usage amount from this source (optional, for
            additional context)
    UsageBreakdownItem:
      type: object
      properties:
        cost:
          type: string
          description: cost is the cost attributed to this group for the line item
        event_count:
          type: integer
          description: event_count is the number of events from this group (optional)
        grouped_by:
          type: object
          additionalProperties:
            type: string
          description: >-
            grouped_by contains the grouping field values (e.g., {"source":
            "api", "org_id": "org123"})
        percentage:
          type: string
          description: >-
            percentage is the percentage of total line item cost from this group
            (optional)
        usage:
          type: string
          description: >-
            usage is the total usage amount from this group (optional, for
            additional context)
    types.TaxRateEntityType:
      type: string
      enum:
        - customer
        - subscription
        - invoice
        - tenant
      x-enum-varnames:
        - TaxRateEntityTypeCustomer
        - TaxRateEntityTypeSubscription
        - TaxRateEntityTypeInvoice
        - TaxRateEntityTypeTenant
      x-speakeasy-name-override: TaxRateEntityType
    TaxRateResponse:
      type: object
      properties:
        code:
          type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        description:
          type: string
        environment_id:
          type: string
        fixed_value:
          type: string
        id:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        name:
          type: string
        percentage_value:
          type: string
        scope:
          $ref: '#/components/schemas/types.TaxRateScope'
        status:
          $ref: '#/components/schemas/types.Status'
        tax_rate_status:
          $ref: '#/components/schemas/types.TaxRateStatus'
        tax_rate_type:
          $ref: '#/components/schemas/types.TaxRateType'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    Coupon:
      type: object
      properties:
        amount_off:
          type: string
        cadence:
          $ref: '#/components/schemas/types.CouponCadence'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
        duration_in_periods:
          type: integer
        environment_id:
          type: string
        id:
          type: string
        max_redemptions:
          type: integer
        metadata:
          type: object
          additionalProperties:
            type: string
        name:
          type: string
        percentage_off:
          type: string
        redeem_after:
          type: string
        redeem_before:
          type: string
        rules:
          type: object
          additionalProperties: true
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        total_redemptions:
          type: integer
        type:
          $ref: '#/components/schemas/types.CouponType'
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.CreditGrantCadence:
      type: string
      enum:
        - ONETIME
        - RECURRING
      x-enum-varnames:
        - CreditGrantCadenceOneTime
        - CreditGrantCadenceRecurring
      x-speakeasy-name-override: CreditGrantCadence
    types.CreditGrantExpiryDurationUnit:
      type: string
      enum:
        - DAY
        - WEEK
        - MONTH
        - YEAR
      x-enum-varnames:
        - CreditGrantExpiryDurationUnitDays
        - CreditGrantExpiryDurationUnitWeeks
        - CreditGrantExpiryDurationUnitMonths
        - CreditGrantExpiryDurationUnitYears
      x-speakeasy-name-override: CreditGrantExpiryDurationUnit
    types.CreditGrantExpiryType:
      type: string
      enum:
        - NEVER
        - DURATION
        - BILLING_CYCLE
      x-enum-varnames:
        - CreditGrantExpiryTypeNever
        - CreditGrantExpiryTypeDuration
        - CreditGrantExpiryTypeBillingCycle
      x-speakeasy-name-override: CreditGrantExpiryType
    types.CreditGrantPeriod:
      type: string
      enum:
        - DAILY
        - WEEKLY
        - MONTHLY
        - ANNUAL
        - QUARTERLY
        - HALF_YEARLY
      x-enum-varnames:
        - CREDIT_GRANT_PERIOD_DAILY
        - CREDIT_GRANT_PERIOD_WEEKLY
        - CREDIT_GRANT_PERIOD_MONTHLY
        - CREDIT_GRANT_PERIOD_ANNUAL
        - CREDIT_GRANT_PERIOD_QUARTER
        - CREDIT_GRANT_PERIOD_HALF_YEARLY
      x-speakeasy-name-override: CreditGrantPeriod
    types.CreditGrantScope:
      type: string
      enum:
        - PLAN
        - SUBSCRIPTION
      x-enum-varnames:
        - CreditGrantScopePlan
        - CreditGrantScopeSubscription
      x-speakeasy-name-override: CreditGrantScope
    types.CommitmentType:
      type: string
      enum:
        - amount
        - quantity
      x-enum-varnames:
        - COMMITMENT_TYPE_AMOUNT
        - COMMITMENT_TYPE_QUANTITY
      x-speakeasy-name-override: CommitmentType
    types.SubscriptionLineItemEntityType:
      type: string
      enum:
        - plan
        - addon
        - subscription
      x-enum-varnames:
        - SubscriptionLineItemEntityTypePlan
        - SubscriptionLineItemEntityTypeAddon
        - SubscriptionLineItemEntityTypeSubscription
      x-speakeasy-name-override: SubscriptionLineItemEntityType
    types.InvoiceCadence:
      type: string
      enum:
        - ARREAR
        - ADVANCE
      x-enum-varnames:
        - InvoiceCadenceArrear
        - InvoiceCadenceAdvance
      x-speakeasy-name-override: InvoiceCadence
    price.Price:
      type: object
      properties:
        amount:
          type: string
          description: |-
            Amount stored in main currency units (e.g., dollars, not cents)
            For USD: 12.50 means $12.50
        billing_cadence:
          $ref: '#/components/schemas/types.BillingCadence'
        billing_model:
          $ref: '#/components/schemas/types.BillingModel'
        billing_period:
          $ref: '#/components/schemas/types.BillingPeriod'
        billing_period_count:
          type: integer
          description: BillingPeriodCount is the count of the billing period ex 1, 3, 6, 12
        conversion_rate:
          type: string
          description: >-
            ConversionRate is the conversion rate of the price unit to the fiat
            currency
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
          description: Currency 3 digit ISO currency code in lowercase ex usd, eur, gbp
        description:
          type: string
          description: Description of the price
        display_amount:
          type: string
          description: |-
            DisplayAmount is the formatted amount with currency symbol
            For USD: $12.50
        display_name:
          type: string
          description: DisplayName is the name of the price
        display_price_unit_amount:
          type: string
          description: DisplayPriceUnitAmount is the formatted amount of the price unit
        end_date:
          type: string
          description: EndDate is the end date of the price
          format: date-time
        entity_id:
          type: string
          description: EntityID holds the value of the "entity_id" field.
        entity_type:
          $ref: '#/components/schemas/types.PriceEntityType'
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the price
        group_id:
          type: string
          description: GroupID references the group this price belongs to
        id:
          type: string
          description: ID uuid identifier for the price
        invoice_cadence:
          $ref: '#/components/schemas/types.InvoiceCadence'
        lookup_key:
          type: string
          description: LookupKey used for looking up the price in the database
        metadata:
          $ref: '#/components/schemas/price.JSONBMetadata'
        meter_id:
          type: string
          description: MeterID is the id of the meter for usage based pricing
        min_quantity:
          type: string
          description: MinQuantity is the minimum quantity of the price
          nullable: true
        parent_price_id:
          type: string
          description: >-
            ParentPriceID references the root price (always set for price
            lineage tracking)
        price_unit:
          type: string
          description: PriceUnit is the code of the price unit (e.g., 'btc', 'eth')
        price_unit_amount:
          type: string
          description: PriceUnitAmount is the amount of the price unit
        price_unit_id:
          type: string
          description: PriceUnitID is the id of the price unit (for CUSTOM type)
        price_unit_tiers:
          type: array
          description: >-
            PriceUnitTiers are the tiers for the price unit when BillingModel is
            TIERED
          items:
            $ref: '#/components/schemas/price.PriceTier'
        price_unit_type:
          $ref: '#/components/schemas/types.PriceUnitType'
        start_date:
          type: string
          description: StartDate is the start date of the price
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        tier_mode:
          $ref: '#/components/schemas/types.BillingTier'
        tiers:
          type: array
          items:
            $ref: '#/components/schemas/price.PriceTier'
        transform_quantity:
          $ref: '#/components/schemas/price.JSONBTransformQuantity'
        trial_period_days:
          type: integer
          description: >-
            TrialPeriodDays is the number of days for the trial period

            Note: This is only applicable for recurring prices
            (BILLING_CADENCE_RECURRING)
        type:
          $ref: '#/components/schemas/types.PriceType'
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.PriceType:
      type: string
      enum:
        - USAGE
        - FIXED
      x-enum-varnames:
        - PRICE_TYPE_USAGE
        - PRICE_TYPE_FIXED
      x-speakeasy-name-override: PriceType
    types.PauseMode:
      type: string
      enum:
        - immediate
        - scheduled
        - period_end
      x-enum-varnames:
        - PauseModeImmediate
        - PauseModeScheduled
        - PauseModePeriodEnd
      x-speakeasy-name-override: PauseMode
    types.ResumeMode:
      type: string
      enum:
        - immediate
        - scheduled
        - auto
      x-enum-varnames:
        - ResumeModeImmediate
        - ResumeModeScheduled
        - ResumeModeAuto
      x-speakeasy-name-override: ResumeMode
    EntitlementResponse:
      type: object
      properties:
        addon:
          $ref: '#/components/schemas/AddonResponse'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        display_order:
          type: integer
        end_date:
          type: string
          format: date-time
        entity_id:
          type: string
        entity_type:
          $ref: '#/components/schemas/types.EntitlementEntityType'
        environment_id:
          type: string
        feature:
          $ref: '#/components/schemas/FeatureResponse'
        feature_id:
          type: string
        feature_type:
          $ref: '#/components/schemas/types.FeatureType'
        id:
          type: string
        is_enabled:
          type: boolean
        is_soft_limit:
          type: boolean
        parent_entitlement_id:
          type: string
        plan:
          $ref: '#/components/schemas/PlanResponse'
        plan_id:
          type: string
          description: 'TODO: Remove this once we have a proper entitlement entity type'
        start_date:
          type: string
          format: date-time
        static_value:
          type: string
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
        usage_limit:
          type: integer
        usage_reset_period:
          $ref: '#/components/schemas/types.EntitlementUsageResetPeriod'
    PriceResponse:
      type: object
      properties:
        addon:
          $ref: '#/components/schemas/AddonResponse'
        amount:
          type: string
          description: |-
            Amount stored in main currency units (e.g., dollars, not cents)
            For USD: 12.50 means $12.50
        billing_cadence:
          $ref: '#/components/schemas/types.BillingCadence'
        billing_model:
          $ref: '#/components/schemas/types.BillingModel'
        billing_period:
          $ref: '#/components/schemas/types.BillingPeriod'
        billing_period_count:
          type: integer
          description: BillingPeriodCount is the count of the billing period ex 1, 3, 6, 12
        conversion_rate:
          type: string
          description: >-
            ConversionRate is the conversion rate of the price unit to the fiat
            currency
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        currency:
          type: string
          description: Currency 3 digit ISO currency code in lowercase ex usd, eur, gbp
        description:
          type: string
          description: Description of the price
        display_amount:
          type: string
          description: |-
            DisplayAmount is the formatted amount with currency symbol
            For USD: $12.50
        display_name:
          type: string
          description: DisplayName is the name of the price
        display_price_unit_amount:
          type: string
          description: DisplayPriceUnitAmount is the formatted amount of the price unit
        end_date:
          type: string
          description: EndDate is the end date of the price
          format: date-time
        entity_id:
          type: string
          description: EntityID holds the value of the "entity_id" field.
        entity_type:
          $ref: '#/components/schemas/types.PriceEntityType'
        environment_id:
          type: string
          description: EnvironmentID is the environment identifier for the price
        group:
          $ref: '#/components/schemas/GroupResponse'
        group_id:
          type: string
          description: GroupID references the group this price belongs to
        id:
          type: string
          description: ID uuid identifier for the price
        invoice_cadence:
          $ref: '#/components/schemas/types.InvoiceCadence'
        lookup_key:
          type: string
          description: LookupKey used for looking up the price in the database
        metadata:
          $ref: '#/components/schemas/price.JSONBMetadata'
        meter:
          $ref: '#/components/schemas/MeterResponse'
        meter_id:
          type: string
          description: MeterID is the id of the meter for usage based pricing
        min_quantity:
          type: string
          description: MinQuantity is the minimum quantity of the price
          nullable: true
        parent_price_id:
          type: string
          description: >-
            ParentPriceID references the root price (always set for price
            lineage tracking)
        plan:
          $ref: '#/components/schemas/PlanResponse'
        price_unit:
          type: string
          description: PriceUnit is the code of the price unit (e.g., 'btc', 'eth')
        price_unit_amount:
          type: string
          description: PriceUnitAmount is the amount of the price unit
        price_unit_id:
          type: string
          description: PriceUnitID is the id of the price unit (for CUSTOM type)
        price_unit_tiers:
          type: array
          description: >-
            PriceUnitTiers are the tiers for the price unit when BillingModel is
            TIERED
          items:
            $ref: '#/components/schemas/price.PriceTier'
        price_unit_type:
          $ref: '#/components/schemas/types.PriceUnitType'
        pricing_unit:
          $ref: '#/components/schemas/PriceUnitResponse'
        start_date:
          type: string
          description: StartDate is the start date of the price
          format: date-time
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        tier_mode:
          $ref: '#/components/schemas/types.BillingTier'
        tiers:
          type: array
          items:
            $ref: '#/components/schemas/price.PriceTier'
        transform_quantity:
          $ref: '#/components/schemas/price.JSONBTransformQuantity'
        trial_period_days:
          type: integer
          description: >-
            TrialPeriodDays is the number of days for the trial period

            Note: This is only applicable for recurring prices
            (BILLING_CADENCE_RECURRING)
        type:
          $ref: '#/components/schemas/types.PriceType'
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.IntegrationEntityType:
      type: string
      enum:
        - customer
        - plan
        - invoice
        - subscription
        - payment
        - credit_note
        - addon
        - item
        - item_price
        - price
      x-enum-varnames:
        - IntegrationEntityTypeCustomer
        - IntegrationEntityTypePlan
        - IntegrationEntityTypeInvoice
        - IntegrationEntityTypeSubscription
        - IntegrationEntityTypePayment
        - IntegrationEntityTypeCreditNote
        - IntegrationEntityTypeAddon
        - IntegrationEntityTypeItem
        - IntegrationEntityTypeItemPrice
        - IntegrationEntityTypePrice
      x-speakeasy-name-override: IntegrationEntityType
    types.TaxRateScope:
      type: string
      enum:
        - INTERNAL
        - EXTERNAL
        - ONETIME
      x-enum-varnames:
        - TaxRateScopeInternal
        - TaxRateScopeExternal
        - TaxRateScopeOneTime
      x-speakeasy-name-override: TaxRateScope
    types.TaxRateStatus:
      type: string
      enum:
        - ACTIVE
        - INACTIVE
      x-enum-varnames:
        - TaxRateStatusActive
        - TaxRateStatusInactive
      x-speakeasy-name-override: TaxRateStatus
    types.TaxRateType:
      type: string
      enum:
        - percentage
        - fixed
      x-enum-varnames:
        - TaxRateTypePercentage
        - TaxRateTypeFixed
      x-speakeasy-name-override: TaxRateType
    types.CouponCadence:
      type: string
      enum:
        - once
        - repeated
        - forever
      x-enum-varnames:
        - CouponCadenceOnce
        - CouponCadenceRepeated
        - CouponCadenceForever
      x-speakeasy-name-override: CouponCadence
    types.BillingModel:
      type: string
      enum:
        - FLAT_FEE
        - PACKAGE
        - TIERED
      x-enum-varnames:
        - BILLING_MODEL_FLAT_FEE
        - BILLING_MODEL_PACKAGE
        - BILLING_MODEL_TIERED
      x-speakeasy-name-override: BillingModel
    types.PriceEntityType:
      type: string
      enum:
        - PLAN
        - SUBSCRIPTION
        - ADDON
        - PRICE
        - COSTSHEET
      x-enum-varnames:
        - PRICE_ENTITY_TYPE_PLAN
        - PRICE_ENTITY_TYPE_SUBSCRIPTION
        - PRICE_ENTITY_TYPE_ADDON
        - PRICE_ENTITY_TYPE_PRICE
        - PRICE_ENTITY_TYPE_COSTSHEET
      x-speakeasy-name-override: PriceEntityType
    price.JSONBMetadata:
      type: object
      additionalProperties:
        type: string
    price.PriceTier:
      type: object
      properties:
        flat_amount:
          type: string
          description: >-
            flat_amount is the flat amount for the given tier (optional)

            Applied on top of unit_amount*quantity. Useful for cases like "2.7$
            + 5c"
        unit_amount:
          type: string
          description: unit_amount is the amount per unit for the given tier
        up_to:
          type: integer
          description: >-
            up_to is the quantity up to which this tier applies. It is null for
            the last tier.

            IMPORTANT: Tier boundaries are INCLUSIVE.

            - If up_to is 1000, then quantity less than or equal to 1000 belongs
            to this tier

            - This behavior is consistent across both VOLUME and SLAB tier modes
    types.PriceUnitType:
      type: string
      enum:
        - FIAT
        - CUSTOM
      x-enum-varnames:
        - PRICE_UNIT_TYPE_FIAT
        - PRICE_UNIT_TYPE_CUSTOM
      x-speakeasy-name-override: PriceUnitType
    types.BillingTier:
      type: string
      enum:
        - VOLUME
        - SLAB
      x-enum-varnames:
        - BILLING_TIER_VOLUME
        - BILLING_TIER_SLAB
      x-speakeasy-name-override: BillingTier
    price.JSONBTransformQuantity:
      type: object
      properties:
        divide_by:
          type: integer
          description: Divide quantity by this number
        round:
          $ref: '#/components/schemas/types.RoundType'
    AddonResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        description:
          type: string
        entitlements:
          type: array
          items:
            $ref: '#/components/schemas/EntitlementResponse'
        environment_id:
          type: string
        id:
          type: string
        lookup_key:
          type: string
        metadata:
          type: object
          additionalProperties: true
        name:
          type: string
        prices:
          type: array
          description: Optional expanded fields
          items:
            $ref: '#/components/schemas/PriceResponse'
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.EntitlementEntityType:
      type: string
      enum:
        - PLAN
        - SUBSCRIPTION
        - ADDON
      x-enum-varnames:
        - ENTITLEMENT_ENTITY_TYPE_PLAN
        - ENTITLEMENT_ENTITY_TYPE_SUBSCRIPTION
        - ENTITLEMENT_ENTITY_TYPE_ADDON
      x-speakeasy-name-override: EntitlementEntityType
    FeatureResponse:
      type: object
      properties:
        alert_settings:
          $ref: '#/components/schemas/types.AlertSettings'
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        description:
          type: string
        environment_id:
          type: string
        group:
          $ref: '#/components/schemas/GroupResponse'
        group_id:
          type: string
        id:
          type: string
        lookup_key:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        meter:
          $ref: '#/components/schemas/MeterResponse'
        meter_id:
          type: string
        name:
          type: string
        reporting_unit:
          $ref: '#/components/schemas/types.ReportingUnit'
        status:
          $ref: '#/components/schemas/types.Status'
        tenant_id:
          type: string
        type:
          $ref: '#/components/schemas/types.FeatureType'
        unit_plural:
          type: string
        unit_singular:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.FeatureType:
      type: string
      enum:
        - metered
        - boolean
        - static
      x-enum-varnames:
        - FeatureTypeMetered
        - FeatureTypeBoolean
        - FeatureTypeStatic
      x-speakeasy-name-override: FeatureType
    types.EntitlementUsageResetPeriod:
      type: string
      enum:
        - MONTHLY
        - ANNUAL
        - WEEKLY
        - DAILY
        - QUARTERLY
        - HALF_YEARLY
        - NEVER
      x-enum-varnames:
        - ENTITLEMENT_USAGE_RESET_PERIOD_MONTHLY
        - ENTITLEMENT_USAGE_RESET_PERIOD_ANNUAL
        - ENTITLEMENT_USAGE_RESET_PERIOD_WEEKLY
        - ENTITLEMENT_USAGE_RESET_PERIOD_DAILY
        - ENTITLEMENT_USAGE_RESET_PERIOD_QUARTER
        - ENTITLEMENT_USAGE_RESET_PERIOD_HALF_YEAR
        - ENTITLEMENT_USAGE_RESET_PERIOD_NEVER
      x-speakeasy-name-override: EntitlementUsageResetPeriod
    GroupResponse:
      type: object
      properties:
        created_at:
          type: string
          format: date-time
        entity_ids:
          type: array
          items:
            type: string
        entity_type:
          type: string
        id:
          type: string
        lookup_key:
          type: string
        metadata:
          type: object
          additionalProperties:
            type: string
        name:
          type: string
        status:
          type: string
        updated_at:
          type: string
          format: date-time
    MeterResponse:
      type: object
      properties:
        aggregation:
          $ref: '#/components/schemas/meter.Aggregation'
        created_at:
          type: string
          example: '2024-03-20T15:04:05Z'
          format: date-time
        event_name:
          type: string
          example: api_request
        filters:
          type: array
          items:
            $ref: '#/components/schemas/meter.Filter'
        id:
          type: string
          example: 550e8400-e29b-41d4-a716-446655440000
        name:
          type: string
          example: API Usage Meter
        reset_usage:
          $ref: '#/components/schemas/types.ResetUsage'
        status:
          type: string
          example: published
        tenant_id:
          type: string
          example: tenant123
        updated_at:
          type: string
          example: '2024-03-20T15:04:05Z'
          format: date-time
    PriceUnitResponse:
      type: object
      properties:
        base_currency:
          type: string
        code:
          type: string
        conversion_rate:
          type: string
        created_at:
          type: string
          format: date-time
        created_by:
          type: string
        environment_id:
          type: string
        id:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        name:
          type: string
        status:
          $ref: '#/components/schemas/types.Status'
        symbol:
          type: string
        tenant_id:
          type: string
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
    types.RoundType:
      type: string
      enum:
        - up
        - down
      x-enum-varnames:
        - ROUND_UP
        - ROUND_DOWN
      x-speakeasy-name-override: RoundType
    types.AlertSettings:
      type: object
      properties:
        alert_enabled:
          type: boolean
        critical:
          $ref: '#/components/schemas/types.AlertThreshold'
        info:
          $ref: '#/components/schemas/types.AlertThreshold'
        warning:
          $ref: '#/components/schemas/types.AlertThreshold'
      x-speakeasy-name-override: AlertSettings
    types.ReportingUnit:
      type: object
      properties:
        conversion_rate:
          type: number
          description: >-
            Multiplier: reporting_unit_value = unit_value * conversion_rate;
            must be > 0
        unit_plural:
          type: string
          description: Display unit label, plural (e.g. "seconds")
        unit_singular:
          type: string
          description: Display unit label, singular (e.g. "second")
      x-speakeasy-name-override: ReportingUnit
    meter.Aggregation:
      type: object
      properties:
        bucket_size:
          $ref: '#/components/schemas/types.WindowSize'
        expression:
          type: string
          description: >-
            Expression is an optional CEL expression to compute per-event
            quantity from event.properties.

            When set, it replaces Field-based extraction. Property names are
            used directly (e.g., token * duration * pixel).
        field:
          type: string
          description: >-
            Field is the key in $event.properties on which the aggregation is to
            be applied

            For ex if the aggregation type is sum for API usage, the field could
            be "duration_ms"

            Ignored when Expression is set.
        group_by:
          type: string
          description: >-
            GroupBy is the property name in event.properties to group by before
            aggregating.

            Currently only supported for MAX aggregation with bucket_size.

            When set, aggregation is applied per unique value of this property
            within each bucket,

            then the per-group results are summed to produce the bucket total.
        multiplier:
          type: string
          description: >-
            Multiplier is the multiplier for the aggregation

            For ex if the aggregation type is sum_with_multiplier for API usage,
            the multiplier could be 1000

            to scale up by a factor of 1000. If not provided, it will be null.
        type:
          $ref: '#/components/schemas/types.AggregationType'
    meter.Filter:
      type: object
      properties:
        key:
          type: string
          description: >-
            Key is the key for the filter from $event.properties

            Currently we support only first level keys in the properties and not
            nested keys
        values:
          type: array
          description: >-
            Values are the possible values for the filter to be considered for
            the meter

            For ex "model_name" could have values "o1-mini", "gpt-4o" etc
          items:
            type: string
    types.ResetUsage:
      type: string
      enum:
        - BILLING_PERIOD
        - NEVER
      x-enum-varnames:
        - ResetUsageBillingPeriod
        - ResetUsageNever
      x-speakeasy-name-override: ResetUsage
    types.AlertThreshold:
      type: object
      properties:
        condition:
          $ref: '#/components/schemas/types.AlertCondition'
        threshold:
          type: number
      x-speakeasy-name-override: AlertThreshold
    types.WindowSize:
      type: string
      enum:
        - MINUTE
        - 15MIN
        - 30MIN
        - HOUR
        - 3HOUR
        - 6HOUR
        - 12HOUR
        - DAY
        - WEEK
        - MONTH
        - MONTH
      x-enum-varnames:
        - WindowSizeMinute
        - WindowSize15Min
        - WindowSize30Min
        - WindowSizeHour
        - WindowSize3Hour
        - WindowSize6Hour
        - WindowSize12Hour
        - WindowSizeDay
        - WindowSizeWeek
        - WindowSizeMonth
        - DefaultWindowSize
      x-speakeasy-name-override: WindowSize
    types.AggregationType:
      type: string
      enum:
        - COUNT
        - SUM
        - AVG
        - COUNT_UNIQUE
        - LATEST
        - SUM_WITH_MULTIPLIER
        - MAX
        - WEIGHTED_SUM
      x-enum-comments:
        AggregationSumWithMultiplier: Sum with a multiplier - [sum(value) * multiplier]
      x-enum-varnames:
        - AggregationCount
        - AggregationSum
        - AggregationAvg
        - AggregationCountUnique
        - AggregationLatest
        - AggregationSumWithMultiplier
        - AggregationMax
        - AggregationWeightedSum
      x-speakeasy-name-override: AggregationType
    types.AlertCondition:
      type: string
      enum:
        - above
        - below
      x-enum-varnames:
        - AlertConditionAbove
        - AlertConditionBelow
      x-speakeasy-name-override: AlertCondition
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````