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

# Retrieve current usage

> Returns usage across the open billing windows of the active or pending contract.

> [!NOTE]
>
> API v2 is in beta. Endpoints return the `X-Lago-Endpoint-Status: beta` header.


## OpenAPI

````yaml https://swagger.getlago.com/openapi-v2.yaml GET /contracts/{external_id}/current_usage
openapi: 3.1.0
info:
  title: Lago API v2 documentation
  description: >-
    Lago API v2. Documents native v2 endpoints for the product catalog, billing,
    customers, organizations, billing entities, billable metrics, events,
    features, privileges, entitlements, wallets, alerts, logs and webhook
    endpoints. Paginated lists use cursor pagination. Some lists, such as rates
    and phases, return the complete list without pagination. Native v2 endpoints
    use opt-in relationship expansions and structured error responses. Only the
    documented actions and expansions are supported. Some other /api/v2 paths
    still fall back to v1 controllers and are not described here.
  version: 2.0.0-beta
  license:
    name: AGPLv3
    url: https://github.com/getlago/lago-openapi/blob/main/LICENSE
  contact:
    email: tech@getlago.com
servers:
  - url: https://api.getlago.com/api/v2
    description: US Lago cluster
  - url: https://api.eu.getlago.com/api/v2
    description: EU Lago cluster
security:
  - bearerAuth: []
tags:
  - name: taxes
    description: Tax rates
  - name: product_categories
    description: product categories operations
  - name: products
    description: products operations
  - name: product_filters
    description: product filters operations
  - name: rate_cards
    description: rate cards operations
  - name: rate_card_rates
    description: rate card rates operations
  - name: catalog_plans
    description: catalog plans operations
  - name: plan_applied_rate_cards
    description: plan applied rate cards operations
  - name: plan_rate_phases
    description: plan rate phases operations
  - name: contract_applied_rate_cards
    description: contract applied rate cards operations
  - name: contract_rate_phases
    description: contract rate phases operations
  - name: contracts
    description: contracts operations
  - name: invoices
    description: invoices operations
  - name: fees
    description: fees operations
  - name: payments
    description: payments operations
  - name: payment_requests
    description: payment requests operations
  - name: payment_receipts
    description: payment receipts operations
  - name: credit_notes
    description: credit notes operations
  - name: customers
    description: customers operations
  - name: organizations
    description: Organization operations
  - name: billing_entities
    description: billing entities operations
  - name: billable_metrics
    description: billable metrics operations
  - name: events
    description: Event operations
  - name: activity_logs
    description: activity logs operations
  - name: api_logs
    description: api logs operations
  - name: security_logs
    description: security logs operations
  - name: webhook_endpoints
    description: webhook endpoints operations
  - name: features
    description: features operations
  - name: feature_privileges
    description: feature privileges operations
  - name: plan_wallets
    description: plan wallets operations
  - name: contract_wallets
    description: contract wallets operations
  - name: contract_wallet_transactions
    description: contract wallet transactions operations
  - name: plan_wallet_alerts
    description: plan wallet alerts operations
  - name: contract_wallet_alerts
    description: contract wallet alerts operations
  - name: contract_alerts
    description: contract alerts operations
  - name: plan_entitlements
    description: plan entitlements operations
  - name: contract_entitlements
    description: contract entitlements operations
externalDocs:
  description: Lago documentation
  url: https://getlago.com/docs
paths:
  /contracts/{external_id}/current_usage:
    parameters:
      - name: external_id
        in: path
        required: true
        description: External id.
        schema:
          type: string
          description: External id.
          example: external_123
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contracts
      summary: Retrieve contract current usage
      description: >-
        Returns usage across the open billing windows of the active or pending
        contract. Pending contracts have no usage. Totals may span multiple
        invoices.

        Requires the product catalog to be enabled and customer_usage read
        permission on the API key.
      operationId: findContractCurrentUsage
      parameters:
        - name: apply_taxes
          in: query
          required: false
          description: Apply taxes.
          schema:
            type: boolean
            description: Whether to include tax calculation.
            example: true
            default: true
        - name: rate_card_code
          in: query
          required: false
          description: Rate card code.
          schema:
            type: string
            description: Exact code.
            example: example_code
        - name: product_code
          in: query
          required: false
          description: Product code.
          schema:
            type: string
            description: Exact code.
            example: example_code
        - name: product_filter_code
          in: query
          required: false
          description: Product filter code.
          schema:
            type: string
            description: Exact code.
            example: example_code
        - name: product_type
          in: query
          required: false
          description: Product type.
          schema:
            type: string
            description: >-
              Type of product. Metered products require a billable metric; fixed
              products must not reference one.
            example: metered
            enum:
              - metered
              - fixed
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractUsage'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  parameters:
    contract_code:
      name: contract_code
      in: query
      required: false
      description: >-
        Code of the contract to select. Required when multiple contracts share
        the external ID, including canceled and terminated contracts. Otherwise,
        it can be omitted. Omitting it when the external ID is ambiguous returns
        422 value_is_mandatory on contract_code; a blank value returns 422
        value_is_invalid.
      schema:
        type: string
        minLength: 1
        description: Exact contract code.
        example: initial
  headers:
    EndpointStatus:
      description: Indicates that the endpoint is in beta.
      schema:
        type: string
        enum:
          - beta
        example: beta
  schemas:
    ContractUsage:
      type: object
      description: current usage response.
      required:
        - current_usage
      properties:
        current_usage:
          $ref: '#/components/schemas/ContractUsageObject'
    ContractUsageObject:
      type: object
      description: >-
        Current usage across the contract open billing windows. This is not a
        preview of one invoice.
      required:
        - external_contract_id
        - external_customer_id
        - currency
        - amount_cents
        - taxes_amount_cents
        - total_amount_cents
        - rate_cards
      properties:
        external_contract_id:
          type: string
          description: External contract identifier.
          example: contract_123
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        currency:
          type: string
          description: Billing currency.
          example: USD
        amount_cents:
          type: integer
          description: Amount excluding tax, in cents.
          example: 1000
        taxes_amount_cents:
          type: integer
          description: Tax amount, in cents.
          example: 200
        total_amount_cents:
          type: integer
          description: Amount including tax, in cents.
          example: 1200
        rate_cards:
          type: array
          description: Usage by applied rate card.
          items:
            $ref: '#/components/schemas/RateCardUsageObject'
    ApiError:
      type: object
      required:
        - code
        - details
      properties:
        code:
          type: string
          pattern: ^[a-z][a-z0-9_]*$
          description: >-
            Code identifying the failure. The HTTP status is carried by the
            response, not the body.
          example: validation_errors
        details:
          type: array
          description: >-
            Details of the failure. The array is empty when no field details are
            available.
          items:
            type: object
            required:
              - code
              - field
              - meta
            properties:
              code:
                type: string
                pattern: ^[a-z][a-z0-9_]*$
                description: >-
                  Code identifying the field error or the reason a request
                  parameter was rejected.
                example: value_is_mandatory
              field:
                type: string
                description: >-
                  Request field or parameter. Nested fields use dots and
                  zero-based array indexes. A resource-level failure uses base.
                example: name
              meta:
                type: object
                description: >-
                  Information about the failure, such as the missing resource,
                  allowed values or bounds. The object is empty when no metadata
                  is available.
                additionalProperties: true
                example: {}
                properties:
                  min:
                    type: integer
                    description: Inclusive minimum value.
                    example: 0
                  max:
                    type: integer
                    description: Inclusive maximum value.
                    example: 100
                  min_length:
                    type: integer
                    description: Minimum string length, in characters.
                    example: 1
                  max_length:
                    type: integer
                    description: Maximum string length, in characters.
                    example: 255
                  max_items:
                    type: integer
                    description: Maximum number of items.
                    example: 100
                  allowed_values:
                    type: array
                    description: Values accepted for the field.
                    items:
                      type: string
                      description: Allowed value.
                      example: draft
                  invalid_values:
                    type: array
                    description: Values rejected by request validation.
                    items:
                      type: string
                      description: Rejected value.
                      example: unknown
                  value:
                    type: string
                    description: Query parameter value received.
                    example: unknown
                  resource:
                    type: string
                    description: Resource that could not be found.
                    example: customer
                  provider_name:
                    type: string
                    description: Name of the provider that failed.
                    example: stripe
                  provider_code:
                    type: string
                    description: Code of the provider connection.
                    example: stripe_eu
                  provider_error_code:
                    type: string
                    description: Error code returned by the provider.
                    example: resource_missing
    RateCardUsageObject:
      type: object
      description: Usage in one applied rate card billing window.
      required:
        - rate_card_code
        - rate_card_name
        - product_code
        - product_name
        - product_category_code
        - product_category_name
        - product_filter_code
        - product_filter_name
        - invoice_display_name
        - product_type
        - billable_metric_code
        - billing_timing
        - rate_phase_code
        - rate_phase_name
        - rate_source
        - units
        - events_count
        - amount_cents
        - from_datetime
        - to_datetime
        - segments
      properties:
        rate_card_code:
          type: string
          description: Rate card code.
          example: compute_usd
        rate_card_name:
          type: string
          description: Rate card name.
          example: Compute USD
        product_code:
          type: string
          description: Product code.
          example: api_requests
        product_name:
          type: string
          description: Product name.
          example: API requests
        product_category_code:
          type:
            - string
            - 'null'
          description: Category code.
          example: compute
        product_category_name:
          type:
            - string
            - 'null'
          description: Category name.
          example: Compute
        product_filter_code:
          type:
            - string
            - 'null'
          description: Filter code.
          example: eu
        product_filter_name:
          type:
            - string
            - 'null'
          description: Filter name.
          example: EU
        invoice_display_name:
          type: string
          description: Name displayed on invoices.
          example: API requests
        product_type:
          type: string
          description: >-
            Type of product. Metered products require a billable metric; fixed
            products must not reference one.
          example: metered
          enum:
            - metered
            - fixed
        billable_metric_code:
          type:
            - string
            - 'null'
          description: Billable metric code.
          example: api_requests
        billing_timing:
          type: string
          description: Billing timing.
          example: arrears
          enum:
            - arrears
            - advance
        rate_phase_code:
          type:
            - string
            - 'null'
          description: Rate phase code.
          example: default
        rate_phase_name:
          type:
            - string
            - 'null'
          description: Rate phase name.
          example: Default
        rate_source:
          type: string
          description: Source of the price used for this window.
          example: rate
          enum:
            - rate
            - phase_override
        units:
          type: string
          description: Quantity billed. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        events_count:
          type: integer
          description: Number of matching events.
          example: 42
        amount_cents:
          type: integer
          description: Amount excluding tax, in cents.
          example: 1000
        from_datetime:
          type: string
          description: Start of the billing window.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        to_datetime:
          type: string
          description: End of the billing window.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        segments:
          type: array
          description: Pricing segments contributing to the totals for this billing window.
          items:
            $ref: '#/components/schemas/RateCardUsageSegmentObject'
    RateCardUsageSegmentObject:
      type: object
      description: >-
        Usage and pricing for one segment of an applied rate card billing
        window.
      required:
        - rate_model
        - rate_properties
        - units
        - events_count
        - amount_cents
        - from_datetime
        - to_datetime
      properties:
        rate_model:
          type: string
          description: >-
            Pricing model. Fixed products support standard, graduated and
            volume. Volume cannot be billed in advance; dynamic requires a sum
            metric. Proration and aggregation can impose further restrictions.
          example: standard
          enum:
            - standard
            - graduated
            - package
            - percentage
            - volume
            - graduated_percentage
            - custom
            - dynamic
        rate_properties:
          type: object
          description: Effective pricing properties used by billing.
          additionalProperties: true
        units:
          type: string
          description: Quantity billed. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        events_count:
          type: integer
          description: Number of matching events.
          example: 42
        amount_cents:
          type: integer
          description: Amount excluding tax, in cents.
          example: 1000
        from_datetime:
          type: string
          description: Start of this segment within the billing window.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        to_datetime:
          type: string
          description: End of this segment within the billing window.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
  responses:
    BadRequest:
      description: Invalid request body, pagination or relationship expansion
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            code: invalid_expand
            details:
              - code: malformed
                field: expands
                meta:
                  allowed_values: []
    Unauthorized:
      description: Missing or invalid API key
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            code: unauthorized
            details: []
    Forbidden:
      description: Feature unavailable or insufficient API permissions
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            code: feature_unavailable
            details: []
    NotFound:
      description: Unknown resource or resource from another organization
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            code: resource_not_found
            details:
              - code: resource_not_found
                field: base
                meta:
                  resource: resource_name
    UnprocessableEntity:
      description: Invalid fields or filters
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.