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:
  /taxes:
    get:
      tags:
        - taxes
      summary: List all taxes
      description: |-
        Lists the organization's taxes, excluding deleted taxes.
        Requires the product catalog to be enabled and tax read permission on the API key.
        Results are ordered by creation time, newest first, with the tax identifier as a tiebreaker.
        Use after or before to navigate. The page and per_page parameters return 400.
        Relationships and assignment counts are not returned. Taxes have no supported expansions; a nonempty expands[] returns 400.
        Invalid date filters return 422.
      operationId: findAllTaxes
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Taxes
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaxesPaginated'
              example:
                taxes:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    name: VAT
                    code: standard_vat
                    rate: 20
                    description: Standard VAT
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T09:30:00.123456Z'
                    deleted_at: null
                meta:
                  next_cursor: null
                  prev_cursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - taxes
      summary: Create a tax
      description: |-
        Creates a tax rate for the organization.
        Requires the product catalog to be enabled and tax write permission on the API key.
        Name, code and rate are required. A code already used by another tax of the organization, including a deleted one, returns 422.
        The applied_to_organization parameter is ignored and is not returned. Creating a tax does not assign it to any resource.
        Taxes have no supported expansions; a nonempty expands[] returns 400 before creation.
      operationId: createTax
      requestBody:
        required: true
        description: Tax creation payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaxCreateInput'
            example:
              tax:
                name: VAT
                code: standard_vat
                rate: 20
                description: Standard VAT
      responses:
        '200':
          description: Tax created
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tax'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /taxes/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code of the tax within the organization.
        schema:
          type: string
          example: standard_vat
    get:
      tags:
        - taxes
      summary: Retrieve a tax
      description: |-
        Retrieves a non-deleted tax by its code.
        Requires the product catalog to be enabled and tax read permission on the API key.
        Unknown taxes and taxes belonging to another organization return 404.
        Assignments and relationship counts are not returned. Taxes have no supported expansions; a nonempty expands[] returns 400.
      operationId: findTax
      responses:
        '200':
          description: Tax
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tax'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - taxes
      summary: Update a tax
      description: |-
        Updates a non-deleted tax identified by the code in the path.
        Requires the product catalog to be enabled and tax write permission on the API key.
        Both PUT and PATCH accept partial updates. Omitted fields keep their current values.
        The tax wrapper must be nonempty. The code field can rename the tax if no other tax of the organization, including a deleted one, uses the new code.
        The applied_to_organization parameter is ignored and existing assignments are not changed by this parameter.
        Taxes have no supported expansions; a nonempty expands[] returns 400 before updating the tax.
      operationId: updateTax
      requestBody:
        required: true
        description: Tax update payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaxUpdateInput'
            example:
              tax:
                rate: '5.5'
                description: Reduced VAT
      responses:
        '200':
          description: Tax updated
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tax'
        '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'
    patch:
      tags:
        - taxes
      summary: Partially update a tax
      description: |-
        Updates only the supplied fields of a non-deleted tax identified by its code.
        Requires the product catalog to be enabled and tax write permission on the API key.
        Behaves the same as PUT. The tax wrapper must be nonempty, and omitted fields keep their current values.
        The applied_to_organization parameter is ignored and existing assignments are not changed by this parameter.
        Taxes have no supported expansions; a nonempty expands[] returns 400 before updating the tax.
      operationId: patchTax
      x-lago-cli-action: patch
      requestBody:
        required: true
        description: Tax update payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaxUpdateInput'
            example:
              tax:
                name: Reduced VAT
      responses:
        '200':
          description: Tax updated
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tax'
        '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'
    delete:
      tags:
        - taxes
      summary: Delete a tax
      description: |-
        Deletes a tax identified by its code and returns it with a non-null deleted_at timestamp.
        Requires the product catalog to be enabled and tax write permission on the API key.
        Deleted taxes are no longer returned by listing or retrieval. An unknown or already deleted tax returns 404.
        Taxes have no supported expansions; a nonempty expands[] returns 400 before deletion.
      operationId: destroyTax
      responses:
        '200':
          description: Tax deleted
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tax'
              example:
                tax:
                  lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                  name: VAT
                  code: standard_vat
                  rate: 20
                  description: Standard VAT
                  created_at: '2022-04-29T08:59:51.123456Z'
                  updated_at: '2022-04-30T10:00:00.123456Z'
                  deleted_at: '2022-04-30T10:00:00.123456Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /product_categories:
    get:
      tags:
        - product_categories
      summary: List product categories
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and product_category read permission on the API key.
      operationId: findAllProductCategories
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches names and codes.
          schema:
            type: string
            description: Text to search.
            example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategoriesPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - product_categories
      summary: Create product category
      description: Requires the product catalog to be enabled and product_category write permission on the API key.
      operationId: createProductCategory
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCategoryCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategory'
        '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'
  /product_categories/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - product_categories
      summary: Retrieve product category
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and product_category read permission on the API key.
      operationId: findProductCategory
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategory'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - product_categories
      summary: Update product category
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.

        Requires the product catalog to be enabled and product_category write permission on the API key.
      operationId: updateProductCategory
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCategoryUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategory'
        '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'
    patch:
      tags:
        - product_categories
      summary: Update product category
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.

        Requires the product catalog to be enabled and product_category write permission on the API key.
      operationId: patchProductCategory
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCategoryUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategory'
        '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'
    delete:
      tags:
        - product_categories
      summary: Delete product category
      description: |-
        Deletes the category and its products, filters, rate cards and rates. A category attached to a plan or subscription cannot be deleted.
        Requires the product catalog to be enabled and product_category write permission on the API key.
      operationId: destroyProductCategory
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductCategory'
        '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'
  /products:
    get:
      tags:
        - products
      summary: List products
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and product read permission on the API key.
      operationId: findAllProducts
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches names and codes.
          schema:
            type: string
            description: Text to search.
            example: example
        - name: product_category_code[]
          in: query
          required: false
          description: Filter by category codes. A scalar product_category_code is also accepted. Unknown categories return 404.
          schema:
            type: array
            description: Category codes.
            items:
              type: string
              description: Category code.
              example: compute
        - name: without_product_category
          in: query
          required: false
          description: Include uncategorized products, alone or alongside the requested categories.
          schema:
            type: boolean
            description: Include uncategorized products.
            example: false
        - 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/ProductsPaginated'
        '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'
    post:
      tags:
        - products
      summary: Create product
      description: |-
        Creates a fixed or metered product. Metered products require billable_metric_code; fixed products reject it.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: createProduct
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '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'
  /products/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - products
      summary: Retrieve product
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and product read permission on the API key.
      operationId: findProduct
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - product_category
                - billable_metric
              example: product_category
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - products
      summary: Update product
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Product type and billable metric cannot be changed through this endpoint. A blank product_category_code detaches the category.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: updateProduct
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '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'
    patch:
      tags:
        - products
      summary: Update product
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Product type and billable metric cannot be changed through this endpoint. A blank product_category_code detaches the category.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: patchProduct
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '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'
    delete:
      tags:
        - products
      summary: Delete product
      description: |-
        Deletes the product, its filters, rate cards and rates. Products attached to a plan or subscription cannot be deleted.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: destroyProduct
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
        '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'
  /products/{product_code}/filters:
    parameters:
      - name: product_code
        in: path
        required: true
        description: Product code.
        schema:
          type: string
          description: Product code.
          example: example_code
    get:
      tags:
        - product_filters
      summary: List product filters
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and product read permission on the API key.
      operationId: findAllProductFilters
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches names and codes.
          schema:
            type: string
            description: Text to search.
            example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFiltersPaginated'
        '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'
    post:
      tags:
        - product_filters
      summary: Create filter
      description: |-
        Creates a filter for a metered product only. Values must refer to keys and configured values of its billable metric. A key-only entry cannot be combined with specific values for the same key.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: createProductFilter
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductFilterCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFilter'
        '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'
  /products/{product_code}/filters/{code}:
    parameters:
      - name: product_code
        in: path
        required: true
        description: Product code.
        schema:
          type: string
          description: Product code.
          example: example_code
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - product_filters
      summary: Retrieve filter
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and product read permission on the API key.
      operationId: findProductFilter
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFilter'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - product_filters
      summary: Update filter
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. The code cannot change while the product is used by a plan or contract. Values cannot change while a contract has a rate card scoped to this filter.
        Supplying values replaces the existing value set. Omitting values preserves it.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: updateProductFilter
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductFilterUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFilter'
        '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'
    patch:
      tags:
        - product_filters
      summary: Update filter
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. The code cannot change while the product is used by a plan or contract. Values cannot change while a contract has a rate card scoped to this filter.
        Supplying values replaces the existing value set. Omitting values preserves it.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: patchProductFilter
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductFilterUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFilter'
        '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'
    delete:
      tags:
        - product_filters
      summary: Delete filter
      description: |-
        Soft-deletes the filter, its values, its scoped rate cards and their rates. Deletion is rejected while the product is used by a plan or contract.
        Requires the product catalog to be enabled and product write permission on the API key.
      operationId: destroyProductFilter
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductFilter'
        '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'
  /rate_cards:
    get:
      tags:
        - rate_cards
      summary: List rate cards
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and rate_card read permission on the API key.
      operationId: findAllRateCards
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches names and codes.
          schema:
            type: string
            description: Text to search.
            example: example
        - name: product_id[]
          in: query
          required: false
          description: Filter by matching resource identifiers.
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
        - name: product_filter_id[]
          in: query
          required: false
          description: Filter by matching resource identifiers.
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
        - name: code
          in: query
          required: false
          description: 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
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - rate_cards
      summary: Create rate card
      description: Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: createRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCard'
        '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'
  /rate_cards/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - rate_cards
      summary: Retrieve rate card
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and rate_card read permission on the API key.
      operationId: findRateCard
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - active_rate
                - taxes
                - rates
                - product
                - product_filter
              example: active_rate
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCard'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - rate_cards
      summary: Update rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Product and product filter are fixed at creation. Once any rate exists, currency, applied_pricing_unit_code, billing_timing, proration, regroup_paid_fees and display_on_invoice cannot change. Code and currency also cannot change while the card is attached to a plan or contract. Tax assignments remain editable.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: updateRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCard'
        '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'
    patch:
      tags:
        - rate_cards
      summary: Update rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Product and product filter are fixed at creation. Once any rate exists, currency, applied_pricing_unit_code, billing_timing, proration, regroup_paid_fees and display_on_invoice cannot change. Code and currency also cannot change while the card is attached to a plan or contract. Tax assignments remain editable.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: patchRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCard'
        '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'
    delete:
      tags:
        - rate_cards
      summary: Delete rate card
      description: |-
        Deletes an unused rate card and its rates. Cards attached to plans or subscriptions cannot be deleted.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: destroyRateCard
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCard'
        '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'
  /rate_cards/{rate_card_code}/rates:
    parameters:
      - name: rate_card_code
        in: path
        required: true
        description: Rate card code.
        schema:
          type: string
          description: Rate card code.
          example: example_code
    get:
      tags:
        - rate_card_rates
      summary: List rate card rates
      description: |-
        Returns the complete list without cursor metadata.
        Rates are ordered by effective_from, newest first. Offset pagination parameters are rejected.
        Requires the product catalog to be enabled and rate_card read permission on the API key.
      operationId: findAllRateCardRates
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRatesCollection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
        - rate_card_rates
      summary: Create rate
      description: |-
        Adds a rate after the currently active rate, with a unique effective timestamp. Amount and range fields must match rate_model.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: createRateCardRate
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardRateCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRate'
        '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'
  /rate_cards/{rate_card_code}/rates/{code}:
    parameters:
      - name: rate_card_code
        in: path
        required: true
        description: Rate card code.
        schema:
          type: string
          description: Rate card code.
          example: example_code
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - rate_card_rates
      summary: Retrieve rate
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and rate_card read permission on the API key.
      operationId: findRateCardRate
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRate'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - rate_card_rates
      summary: Update rate
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Terminated rates are frozen. Active rates reject effective_from, rate_model, min_amount_cents and billing interval fields, even when unchanged. Pending rates are fully editable; attachment and identity restrictions also apply.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: updateRateCardRate
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardRateUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRate'
        '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'
    patch:
      tags:
        - rate_card_rates
      summary: Update rate
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Terminated rates are frozen. Active rates reject effective_from, rate_model, min_amount_cents and billing interval fields, even when unchanged. Pending rates are fully editable; attachment and identity restrictions also apply.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: patchRateCardRate
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RateCardRateUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRate'
        '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'
    delete:
      tags:
        - rate_card_rates
      summary: Delete rate
      description: |-
        Only pending rates can be deleted. Active and terminated rates remain for history.
        Requires the product catalog to be enabled and rate_card write permission on the API key.
      operationId: destroyRateCardRate
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateCardRate'
        '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'
  /plans:
    get:
      tags:
        - catalog_plans
      summary: List catalog plans
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and plan read permission on the API key.
      operationId: findAllCatalogPlans
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches names and codes.
          schema:
            type: string
            description: Text to search.
            example: example
        - name: product_id[]
          in: query
          required: false
          description: Product id[].
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
        - name: product_filter_id[]
          in: query
          required: false
          description: Product filter id[].
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
        - name: product_category_id[]
          in: query
          required: false
          description: Product category id[].
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
        - name: rate_card_id[]
          in: query
          required: false
          description: Rate card id[].
          schema:
            type: array
            description: Resource identifiers.
            items:
              type: string
              description: Resource identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogPlansPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - catalog_plans
      summary: Create plan
      description: Requires the product catalog to be enabled and plan write permission on the API key.
      operationId: createCatalogPlan
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogPlanCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogPlan'
        '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'
  /plans/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - catalog_plans
      summary: Retrieve plan
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and plan read permission on the API key.
      operationId: findCatalogPlan
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - taxes
              example: taxes
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogPlan'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - catalog_plans
      summary: Update plan
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Tax codes can be changed after a plan is in use. Other fields are subject to plan locking rules.
        Requires the product catalog to be enabled and plan write permission on the API key.
      operationId: updateCatalogPlan
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogPlanUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogPlan'
        '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'
    patch:
      tags:
        - catalog_plans
      summary: Update plan
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Tax codes can be changed after a plan is in use. Other fields are subject to plan locking rules.
        Requires the product catalog to be enabled and plan write permission on the API key.
      operationId: patchCatalogPlan
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogPlanUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogPlan'
        '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'
  /plans/{plan_code}/applied_rate_cards:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Plan code.
        schema:
          type: string
          description: Plan code.
          example: example_code
    get:
      tags:
        - plan_applied_rate_cards
      summary: List plan applied rate cards
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and plan_rate_card read permission on the API key.
      operationId: findAllPlanAppliedRateCards
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCardsPaginated'
        '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'
    post:
      tags:
        - plan_applied_rate_cards
      summary: Create applied rate card
      description: |-
        Attaches a rate card in the same currency. Only one rate card may price each product/filter combination. Plans attached to contracts are locked.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: createPlanAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanAppliedRateCardCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCard'
        '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'
  /plans/{plan_code}/applied_rate_cards/{code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Plan code.
        schema:
          type: string
          description: Plan code.
          example: example_code
      - name: code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
    get:
      tags:
        - plan_applied_rate_cards
      summary: Retrieve applied rate card
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and plan_rate_card read permission on the API key.
      operationId: findPlanAppliedRateCard
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCard'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - plan_applied_rate_cards
      summary: Update applied rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Plans attached to contracts are locked.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: updatePlanAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanAppliedRateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCard'
        '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'
    patch:
      tags:
        - plan_applied_rate_cards
      summary: Update applied rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Plans attached to contracts are locked.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: patchPlanAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanAppliedRateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCard'
        '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'
    delete:
      tags:
        - plan_applied_rate_cards
      summary: Delete applied rate card
      description: |-
        Removes the rate card from an editable plan.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: destroyPlanAppliedRateCard
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanAppliedRateCard'
        '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'
  /plans/{plan_code}/applied_rate_cards/{applied_rate_card_code}/rate_phases:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Plan code.
        schema:
          type: string
          description: Plan code.
          example: example_code
      - name: applied_rate_card_code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
    get:
      tags:
        - plan_rate_phases
      summary: List plan rate phases
      description: |-
        Returns the complete list without cursor metadata.
        Phases are returned in position order.
        Requires the product catalog to be enabled and plan_rate_card read permission on the API key.
      operationId: findAllPlanRatePhases
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanRatePhasesCollection'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
        - plan_rate_phases
      summary: Create rate phase
      description: |-
        Inserts a phase and renumbers later positions. The last phase must be indefinite and no earlier phase may be indefinite. Parent locking rules apply.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: createPlanRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanRatePhase'
        '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'
  /plans/{plan_code}/applied_rate_cards/{applied_rate_card_code}/rate_phases/{code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Plan code.
        schema:
          type: string
          description: Plan code.
          example: example_code
      - name: applied_rate_card_code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    put:
      tags:
        - plan_rate_phases
      summary: Update rate phase
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        A null rate_override removes the override. Structural rate card fields are not overridable. Parent locking rules apply.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: updatePlanRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanRatePhase'
        '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'
    patch:
      tags:
        - plan_rate_phases
      summary: Update rate phase
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        A null rate_override removes the override. Structural rate card fields are not overridable. Parent locking rules apply.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: patchPlanRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanRatePhase'
        '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'
    delete:
      tags:
        - plan_rate_phases
      summary: Delete rate phase
      description: |-
        Removes the phase and renumbers later positions. The final indefinite phase and the only remaining phase cannot be deleted.
        Requires the product catalog to be enabled and plan_rate_card write permission on the API key.
      operationId: destroyPlanRatePhase
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanRatePhase'
        '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'
  /contracts/{contract_external_id}/applied_rate_cards:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: Contract external id.
        schema:
          type: string
          description: Contract external id.
          example: external_123
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contract_applied_rate_cards
      summary: List contract applied rate cards
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and contract_rate_card read permission on the API key.
      operationId: findAllContractAppliedRateCards
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCardsPaginated'
        '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'
    post:
      tags:
        - contract_applied_rate_cards
      summary: Create applied rate card
      description: |-
        Attaches a rate card in the same currency. Only one rate card may price each product/filter combination. Only pending contracts can be edited.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: createContractAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAppliedRateCardCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCard'
        '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'
  /contracts/{contract_external_id}/applied_rate_cards/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: Contract external id.
        schema:
          type: string
          description: Contract external id.
          example: external_123
      - name: code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contract_applied_rate_cards
      summary: Retrieve applied rate card
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and contract_rate_card read permission on the API key.
      operationId: findContractAppliedRateCard
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCard'
        '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'
    put:
      tags:
        - contract_applied_rate_cards
      summary: Update applied rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only pending contracts can be edited.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: updateContractAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAppliedRateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCard'
        '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'
    patch:
      tags:
        - contract_applied_rate_cards
      summary: Update applied rate card
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only pending contracts can be edited.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: patchContractAppliedRateCard
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAppliedRateCardUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCard'
        '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'
    delete:
      tags:
        - contract_applied_rate_cards
      summary: Delete applied rate card
      description: |-
        Removes the rate card from a pending contract.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: destroyContractAppliedRateCard
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAppliedRateCard'
        '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'
  /contracts/{contract_external_id}/applied_rate_cards/{applied_rate_card_code}/rate_phases:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: Contract external id.
        schema:
          type: string
          description: Contract external id.
          example: external_123
      - name: applied_rate_card_code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contract_rate_phases
      summary: List contract rate phases
      description: |-
        Returns the complete list without cursor metadata.
        Phases are returned in position order.
        Requires the product catalog to be enabled and contract_rate_card read permission on the API key.
      operationId: findAllContractRatePhases
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractRatePhasesCollection'
        '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'
    post:
      tags:
        - contract_rate_phases
      summary: Create rate phase
      description: |-
        Inserts a phase and renumbers later positions. The last phase must be indefinite and no earlier phase may be indefinite. Parent locking rules apply.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: createContractRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractRatePhase'
        '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'
  /contracts/{contract_external_id}/applied_rate_cards/{applied_rate_card_code}/rate_phases/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: Contract external id.
        schema:
          type: string
          description: Contract external id.
          example: external_123
      - name: applied_rate_card_code
        in: path
        required: true
        description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
        schema:
          type: string
          description: Code of the rate card applied to the parent, returned as rate_card_code on the applied rate card.
          example: compute_usd
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
      - $ref: '#/components/parameters/contract_code'
    put:
      tags:
        - contract_rate_phases
      summary: Update rate phase
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        A null rate_override removes the override. Structural rate card fields are not overridable. Parent locking rules apply.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: updateContractRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractRatePhase'
        '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'
    patch:
      tags:
        - contract_rate_phases
      summary: Update rate phase
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        A null rate_override removes the override. Structural rate card fields are not overridable. Parent locking rules apply.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: patchContractRatePhase
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RatePhaseUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractRatePhase'
        '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'
    delete:
      tags:
        - contract_rate_phases
      summary: Delete rate phase
      description: |-
        Removes the phase and renumbers later positions. The final indefinite phase and the only remaining phase cannot be deleted.
        Requires the product catalog to be enabled and contract_rate_card write permission on the API key.
      operationId: destroyContractRatePhase
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractRatePhase'
        '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'
  /contracts:
    get:
      tags:
        - contracts
      summary: List contracts
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and contract read permission on the API key.
      operationId: findAllContracts
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches contract name, external ID and Lago ID; plan name and code; and customer name, email and external ID. Ignored when external_id is provided. Customer fields are not searched when external_customer_id is provided.
          schema:
            type: string
            description: Searches contract name, external ID and Lago ID; plan name and code; and customer name, email and external ID. Ignored when external_id is provided. Customer fields are not searched when external_customer_id is provided.
            example: example
        - name: status[]
          in: query
          required: false
          description: Statuses to include. Also accepts scalar status. Defaults to every status since Lago v1.58.0; earlier servers default to active.
          schema:
            type: array
            description: Contract statuses.
            items:
              type: string
              description: Lifecycle status.
              example: pending
              enum:
                - draft
                - pending
                - active
                - terminated
                - canceled
        - name: plan_code
          in: query
          required: false
          description: Plan code.
          schema:
            type: string
            description: Exact identifier.
            example: example
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: Exact identifier.
            example: example
        - name: external_id
          in: query
          required: false
          description: External id.
          schema:
            type: string
            description: Exact identifier.
            example: example
        - name: has_rate_overrides
          in: query
          required: false
          description: Has rate overrides.
          schema:
            type: boolean
            description: Whether the contract has a pricing override.
            example: false
        - name: billing_entity_ids[]
          in: query
          required: false
          description: Billing entity ids[].
          schema:
            type: array
            description: Billing entities.
            items:
              type: string
              description: Billing entity identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - contracts
      summary: Create contract
      description: |-
        Creates a contract for an existing customer. The plan is optional. One draft, pending or active contract may use an external_id at a time. A plan supplies the initial applied rate cards.
        A nonblank code is required. It is immutable and must be unique for the external_id within the organization, including canceled and terminated contracts. Reusing the code returns 422 value_already_exist on code.
        With status draft, the contract is prepared without billing, whatever its start date: its rate cards and overrides can be edited until it is published with POST /contracts/{external_id}/publish.
        Requires the product catalog to be enabled and contract write permission on the API key.
      operationId: createContract
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
  /contracts/{external_id}:
    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
      description: |-
        Returns the contract identified by its external ID. Use contract_code when multiple contracts share that external ID, including historical contracts.
        Requires the product catalog to be enabled and contract read permission on the API key.
      operationId: findContract
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - applied_rate_cards
                - plan
                - customer
                - invoice_custom_sections
              example: applied_rate_cards
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
    put:
      tags:
        - contracts
      summary: Update contract
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        External ID, contract code, and customer are immutable. Lifecycle status determines which other fields can change: a draft is edited like a pending contract.
        Requires the product catalog to be enabled and contract write permission on the API key.
      operationId: updateContract
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
    patch:
      tags:
        - contracts
      summary: Update contract
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        External ID, contract code, and customer are immutable. Lifecycle status determines which other fields can change: a draft is edited like a pending contract.
        Requires the product catalog to be enabled and contract write permission on the API key.
      operationId: patchContract
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
    delete:
      tags:
        - contracts
      summary: Delete contract
      description: |-
        DELETE ends the contract lifecycle; it does not delete the record. Active contracts are terminated; draft and pending contracts are canceled.
        Requires the product catalog to be enabled and contract write permission on the API key.
      operationId: destroyContract
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
  /contracts/{external_id}/publish:
    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'
    post:
      tags:
        - contracts
      summary: Publish contract
      description: |-
        Publishes a draft contract so billing can start; it is the only way out of draft. A draft whose start is ahead becomes pending and starts on its start date. A draft whose start has passed becomes active now: the first period that is due is billed at once, and each further period elapsed since the start is billed on a following hourly run. Usage billed in advance and received while the contract was a draft is not billed.
        Publishing a pending or active contract again publishes nothing; a pending contract whose start has passed is activated. Sends the contract.published webhook, then contract.started when the contract becomes active.
        Errors (422): cannot_publish on contract for a terminated or canceled contract; already_ended on ended_at; customer_deleted on customer; active_contract_exists or value_already_exists on external_id when another active or pending contract uses the external id; value_is_mandatory on contract_code when several contracts share the external id and none is given, or value_is_invalid when it is blank; concurrency_conflict on base when another operation holds the customer's billing schedule, which a retry resolves.
        Requires Lago v1.58.0 or later, the product catalog to be enabled and contract write permission on the API key.
      operationId: publishContract
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - applied_rate_cards
                - plan
                - customer
                - invoice_custom_sections
              example: applied_rate_cards
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
        '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'
  /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'
  /invoices:
    get:
      tags:
        - invoices
      summary: List invoices
      description: |-
        Returns a cursor-paginated list. Use after or before to navigate. The page and per_page parameters are rejected.
        Returns contract invoices, wallet credit purchase invoices and invoices containing catalog fees. The order is issuing_date descending, then created_at and identifier descending.
        Requires the product catalog to be enabled and invoice read permission on the API key.
      operationId: findAllInvoices
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: invoice_type
          in: query
          required: false
          description: Invoice type.
          schema:
            type: string
            description: Type of catalog invoice to list.
            example: contract
            enum:
              - contract
              - advance_fees
              - credit_purchase
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Billing entity codes[].
          schema:
            type: array
            description: Billing entity codes.
            items:
              type: string
              description: Billing entity code.
              example: main
        - name: payment_status[]
          in: query
          required: false
          description: Payment statuses. Also accepts scalar payment_status or the payment_statuses[] alias.
          schema:
            type: array
            description: Payment statuses.
            items:
              type: string
              description: Payment status.
              example: pending
              enum:
                - pending
                - succeeded
                - failed
        - name: status[]
          in: query
          required: false
          description: Invoice statuses. Also accepts scalar status or the statuses[] alias.
          schema:
            type: array
            description: Invoice statuses.
            items:
              type: string
              description: Invoice status.
              example: finalized
              enum:
                - draft
                - finalized
                - voided
                - failed
                - pending
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer id.
            example: example
        - name: customer_external_id
          in: query
          required: false
          description: Customer external id.
          schema:
            type: string
            description: Customer external id.
            example: example
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: example
        - name: purchase_order_number
          in: query
          required: false
          description: Purchase order number.
          schema:
            type: string
            description: Purchase order number.
            example: example
        - name: search_term
          in: query
          required: false
          description: Search term.
          schema:
            type: string
            description: Search term.
            example: example
        - name: partially_paid
          in: query
          required: false
          description: Partially paid.
          schema:
            type: boolean
            description: Partially paid.
            example: false
        - name: payment_dispute_lost
          in: query
          required: false
          description: Payment dispute lost.
          schema:
            type: boolean
            description: Payment dispute lost.
            example: false
        - name: payment_overdue
          in: query
          required: false
          description: Payment overdue.
          schema:
            type: boolean
            description: Payment overdue.
            example: false
        - name: amount_from
          in: query
          required: false
          description: Amount from.
          schema:
            type: integer
            description: Invoice total amount bound, in cents.
            example: 1000
        - name: amount_to
          in: query
          required: false
          description: Amount to.
          schema:
            type: integer
            description: Invoice total amount bound, in cents.
            example: 1000
        - name: issuing_date_from
          in: query
          required: false
          description: Issuing date from.
          schema:
            type: string
            description: Inclusive issuing date bound.
            example: '2022-04-29'
            format: date
        - name: issuing_date_to
          in: query
          required: false
          description: Issuing date to.
          schema:
            type: string
            description: Inclusive issuing date bound.
            example: '2022-04-29'
            format: date
        - name: settlements[]
          in: query
          required: false
          description: Settlements[].
          schema:
            type: array
            description: Settlement types.
            items:
              type: string
              description: Settlement type.
              example: payment
              enum:
                - payment
                - credit_note
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicesPaginated'
        '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'
  /invoices/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - invoices
      summary: Retrieve invoice
      description: |-
        Returns a product-catalog invoice. Legacy-only invoices return 404. Expanding more than 1000 fees returns 400 expansion_too_large.
        Requires the product catalog to be enabled and invoice read permission on the API key.
      operationId: findInvoice
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - fees
                - applied_taxes
                - customer
                - contracts
                - applied_invoice_custom_sections
                - error_details
              example: fees
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - invoices
      summary: Update invoice
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only payment_status is editable. Voided invoices reject updates.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: updateInvoice
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
    patch:
      tags:
        - invoices
      summary: Update invoice
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only payment_status is editable. Voided invoices reject updates.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: patchInvoice
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InvoiceUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
    delete:
      tags:
        - invoices
      summary: Delete invoice
      description: |-
        Only draft invoices not synchronized to an external integration can be deleted. The response has status deleted; the invoice object does not expose deleted_at.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: destroyInvoice
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /fees:
    get:
      tags:
        - fees
      summary: List fees
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Only product fees are returned. Fees can be listed before they have an invoice. Legacy fees are excluded.
        Requires the product catalog to be enabled and fee read permission on the API key.
      operationId: findAllFees
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: lago_invoice_id
          in: query
          required: false
          description: Lago invoice id.
          schema:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
        - name: payment_status
          in: query
          required: false
          description: Payment status.
          schema:
            type: string
            description: Payment status of the fee.
            example: pending
            enum:
              - pending
              - succeeded
              - failed
              - refunded
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer id.
            example: example
        - name: external_contract_id
          in: query
          required: false
          description: External contract id.
          schema:
            type: string
            description: External contract id.
            example: example
        - name: product_code
          in: query
          required: false
          description: Product code.
          schema:
            type: string
            description: Product code.
            example: example
        - name: rate_card_code
          in: query
          required: false
          description: Rate card code.
          schema:
            type: string
            description: Rate card code.
            example: example
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: example
        - name: event_transaction_id
          in: query
          required: false
          description: Event transaction id.
          schema:
            type: string
            description: Event transaction id.
            example: example
        - name: succeeded_at_from
          in: query
          required: false
          description: Inclusive lower bound on succeeded at. A date starts at midnight UTC.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
        - name: succeeded_at_to
          in: query
          required: false
          description: Inclusive upper bound on succeeded at. A date-only upper bound includes the whole UTC day.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
        - name: failed_at_from
          in: query
          required: false
          description: Inclusive lower bound on failed at. A date starts at midnight UTC.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
        - name: failed_at_to
          in: query
          required: false
          description: Inclusive upper bound on failed at. A date-only upper bound includes the whole UTC day.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
        - name: refunded_at_from
          in: query
          required: false
          description: Inclusive lower bound on refunded at. A date starts at midnight UTC.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
        - name: refunded_at_to
          in: query
          required: false
          description: Inclusive upper bound on refunded at. A date-only upper bound includes the whole UTC day.
          schema:
            type: string
            example: '2022-04-29T00:00:00Z'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeesPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /fees/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - fees
      summary: Retrieve fee
      description: |-
        Legacy fees return 404. Related products, filters and rates can identify deleted catalog records for historical fees.
        Requires the product catalog to be enabled and fee read permission on the API key.
      operationId: findFee
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - applied_taxes
                - invoice
                - product
                - product_filter
                - rate_card
                - rate
                - contract
                - customer
              example: applied_taxes
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fee'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - fees
      summary: Update fee
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Updates only payment_status. An invoiced fee cannot be updated and returns 422 with invoiced_fee.
        Requires the product catalog to be enabled and fee write permission on the API key.
      operationId: updateFee
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeeUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fee'
        '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'
    patch:
      tags:
        - fees
      summary: Update fee
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Updates only payment_status. An invoiced fee cannot be updated and returns 422 with invoiced_fee.
        Requires the product catalog to be enabled and fee write permission on the API key.
      operationId: patchFee
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeeUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fee'
        '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'
    delete:
      tags:
        - fees
      summary: Delete fee
      description: |-
        Only uninvoiced fees can be deleted. A fee already attached to an invoice returns 422 invoiced_fee.
        Requires the product catalog to be enabled and fee write permission on the API key.
      operationId: destroyFee
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Fee'
        '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'
  /invoices/{lago_id}/void:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Void an invoice
      description: |-
        Voids an eligible invoice. Optional credit note creation requires a premium license.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: voidInvoice
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoidInvoiceInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /invoices/{lago_id}/lose_dispute:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Mark an invoice dispute as lost
      description: |-
        Marks the payment dispute as lost.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: loseDisputeInvoice
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /invoices/{lago_id}/download_pdf:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Download an invoice PDF
      description: |-
        For finalized invoices only. Returns 200 with the invoice if its PDF already exists. Otherwise, queues PDF generation and returns 202 with an empty body.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: downloadPdfInvoice
      responses:
        '200':
          description: Invoice with an existing PDF
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '202':
          description: PDF generation queued with an empty response body
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /invoices/{lago_id}/resend_email:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Resend an invoice email
      description: |-
        Queues an email for a finalized invoice. Requires a premium license, valid recipients and billing entity email configuration.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: resendEmailInvoice
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResendEmailInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /invoices/{lago_id}/retry_taxes:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Retry invoice taxes
      description: |-
        Retries failed tax processing for an eligible invoice.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: retryTaxesInvoice
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /invoices/{lago_id}/retry_payment:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Retry invoice payment
      description: |-
        Retries collection using the selected or default payment method.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: retryPaymentInvoice
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RetryInvoicePaymentInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /invoices/{lago_id}/finalize:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    put:
      tags:
        - invoices
      summary: Finalize a draft invoice
      description: |-
        Refreshes and finalizes a draft invoice. A non-draft invoice returns 404. Only subscription and contract invoices support finalization; other invoice types return 403. If provider taxes are already pending, the request returns 403 with cannot_finalize_with_pending_taxes. If this request starts fetching provider taxes, it returns 200 with the invoice in pending status; finalization completes after the taxes are applied.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: finalizeInvoice
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /invoices/{lago_id}/refresh:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    put:
      tags:
        - invoices
      summary: Refresh a draft invoice
      description: |-
        Refreshes a draft invoice and recalculates fees, taxes and totals. Eligible non-draft invoices return 200 unchanged. Only subscription and contract invoices support refresh; other invoice types return 403.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: refreshInvoice
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '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'
  /invoices/{lago_id}/payment_url:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - invoices
      summary: Create an invoice payment URL
      description: |-
        Creates a payment URL for a catalog invoice. A payment provider rate limit returns 429.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: createInvoicePaymentUrl
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicePaymentUrl'
        '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'
        '429':
          $ref: '#/components/responses/TooManyRequests'
  /payments:
    get:
      tags:
        - payments
      summary: List payments
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Lists organization payments, including manual and provider payments and payments attached to a payment request.
        Requires the product catalog to be enabled and payment read permission on the API key.
      operationId: findAllPayments
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: invoice_id
          in: query
          required: false
          description: Includes payments made through a payment request that covers this invoice.
          schema:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer identifier.
            example: customer_123
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - payments
      summary: Create payment
      description: |-
        Records a manual payment against an existing invoice. A reference and positive integer amount are required. Premium access and invoice eligibility are checked, except for supported advance-fee payments.
        Requires the product catalog to be enabled and payment write permission on the API key.
      operationId: createPayment
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Payment'
        '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'
  /payments/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - payments
      summary: Retrieve payment
      description: |-
        Returns the payment without nested relationships. No expansions are supported.
        Requires the product catalog to be enabled and payment read permission on the API key.
      operationId: findPayment
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Payment'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /payment_requests:
    get:
      tags:
        - payment_requests
      summary: List payment requests
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and payment_request read permission on the API key.
      operationId: findAllPaymentRequests
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer identifier.
            example: customer_123
        - name: payment_status
          in: query
          required: false
          description: Payment status.
          schema:
            type: string
            description: Payment status.
            example: pending
            enum:
              - pending
              - succeeded
              - failed
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: USD
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Also accepts a scalar billing_entity_codes. Unknown codes return 404.
          schema:
            type: array
            description: Billing entity codes.
            items:
              type: string
              description: Billing entity code.
              example: main
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentRequestsPaginated'
        '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'
    post:
      tags:
        - payment_requests
      summary: Create payment request
      description: |-
        Requires a premium license. Selected customer invoices must be overdue, ready for payment processing, and share the same currency and billing entity. Payment collection and email delivery are asynchronous.
        Requires the product catalog to be enabled and payment_request write permission on the API key.
      operationId: createPaymentRequest
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PaymentRequestCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentRequest'
        '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'
  /payment_requests/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - payment_requests
      summary: Retrieve payment request
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and payment_request read permission on the API key.
      operationId: findPaymentRequest
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentRequest'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /payment_receipts:
    get:
      tags:
        - payment_receipts
      summary: List payment receipts
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Lists every receipt of the organization. Current receipt authorization uses invoice read permission.
        Requires the product catalog to be enabled and invoice read permission on the API key.
      operationId: findAllPaymentReceipts
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: invoice_id
          in: query
          required: false
          description: Includes receipts for payments through a payment request covering the invoice. An unknown invoice returns an empty list.
          schema:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentReceiptsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /payment_receipts/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - payment_receipts
      summary: Retrieve payment receipt
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and invoice read permission on the API key.
      operationId: findPaymentReceipt
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - payment
              example: payment
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentReceipt'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /payment_receipts/{lago_id}/resend_email:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - payment_receipts
      summary: Resend a payment receipt email
      description: |-
        Queues an email for a receipt. Requires a premium license, valid recipients and billing entity email configuration. Returns an empty success body. Authorization uses invoice write permission.
        Requires the product catalog to be enabled and invoice write permission on the API key.
      operationId: resendPaymentReceiptEmail
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResendEmailInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /credit_notes:
    get:
      tags:
        - credit_notes
      summary: List credit notes
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Lists finalized credit notes of the organization, including credit notes for legacy invoices. This list does not support created_at_from or created_at_to.
        Requires the product catalog to be enabled and credit_note read permission on the API key.
        Unknown values for credit_status, refund_status, reason and types[] are ignored rather than rejected. If no supported values remain for a filter, that filter is not applied.
      operationId: findAllCreditNotes
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: search_term
          in: query
          required: false
          description: Search term.
          schema:
            type: string
            description: Search term.
            example: example
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer id.
            example: example
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: example
        - name: invoice_number
          in: query
          required: false
          description: Invoice number.
          schema:
            type: string
            description: Invoice number.
            example: example
        - name: purchase_order_number
          in: query
          required: false
          description: Purchase order number.
          schema:
            type: string
            description: Purchase order number.
            example: example
        - name: credit_status
          in: query
          required: false
          description: Credit status.
          schema:
            type: string
            description: Credit status.
            example: available
            enum:
              - available
              - consumed
              - voided
        - name: refund_status
          in: query
          required: false
          description: Refund status.
          schema:
            type: string
            description: Refund status.
            example: pending
            enum:
              - pending
              - succeeded
              - failed
        - name: reason
          in: query
          required: false
          description: Reason.
          schema:
            type: string
            description: Reason for issuing the credit note.
            example: duplicated_charge
            enum:
              - duplicated_charge
              - product_unsatisfactory
              - order_change
              - order_cancellation
              - fraudulent_charge
              - other
        - name: self_billed
          in: query
          required: false
          description: Self billed.
          schema:
            type: boolean
            description: Whether the invoice is self-billed.
            example: false
        - name: issuing_date_from
          in: query
          required: false
          description: Issuing date from.
          schema:
            type: string
            description: Issuing date bound.
            example: '2022-04-29'
            format: date
        - name: issuing_date_to
          in: query
          required: false
          description: Issuing date to.
          schema:
            type: string
            description: Issuing date bound.
            example: '2022-04-29'
            format: date
        - name: amount_from
          in: query
          required: false
          description: Amount from.
          schema:
            type: integer
            description: Credit note amount bound, in cents.
            example: 100
        - name: amount_to
          in: query
          required: false
          description: Amount to.
          schema:
            type: integer
            description: Credit note amount bound, in cents.
            example: 100
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Billing entity codes[].
          schema:
            type: array
            description: Billing entities.
            items:
              type: string
              description: Billing entity code.
              example: main
        - name: types[]
          in: query
          required: false
          description: Types[].
          schema:
            type: array
            description: Amount types to include.
            items:
              type: string
              description: Credit note amount type.
              example: credit
              enum:
                - credit
                - refund
                - offset
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNotesPaginated'
        '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'
    post:
      tags:
        - credit_notes
      summary: Create credit note
      description: |-
        Requires a premium license and an eligible invoice. Credits are allocated across credit, refund and offset amounts. Product and legacy invoice fees can be credited.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: createCreditNote
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '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'
  /credit_notes/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - credit_notes
      summary: Retrieve credit note
      description: |-
        Retrieves a finalized credit note. Draft or unknown credit notes return 404.
        Requires the product catalog to be enabled and credit_note read permission on the API key.
      operationId: findCreditNote
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - items
                - applied_taxes
                - customer
                - error_details
                - metadata
              example: items
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - credit_notes
      summary: Update credit note
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only refund_status and metadata are accepted. Metadata updates merge keys. Draft credit notes return 404.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: updateCreditNote
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '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'
    patch:
      tags:
        - credit_notes
      summary: Update credit note
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        Only refund_status and metadata are accepted. Metadata updates merge keys. Draft credit notes return 404.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: patchCreditNote
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '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'
  /credit_notes/estimate:
    post:
      tags:
        - credit_notes
      summary: Estimate a credit note
      description: |-
        Computes the amounts and taxes without creating a credit note. Items and applied taxes are always included; no expands[] parameter is needed.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: estimateCreditNote
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteEstimateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimatedCreditNote'
        '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'
  /credit_notes/{lago_id}/download_pdf:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - credit_notes
      summary: Download a credit note PDF
      description: |-
        For finalized credit notes only. Returns 200 with the credit note if its PDF already exists. Otherwise, queues PDF generation and returns 202 with an empty body.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: downloadPdfCreditNote
      responses:
        '200':
          description: Credit note with an existing PDF
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '202':
          description: PDF generation queued with an empty response body
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /credit_notes/{lago_id}/download_xml:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - credit_notes
      summary: Download a credit note XML
      description: |-
        For finalized credit notes only. Returns 200 with the credit note if its XML already exists. Otherwise, queues XML generation and returns 202 with an empty body.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: downloadXmlCreditNote
      responses:
        '200':
          description: Credit note with an existing XML
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '202':
          description: XML generation queued with an empty response body
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /credit_notes/{lago_id}/resend_email:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - credit_notes
      summary: Resend a credit note email
      description: |-
        Queues an email for a finalized credit note. Requires a premium license and valid billing entity email settings.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: resendEmailCreditNote
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResendEmailInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
        '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'
  /credit_notes/{lago_id}/void:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    put:
      tags:
        - credit_notes
      summary: Void a credit note
      description: |-
        Voids an eligible credit note.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: voidCreditNote
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNote'
        '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'
  /credit_notes/{credit_note_id}/metadata:
    parameters:
      - name: credit_note_id
        in: path
        required: true
        description: Credit note identifier.
        schema:
          type: string
          description: Credit note identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    post:
      tags:
        - credit_notes
      summary: Replace credit note metadata
      description: |-
        The credit note must be finalized. POST replaces all metadata; PUT and PATCH merge keys; DELETE clears all metadata. The response contains only the metadata object or null.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: postCreditNoteMetadata
      x-lago-cli-action: replace-metadata
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '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'
    put:
      tags:
        - credit_notes
      summary: Merge credit note metadata
      description: |-
        The credit note must be finalized. POST replaces all metadata; PUT and PATCH merge keys; DELETE clears all metadata. The response contains only the metadata object or null.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: putCreditNoteMetadata
      x-lago-cli-action: merge-metadata
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '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'
    patch:
      tags:
        - credit_notes
      summary: Merge credit note metadata
      description: |-
        The credit note must be finalized. POST replaces all metadata; PUT and PATCH merge keys; DELETE clears all metadata. The response contains only the metadata object or null.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: patchCreditNoteMetadata
      x-lago-cli-action: patch-metadata
      requestBody:
        required: false
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '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'
    delete:
      tags:
        - credit_notes
      summary: Delete all credit note metadata
      description: |-
        The credit note must be finalized. POST replaces all metadata; PUT and PATCH merge keys; DELETE clears all metadata. The response contains only the metadata object or null.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: deleteCreditNoteMetadata
      x-lago-cli-action: delete-metadata
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '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'
  /credit_notes/{credit_note_id}/metadata/{key}:
    parameters:
      - name: credit_note_id
        in: path
        required: true
        description: Credit note identifier.
        schema:
          type: string
          description: Credit note identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
      - name: key
        in: path
        required: true
        description: Metadata key.
        schema:
          type: string
          description: Metadata key.
          example: example_code
    delete:
      tags:
        - credit_notes
      summary: Delete one credit note metadata key
      description: |-
        Deletes one metadata key from a finalized credit note and returns the remaining metadata.
        Requires the product catalog to be enabled and credit_note write permission on the API key.
      operationId: deleteCreditNoteMetadataKey
      x-lago-cli-action: delete-metadata-key
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metadata'
        '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'
  /customers:
    get:
      tags:
        - customers
      summary: List customers
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and customer read permission on the API key.
      operationId: findAllCustomers
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Search term.
          schema:
            type: string
            description: Text to search.
            example: Acme
        - name: external_id
          in: query
          required: false
          description: External id.
          schema:
            type: string
            description: Exact customer external identifier.
            example: customer_123
        - name: has_tax_identification_number
          in: query
          required: false
          description: Has tax identification number.
          schema:
            type: boolean
            description: Filter customers with or without a tax identifier.
            example: false
        - name: has_customer_type
          in: query
          required: false
          description: Has customer type.
          schema:
            type: boolean
            description: Filter customers with or without a customer type.
            example: false
        - name: customer_type
          in: query
          required: false
          description: Customer type.
          schema:
            type: string
            description: Customer type.
            example: company
            enum:
              - company
              - individual
        - name: metadata
          in: query
          required: false
          description: Metadata key and value pairs to match. An empty value, such as metadata[reference]=, matches customers without that key.
          style: deepObject
          explode: true
          schema:
            type: object
            description: Metadata key and value pairs to match. An empty value, such as metadata[reference]=, matches customers without that key.
            additionalProperties:
              type: string
        - name: currencies[]
          in: query
          required: false
          description: Currencies.
          schema:
            type: array
            description: Currencies.
            items:
              type: string
              description: Currencies.
              example: example
        - name: countries[]
          in: query
          required: false
          description: Countries.
          schema:
            type: array
            description: Countries.
            items:
              type: string
              description: Countries.
              example: example
        - name: states[]
          in: query
          required: false
          description: States.
          schema:
            type: array
            description: States.
            items:
              type: string
              description: States.
              example: example
        - name: zipcodes[]
          in: query
          required: false
          description: Zipcodes.
          schema:
            type: array
            description: Zipcodes.
            items:
              type: string
              description: Zipcodes.
              example: example
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Billing entity codes.
          schema:
            type: array
            description: Billing entity codes.
            items:
              type: string
              description: Billing entity codes.
              example: example
        - name: account_type[]
          in: query
          required: false
          description: Account type.
          schema:
            type: array
            description: Account type.
            items:
              type: string
              description: Account type.
              example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomersPaginated'
        '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'
    post:
      tags:
        - customers
      summary: Create customer
      description: |-
        Creates a new customer. An existing external_id returns 422 rather than updating that customer. Billing and payment settings are top-level fields, not a billing_configuration object. Relationships are omitted from the response unless retrieved later with a supported expansion.
        Requires the product catalog to be enabled and customer write permission on the API key.
      operationId: createCustomer
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
        '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'
  /customers/{external_id}:
    parameters:
      - name: external_id
        in: path
        required: true
        description: External id.
        schema:
          type: string
          description: External id.
          example: external_123
    get:
      tags:
        - customers
      summary: Retrieve customer
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and customer read permission on the API key.
      operationId: findCustomer
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - metadata
                - taxes
                - integration_customers
              example: metadata
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - customers
      summary: Update customer
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. When metadata or integration_customers is supplied, it replaces the entire corresponding list. Send each existing entry with its id to keep or update it; omitted entries are deleted. Use the response lago_id as the request id. An empty array removes all entries.
        The path identifies the existing customer. A missing customer returns 404. Billing and payment settings are top-level fields. Relationships are not expanded in the update response.
        Requires the product catalog to be enabled and customer write permission on the API key.
      operationId: updateCustomer
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
        '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'
    patch:
      tags:
        - customers
      summary: Update customer
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. When metadata or integration_customers is supplied, it replaces the entire corresponding list. Send each existing entry with its id to keep or update it; omitted entries are deleted. Use the response lago_id as the request id. An empty array removes all entries.
        The path identifies the existing customer. A missing customer returns 404. Billing and payment settings are top-level fields. Relationships are not expanded in the update response.
        Requires the product catalog to be enabled and customer write permission on the API key.
      operationId: patchCustomer
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
        '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'
    delete:
      tags:
        - customers
      summary: Delete customer
      description: |-
        Soft-deletes the customer and queues the related termination work. The response includes deleted_at.
        Requires the product catalog to be enabled and customer write permission on the API key.
      operationId: destroyCustomer
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Customer'
        '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'
  /organizations:
    get:
      tags:
        - organizations
      summary: Retrieve the organization
      description: |-
        Returns the organization associated with the API key. No expansions are supported.
        Requires the product catalog to be enabled and organization read permission on the API key.
      operationId: findOrganization
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    put:
      tags:
        - organizations
      summary: Update the organization
      description: |-
        Updates email and slug. Omitted fields are unchanged. Name and events_store are read-only.
        Requires the product catalog to be enabled and organization write permission on the API key.
      operationId: updateOrganization
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrganizationUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Organization'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /billing_entities:
    get:
      tags:
        - billing_entities
      summary: List billing entities
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Lists active billing entities only.
        Requires the product catalog to be enabled and billing_entity read permission on the API key.
      operationId: findAllBillingEntities
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingEntitiesPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - billing_entities
      summary: Create billing entity
      description: |-
        Creating additional billing entities requires the relevant entitlement. Grace periods, timezones, email settings and periodic invoice settings may require a premium license.
        Requires the product catalog to be enabled and billing_entity write permission on the API key.
      operationId: createBillingEntity
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingEntityCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingEntity'
        '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'
  /billing_entities/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - billing_entities
      summary: Retrieve billing entity
      description: |-
        Returns an active entity matching the code, or an archived entity if no active entity has that code. Relationships are included only when requested with expands[].
        Requires the product catalog to be enabled and billing_entity read permission on the API key.
      operationId: findBillingEntity
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - taxes
                - selected_invoice_custom_sections
              example: taxes
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingEntity'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - billing_entities
      summary: Update billing entity
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        The code cannot be changed. Billing configuration fields are top-level fields. Empty tax_codes or invoice_custom_section_codes arrays remove the corresponding assignments.
        Requires the product catalog to be enabled and billing_entity write permission on the API key.
      operationId: updateBillingEntity
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingEntityUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingEntity'
        '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'
    patch:
      tags:
        - billing_entities
      summary: Update billing entity
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        The code cannot be changed. Billing configuration fields are top-level fields. Empty tax_codes or invoice_custom_section_codes arrays remove the corresponding assignments.
        Requires the product catalog to be enabled and billing_entity write permission on the API key.
      operationId: patchBillingEntity
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillingEntityUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillingEntity'
        '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'
  /billable_metrics:
    get:
      tags:
        - billable_metrics
      summary: List billable metrics
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.

        Requires the product catalog to be enabled and billable_metric read permission on the API key.
      operationId: findAllBillableMetrics
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetricsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - billable_metrics
      summary: Create billable metric
      description: Requires the product catalog to be enabled and billable_metric write permission on the API key.
      operationId: createBillableMetric
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillableMetricCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetric'
        '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'
  /billable_metrics/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Code.
        schema:
          type: string
          description: Code.
          example: example_code
    get:
      tags:
        - billable_metrics
      summary: Retrieve billable metric
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and billable_metric read permission on the API key.
      operationId: findBillableMetric
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - filters
              example: filters
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetric'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - billable_metrics
      summary: Update billable metric
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        When attached to a plan, only the name, description and permitted filter changes can be updated. Changes to locked fields return 422. Filter values referenced by product filters cannot be removed.
        Requires the product catalog to be enabled and billable_metric write permission on the API key.
      operationId: updateBillableMetric
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillableMetricUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetric'
        '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'
    patch:
      tags:
        - billable_metrics
      summary: Update billable metric
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged.
        When attached to a plan, only the name, description and permitted filter changes can be updated. Changes to locked fields return 422. Filter values referenced by product filters cannot be removed.
        Requires the product catalog to be enabled and billable_metric write permission on the API key.
      operationId: patchBillableMetric
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BillableMetricUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetric'
        '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'
    delete:
      tags:
        - billable_metrics
      summary: Delete billable metric
      description: |-
        Soft-deletes the metric and all its charges and alerts. Draft invoices containing those charges are marked for refresh. The deleted charges stop billing that usage. A metric referenced by a product filter cannot be deleted.
        Requires the product catalog to be enabled and billable_metric write permission on the API key.
      operationId: destroyBillableMetric
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BillableMetric'
        '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'
  /events:
    get:
      tags:
        - events
      summary: List events
      description: |-
        Lists events using event-time filters. ClickHouse returns enriched events ordered by timestamp, external_contract_id, code and transaction_id, all descending. PostgreSQL orders by creation time and identifier, both descending. Cursors are opaque and must not be constructed from response fields. external_subscription_id, created_at_from and created_at_to are rejected. No expansions are supported.
        Requires the product catalog to be enabled and event read permission on the API key.
      operationId: findAllEvents
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: code
          in: query
          required: false
          description: Code.
          schema:
            type: string
            description: Code.
            example: compute
        - name: transaction_id
          in: query
          required: false
          description: Transaction id.
          schema:
            type: string
            description: Transaction id.
            example: transaction_id_123
        - name: external_contract_id
          in: query
          required: false
          description: External contract id.
          schema:
            type: string
            description: External contract id.
            example: external_contract_id_123
        - name: timestamp_from_started_at
          in: query
          required: false
          description: Timestamp from started at.
          schema:
            type: boolean
            description: Use the contract start time as the lower event-time bound. Requires external_contract_id and cannot be combined with timestamp_from.
            example: false
        - name: timestamp_from
          in: query
          required: false
          description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: timestamp_to
          in: query
          required: false
          description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - events
      summary: Ingest an event
      description: |-
        Accepts product-catalog events. external_subscription_id is not supported and returns 422. For ClickHouse organizations, the product event pipeline must be configured, and success acknowledges ingestion rather than completed enrichment. Newly accepted events may not appear in the list immediately.
        Requires the product catalog to be enabled and event write permission on the API key.
      operationId: createEvent
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Event'
        '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'
  /events/batch:
    post:
      tags:
        - events
      summary: Ingest a batch of events
      description: |-
        Accepts product-catalog events. external_subscription_id is not supported and returns 422. For ClickHouse organizations, the product event pipeline must be configured, and success acknowledges ingestion rather than completed enrichment. Newly accepted events may not appear in the list immediately.
        Requires the product catalog to be enabled and event write permission on the API key.
      operationId: createEventsBatch
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventBatchCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventsCollection'
        '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'
  /customers/{customer_external_id}/checkout_url:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    post:
      tags:
        - customers
      summary: Create a customer checkout URL
      description: |-
        Creates a checkout URL using the customer payment provider. No request body is required.
        Requires the product catalog to be enabled and customer write permission on the API key.
      operationId: createCustomerCheckoutUrl
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutUrl'
        '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'
  /customers/{customer_external_id}/invoices:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    get:
      tags:
        - customers
      summary: List customer invoices
      description: |-
        Returns a cursor-paginated list for the customer identified in the path. No expansions are supported.
        Requires the product catalog to be enabled and invoice read permission on the API key.
      operationId: findAllCustomerInvoices
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: invoice_type
          in: query
          required: false
          description: Invoice type.
          schema:
            type: string
            description: Type of catalog invoice to list.
            example: contract
            enum:
              - contract
              - advance_fees
              - credit_purchase
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Billing entity codes[].
          schema:
            type: array
            description: Billing entity codes.
            items:
              type: string
              description: Billing entity code.
              example: main
        - name: payment_status[]
          in: query
          required: false
          description: Payment statuses. Also accepts scalar payment_status or the payment_statuses[] alias.
          schema:
            type: array
            description: Payment statuses.
            items:
              type: string
              description: Payment status.
              example: pending
              enum:
                - pending
                - succeeded
                - failed
        - name: status[]
          in: query
          required: false
          description: Invoice statuses. Also accepts scalar status or the statuses[] alias.
          schema:
            type: array
            description: Invoice statuses.
            items:
              type: string
              description: Invoice status.
              example: finalized
              enum:
                - draft
                - finalized
                - voided
                - failed
                - pending
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: example
        - name: purchase_order_number
          in: query
          required: false
          description: Purchase order number.
          schema:
            type: string
            description: Purchase order number.
            example: example
        - name: search_term
          in: query
          required: false
          description: Search term.
          schema:
            type: string
            description: Search term.
            example: example
        - name: partially_paid
          in: query
          required: false
          description: Partially paid.
          schema:
            type: boolean
            description: Partially paid.
            example: false
        - name: payment_dispute_lost
          in: query
          required: false
          description: Payment dispute lost.
          schema:
            type: boolean
            description: Payment dispute lost.
            example: false
        - name: payment_overdue
          in: query
          required: false
          description: Payment overdue.
          schema:
            type: boolean
            description: Payment overdue.
            example: false
        - name: amount_from
          in: query
          required: false
          description: Amount from.
          schema:
            type: integer
            description: Invoice total amount bound, in cents.
            example: 1000
        - name: amount_to
          in: query
          required: false
          description: Amount to.
          schema:
            type: integer
            description: Invoice total amount bound, in cents.
            example: 1000
        - name: issuing_date_from
          in: query
          required: false
          description: Issuing date from.
          schema:
            type: string
            description: Inclusive issuing date bound.
            example: '2022-04-29'
            format: date
        - name: issuing_date_to
          in: query
          required: false
          description: Issuing date to.
          schema:
            type: string
            description: Inclusive issuing date bound.
            example: '2022-04-29'
            format: date
        - name: settlements[]
          in: query
          required: false
          description: Settlements[].
          schema:
            type: array
            description: Settlement types.
            items:
              type: string
              description: Settlement type.
              example: payment
              enum:
                - payment
                - credit_note
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoicesPaginated'
        '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'
  /customers/{customer_external_id}/credit_notes:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    get:
      tags:
        - customers
      summary: List customer credit notes
      description: |-
        Returns a cursor-paginated list for the customer identified in the path. No expansions are supported.
        Requires the product catalog to be enabled and credit_note read permission on the API key. Unknown values for credit_status, refund_status, reason and types[] are ignored. If no supported values remain for a filter, that filter is not applied.
      operationId: findAllCustomerCreditNotes
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: search_term
          in: query
          required: false
          description: Search term.
          schema:
            type: string
            description: Search term.
            example: example
        - name: currency
          in: query
          required: false
          description: Currency as an ISO 4217 code.
          schema:
            type: string
            description: Currency as an ISO 4217 code.
            example: example
        - name: invoice_number
          in: query
          required: false
          description: Invoice number.
          schema:
            type: string
            description: Invoice number.
            example: example
        - name: purchase_order_number
          in: query
          required: false
          description: Purchase order number.
          schema:
            type: string
            description: Purchase order number.
            example: example
        - name: credit_status
          in: query
          required: false
          description: Credit status.
          schema:
            type: string
            description: Credit status.
            example: available
            enum:
              - available
              - consumed
              - voided
        - name: refund_status
          in: query
          required: false
          description: Refund status.
          schema:
            type: string
            description: Refund status.
            example: pending
            enum:
              - pending
              - succeeded
              - failed
        - name: reason
          in: query
          required: false
          description: Reason.
          schema:
            type: string
            description: Reason for issuing the credit note.
            example: duplicated_charge
            enum:
              - duplicated_charge
              - product_unsatisfactory
              - order_change
              - order_cancellation
              - fraudulent_charge
              - other
        - name: self_billed
          in: query
          required: false
          description: Self billed.
          schema:
            type: boolean
            description: Whether the invoice is self-billed.
            example: false
        - name: issuing_date_from
          in: query
          required: false
          description: Issuing date from.
          schema:
            type: string
            description: Issuing date bound.
            example: '2022-04-29'
            format: date
        - name: issuing_date_to
          in: query
          required: false
          description: Issuing date to.
          schema:
            type: string
            description: Issuing date bound.
            example: '2022-04-29'
            format: date
        - name: amount_from
          in: query
          required: false
          description: Amount from.
          schema:
            type: integer
            description: Credit note amount bound, in cents.
            example: 100
        - name: amount_to
          in: query
          required: false
          description: Amount to.
          schema:
            type: integer
            description: Credit note amount bound, in cents.
            example: 100
        - name: billing_entity_codes[]
          in: query
          required: false
          description: Billing entity codes[].
          schema:
            type: array
            description: Billing entities.
            items:
              type: string
              description: Billing entity code.
              example: main
        - name: types[]
          in: query
          required: false
          description: Types[].
          schema:
            type: array
            description: Amount types to include.
            items:
              type: string
              description: Credit note amount type.
              example: credit
              enum:
                - credit
                - refund
                - offset
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNotesPaginated'
        '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'
  /customers/{customer_external_id}/payments:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    get:
      tags:
        - customers
      summary: List customer payments
      description: |-
        Returns a cursor-paginated list for the customer identified in the path. No expansions are supported.
        Requires the product catalog to be enabled and payment read permission on the API key.
      operationId: findAllCustomerPayments
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentsPaginated'
        '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'
  /customers/{customer_external_id}/payment_requests:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    get:
      tags:
        - customers
      summary: List customer payment requests
      description: |-
        Returns a cursor-paginated list for the customer identified in the path. No expansions are supported.
        Requires the product catalog to be enabled and payment_request read permission on the API key.
      operationId: findAllCustomerPaymentRequests
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentRequestsPaginated'
        '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'
  /customers/{customer_external_id}/payment_methods:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
    get:
      tags:
        - customers
      summary: List customer payment methods
      description: |-
        Returns a cursor-paginated list for the customer identified in the path. No expansions are supported.
        Requires the product catalog to be enabled and payment_method read permission on the API key.
      operationId: findAllCustomerPaymentMethods
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethodsPaginated'
        '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'
  /customers/{customer_external_id}/payment_methods/{lago_id}:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
      - name: lago_id
        in: path
        required: true
        description: Payment method identifier created by Lago.
        schema:
          type: string
          description: Payment method identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    delete:
      tags:
        - customers
      summary: Delete a customer payment method
      description: |-
        Deletes the payment method and returns it with deleted_at set.
        Requires the product catalog to be enabled and payment_method write permission on the API key.
      operationId: destroyCustomerPaymentMethod
      x-lago-cli-action: delete-payment-method
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethod'
        '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'
  /customers/{customer_external_id}/payment_methods/{lago_id}/set_as_default:
    parameters:
      - name: customer_external_id
        in: path
        required: true
        description: Customer external identifier.
        schema:
          type: string
          description: Customer external identifier.
          example: external_123
      - name: lago_id
        in: path
        required: true
        description: Payment method identifier created by Lago.
        schema:
          type: string
          description: Payment method identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    put:
      tags:
        - customers
      summary: Set the default customer payment method
      description: |-
        Sets this payment method as the customer default. No request body is required.
        Requires the product catalog to be enabled and payment_method write permission on the API key.
      operationId: setDefaultCustomerPaymentMethod
      x-lago-cli-action: set-default-payment-method
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentMethod'
        '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'
  /activity_logs:
    get:
      tags:
        - activity_logs
      summary: List activity logs
      description: |-
        Returns a cursor-paginated list ordered by log time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Requires a premium license and available log storage. Results are ordered by logged_at and activity_id, both descending, within the configured retention period.
        Requires the product catalog to be enabled and activity_log read permission on the API key.
      operationId: findAllActivityLogs
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: from_date
          in: query
          required: false
          description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: to_date
          in: query
          required: false
          description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: activity_types[]
          in: query
          required: false
          description: Activity types[].
          schema:
            type: array
            description: Activity types.
            items:
              type: string
              description: Activity types.
              example: example
        - name: activity_sources[]
          in: query
          required: false
          description: Activity sources[].
          schema:
            type: array
            description: Activity sources.
            items:
              type: string
              description: Activity sources.
              example: example
        - name: user_emails[]
          in: query
          required: false
          description: User emails[].
          schema:
            type: array
            description: User emails.
            items:
              type: string
              description: User emails.
              example: example
        - name: resource_ids[]
          in: query
          required: false
          description: Resource ids[].
          schema:
            type: array
            description: Resource ids.
            items:
              type: string
              description: Resource ids.
              example: example
        - name: resource_types[]
          in: query
          required: false
          description: Resource types[].
          schema:
            type: array
            description: Resource types.
            items:
              type: string
              description: Resource types.
              example: example
        - name: external_customer_id
          in: query
          required: false
          description: External customer id.
          schema:
            type: string
            description: External customer id.
            example: example
        - name: external_subscription_id
          in: query
          required: false
          description: External subscription id.
          schema:
            type: string
            description: External subscription id.
            example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActivityLogsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /activity_logs/{activity_id}:
    parameters:
      - name: activity_id
        in: path
        required: true
        description: Activity id.
        schema:
          type: string
          description: Activity id.
          example: example_code
    get:
      tags:
        - activity_logs
      summary: Retrieve activity log
      description: |-
        Requires a premium license and available log storage. No expansions are supported.
        Requires the product catalog to be enabled and activity_log read permission on the API key.
      operationId: findActivityLog
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActivityLog'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /api_logs:
    get:
      tags:
        - api_logs
      summary: List api logs
      description: |-
        Returns a cursor-paginated list ordered by log time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Requires a premium license and available log storage. Results are ordered by logged_at and request_id, both descending, within the configured retention period.
        Requires the product catalog to be enabled and api_log read permission on the API key.
      operationId: findAllApiLogs
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: from_date
          in: query
          required: false
          description: Inclusive lower log-time bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive lower log-time bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: to_date
          in: query
          required: false
          description: Inclusive upper log-time bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive upper log-time bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: http_methods[]
          in: query
          required: false
          description: Http methods[].
          schema:
            type: array
            description: Http methods.
            items:
              type: string
              description: Http methods.
              example: example
        - name: http_statuses[]
          in: query
          required: false
          description: HTTP status codes or status groups. succeeded selects codes up to 399; failed selects codes above 399. Groups take precedence over numeric codes. Selecting both groups returns no matches.
          schema:
            type: array
            description: Http statuses.
            items:
              anyOf:
                - type: integer
                  description: HTTP status code.
                  example: 200
                - type: string
                  description: HTTP status group.
                  example: succeeded
                  enum:
                    - succeeded
                    - failed
        - name: request_paths[]
          in: query
          required: false
          description: Request paths[].
          schema:
            type: array
            description: Request paths.
            items:
              type: string
              description: Request paths.
              example: example
        - name: clients[]
          in: query
          required: false
          description: Clients[].
          schema:
            type: array
            description: Clients.
            items:
              type: string
              description: Clients.
              example: example
        - name: api_version
          in: query
          required: false
          description: Api version.
          schema:
            type: string
            description: Api version.
            example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiLogsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /api_logs/{request_id}:
    parameters:
      - name: request_id
        in: path
        required: true
        description: Request id.
        schema:
          type: string
          description: Request id.
          example: example_code
    get:
      tags:
        - api_logs
      summary: Retrieve api log
      description: |-
        Requires a premium license and available log storage. No expansions are supported.
        Requires the product catalog to be enabled and api_log read permission on the API key.
      operationId: findApiLog
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiLog'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /security_logs:
    get:
      tags:
        - security_logs
      summary: List security logs
      description: |-
        Returns a cursor-paginated list ordered by log time, newest first. Use after or before to navigate. The page and per_page parameters are rejected.
        Requires a premium license and available log storage. Security logs must also be enabled for the organization. Results are ordered by logged_at and log_id, both descending, within the fixed 90-day retention period.
        Requires the product catalog to be enabled and security_log read permission on the API key.
      operationId: findAllSecurityLogs
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - name: from_date
          in: query
          required: false
          description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
          schema:
            type: string
            description: Inclusive lower bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC.
            example: '2022-04-29T08:59:51.123456Z'
        - name: to_date
          in: query
          required: true
          description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC. Required; a request without it returns 422.
          schema:
            type: string
            description: Inclusive upper bound as an ISO 8601 date or timestamp. A date is interpreted as midnight UTC. Required; a request without it returns 422.
            example: '2022-04-29T08:59:51.123456Z'
        - name: user_ids[]
          in: query
          required: false
          description: User ids[].
          schema:
            type: array
            description: User ids.
            items:
              type: string
              description: User ids.
              example: example
        - name: api_key_ids[]
          in: query
          required: false
          description: Api key ids[].
          schema:
            type: array
            description: Api key ids.
            items:
              type: string
              description: Api key ids.
              example: example
        - name: log_types[]
          in: query
          required: false
          description: Log types[].
          schema:
            type: array
            description: Log types.
            items:
              type: string
              description: Log types.
              example: example
        - name: log_events[]
          in: query
          required: false
          description: Log events[].
          schema:
            type: array
            description: Log events.
            items:
              type: string
              description: Log events.
              example: example
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecurityLogsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /security_logs/{log_id}:
    parameters:
      - name: log_id
        in: path
        required: true
        description: Log id.
        schema:
          type: string
          description: Log id.
          example: example_code
    get:
      tags:
        - security_logs
      summary: Retrieve security log
      description: |-
        Requires a premium license, available log storage and security logs enabled for the organization. Records older than 90 days are excluded. No expansions are supported.
        Requires the product catalog to be enabled and security_log read permission on the API key.
      operationId: findSecurityLog
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SecurityLog'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /webhook_endpoints:
    get:
      tags:
        - webhook_endpoints
      summary: List webhook endpoints
      description: |-
        Returns a cursor-paginated list ordered by creation time, newest first. Use after or before to navigate. The page and per_page parameters are rejected. Expansions are not supported; a nonempty expands[] returns 400 expand_not_supported.

        Requires the product catalog to be enabled and webhook_endpoint read permission on the API key.
      operationId: findAllWebhookEndpoints
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpointsPaginated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - webhook_endpoints
      summary: Create webhook endpoint
      description: |-
        Creates a webhook endpoint. The organization can have at most ten endpoints, each with a distinct URL. The endpoint signs its deliveries with Standard Webhooks; request expands[]=signing_keys to read its signing key.
        Requires the product catalog to be enabled and webhook_endpoint write permission on the API key.
      operationId: createWebhookEndpoint
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - signing_keys
              example: signing_keys
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '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'
  /webhook_endpoints/{lago_id}:
    parameters:
      - name: lago_id
        in: path
        required: true
        description: Unique identifier created by Lago.
        schema:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - webhook_endpoints
      summary: Retrieve webhook endpoint
      description: |-
        Returns the record without nested relationships unless a supported expansion is requested.
        Requires the product catalog to be enabled and webhook_endpoint read permission on the API key. Requesting expands[]=signing_keys also requires webhook_endpoint write permission and returns 403 without it.
      operationId: findWebhookEndpoint
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - signing_keys
              example: signing_keys
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - webhook_endpoints
      summary: Update webhook endpoint
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. Switching to standard_webhooks creates the endpoint's signing key, or reuses the key kept from an earlier switch; request expands[]=signing_keys to read it.

        Requires the product catalog to be enabled and webhook_endpoint write permission on the API key.
      operationId: updateWebhookEndpoint
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - signing_keys
              example: signing_keys
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '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'
    patch:
      tags:
        - webhook_endpoints
      summary: Update webhook endpoint
      description: |-
        PUT and PATCH both accept partial updates. Omitted fields are unchanged. Switching to standard_webhooks creates the endpoint's signing key, or reuses the key kept from an earlier switch; request expands[]=signing_keys to read it.

        Requires the product catalog to be enabled and webhook_endpoint write permission on the API key.
      operationId: patchWebhookEndpoint
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include in this response. Only one expansion level is supported.
          schema:
            type: array
            description: Relationships to include.
            items:
              type: string
              enum:
                - signing_keys
              example: signing_keys
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookEndpointUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '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'
    delete:
      tags:
        - webhook_endpoints
      summary: Delete webhook endpoint
      description: |-
        Permanently deletes the endpoint and its delivery records. Returns the deleted endpoint configuration without a deleted_at field. Expansions are not supported; a nonempty expands[] returns 400 expand_not_supported.
        Requires the product catalog to be enabled and webhook_endpoint write permission on the API key.
      operationId: destroyWebhookEndpoint
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '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'
  /features:
    get:
      tags:
        - features
      summary: List all features
      description: Returns a cursor-paginated list, newest first. Offset pagination parameters are rejected. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: findAllFeatures
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: search_term
          in: query
          required: false
          description: Searches feature names, codes and descriptions.
          schema:
            type: string
            description: Text to search.
            example: analytics
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturesPaginated'
              example:
                features:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    code: analytics
                    name: null
                    description: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
                meta:
                  next_cursor: null
                  prev_cursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
    post:
      tags:
        - features
      summary: Create a feature
      description: Creates a feature and optionally up to 50 initial privileges. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: createFeature
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include. Only the listed expansions are supported.
          schema:
            type: array
            description: Relationship names.
            items:
              type: string
              description: Relationship name.
              example: privileges
              enum:
                - privileges
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
  /features/{code}:
    parameters:
      - name: code
        in: path
        required: true
        description: Feature code.
        schema:
          type: string
          description: Feature code.
          example: example_code
    get:
      tags:
        - features
      summary: Retrieve a feature
      description: Returns the requested record. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: findFeature
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include. Only the listed expansions are supported.
          schema:
            type: array
            description: Relationship names.
            items:
              type: string
              description: Relationship name.
              example: privileges
              enum:
                - privileges
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - features
      summary: Update a feature
      description: Updates the name and description. PUT and PATCH accept partial updates; the code and privileges are not changed. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: updateFeature
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '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'
    patch:
      tags:
        - features
      summary: Update a feature
      description: Updates the name and description. PUT and PATCH accept partial updates; the code and privileges are not changed. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: patchFeature
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeatureUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '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'
    delete:
      tags:
        - features
      summary: Delete a feature
      description: Soft-deletes the feature, its privileges and associated entitlements. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: destroyFeature
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Feature'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /features/{feature_code}/privileges:
    parameters:
      - name: feature_code
        in: path
        required: true
        description: Code of the parent feature.
        schema:
          type: string
          description: Code of the parent feature.
          example: analytics
    get:
      tags:
        - feature_privileges
      summary: List all privileges
      description: Returns the complete list without pagination metadata. Pagination parameters are rejected. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: findAllFeaturePrivileges
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilegesCollection'
              example:
                privileges:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    feature_code: analytics
                    code: seats
                    name: null
                    value_type: integer
                    select_options: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
        - feature_privileges
      summary: Create a privilege
      description: Adds a privilege to the feature. At most 50 privileges are allowed per feature. Omitted value_type defaults to string. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: createFeaturePrivilege
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeaturePrivilegeCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilege'
        '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'
  /features/{feature_code}/privileges/{code}:
    parameters:
      - name: feature_code
        in: path
        required: true
        description: Code of the parent feature.
        schema:
          type: string
          description: Code of the parent feature.
          example: analytics
      - name: code
        in: path
        required: true
        description: Feature Privilege code.
        schema:
          type: string
          description: Feature Privilege code.
          example: example_code
    get:
      tags:
        - feature_privileges
      summary: Retrieve a privilege
      description: Returns the requested record. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: findFeaturePrivilege
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilege'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - feature_privileges
      summary: Update a privilege
      description: Updates the name and select options. PUT and PATCH accept partial updates. Existing select options cannot be removed. The code and value type cannot be changed. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: updateFeaturePrivilege
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeaturePrivilegeUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilege'
        '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'
    patch:
      tags:
        - feature_privileges
      summary: Update a privilege
      description: Updates the name and select options. PUT and PATCH accept partial updates. Existing select options cannot be removed. The code and value type cannot be changed. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: patchFeaturePrivilege
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeaturePrivilegeUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilege'
        '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'
    delete:
      tags:
        - feature_privileges
      summary: Delete a privilege
      description: Soft-deletes the privilege and removes its entitlement values. Requires the product catalog to be enabled and feature read or write permission on the API key, according to the HTTP method.
      operationId: destroyFeaturePrivilege
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeaturePrivilege'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /plans/{plan_code}/wallets:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
    get:
      tags:
        - plan_wallets
      summary: List all wallets
      description: Returns a cursor-paginated list, newest first. Offset pagination parameters are rejected. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: findAllPlanWallets
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWalletsPaginated'
              example:
                plan_wallets:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    code: prepaid
                    name: null
                    invoice_display_name: null
                    currency: USD
                    tax_application: tax_on_consumption
                    priority: 50
                    applies_to:
                      include: []
                    top_up_min_amount_cents: null
                    top_up_max_amount_cents: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
                    plan_code: standard
                meta:
                  next_cursor: null
                  prev_cursor: null
        '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'
    post:
      tags:
        - plan_wallets
      summary: Create a wallet
      description: Creates a wallet template copied to new contracts. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: createPlanWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanWalletCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWallet'
        '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'
  /plans/{plan_code}/wallets/{code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
      - name: code
        in: path
        required: true
        description: Plan Wallet code.
        schema:
          type: string
          description: Plan Wallet code.
          example: example_code
    get:
      tags:
        - plan_wallets
      summary: Retrieve a wallet
      description: Returns the requested record. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: findPlanWallet
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include. Only the listed expansions are supported.
          schema:
            type: array
            description: Relationship names.
            items:
              type: string
              description: Relationship name.
              example: taxes
              enum:
                - taxes
                - metadata
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWallet'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - plan_wallets
      summary: Update a wallet
      description: PUT and PATCH accept partial updates. Changes affect new contracts only. The code cannot change after the plan is attached to a contract. Supplied taxes, metadata and selectors replace their corresponding values. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: updatePlanWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanWalletUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWallet'
        '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'
    patch:
      tags:
        - plan_wallets
      summary: Update a wallet
      description: PUT and PATCH accept partial updates. Changes affect new contracts only. The code cannot change after the plan is attached to a contract. Supplied taxes, metadata and selectors replace their corresponding values. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: patchPlanWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanWalletUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWallet'
        '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'
    delete:
      tags:
        - plan_wallets
      summary: Delete a wallet
      description: Soft-deletes the template without changing existing contract wallets. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and plan_wallet read or write permission on the API key, according to the HTTP method.
      operationId: destroyPlanWallet
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanWallet'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /contracts/{contract_external_id}/wallets:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contract_wallets
      summary: List all wallets
      description: Returns a cursor-paginated list, newest first. Offset pagination parameters are rejected. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: findAllContractWallets
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWalletsPaginated'
              example:
                contract_wallets:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    code: prepaid
                    name: null
                    invoice_display_name: null
                    currency: USD
                    tax_application: tax_on_consumption
                    priority: 50
                    applies_to:
                      include: []
                    top_up_min_amount_cents: null
                    top_up_max_amount_cents: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
                    lago_contract_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    external_contract_id: contract_123
                    contract_code: null
                    external_customer_id: customer_123
                    balance_cents: 0
                    ongoing_balance_cents: 0
                    last_ongoing_balance_sync_at: null
                    terminated_at: null
                meta:
                  next_cursor: null
                  prev_cursor: null
        '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'
    post:
      tags:
        - contract_wallets
      summary: Create a wallet
      description: Creates a wallet on a live contract (draft, pending or active). Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: createContractWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractWalletCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWallet'
        '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'
  /contracts/{contract_external_id}/wallets/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: code
        in: path
        required: true
        description: Contract Wallet code.
        schema:
          type: string
          description: Contract Wallet code.
          example: example_code
    get:
      tags:
        - contract_wallets
      summary: Retrieve a wallet
      description: Returns the requested record. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: findContractWallet
      parameters:
        - name: expands[]
          in: query
          required: false
          description: Relationships to include. Only the listed expansions are supported.
          schema:
            type: array
            description: Relationship names.
            items:
              type: string
              description: Relationship name.
              example: taxes
              enum:
                - taxes
                - metadata
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWallet'
        '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'
    put:
      tags:
        - contract_wallets
      summary: Update a wallet
      description: PUT and PATCH accept partial updates. Only live contracts can be edited. The wallet code, currency and tax application cannot change. Supplied taxes, metadata and selectors replace their corresponding values. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: updateContractWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractWalletUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWallet'
        '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'
    patch:
      tags:
        - contract_wallets
      summary: Update a wallet
      description: PUT and PATCH accept partial updates. Only live contracts can be edited. The wallet code, currency and tax application cannot change. Supplied taxes, metadata and selectors replace their corresponding values. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: patchContractWallet
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractWalletUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWallet'
        '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'
    delete:
      tags:
        - contract_wallets
      summary: Delete a wallet
      description: Soft-deletes a wallet of a live contract only when it has no positive balance, unsettled inbound transactions or credit allocations. Catalog wallets must also be enabled for the organization. Requires the product catalog to be enabled and contract_wallet read or write permission on the API key, according to the HTTP method.
      operationId: destroyContractWallet
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWallet'
        '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'
  /contracts/{contract_external_id}/wallets/{wallet_code}/transactions:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
    get:
      tags:
        - contract_wallet_transactions
      summary: List all contract wallet transactions
      description: Returns a cursor-paginated list, newest first. Requires the product catalog to be enabled and wallet_transaction read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findAllContractWalletTransactions
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
        - name: direction
          in: query
          required: false
          description: Filter by transaction direction.
          schema:
            type: string
            description: Transaction direction.
            example: inbound
            enum:
              - inbound
              - outbound
        - name: status
          in: query
          required: false
          description: Filter by transaction status.
          schema:
            type: string
            description: Transaction status.
            example: settled
            enum:
              - pending
              - settled
              - failed
        - name: reason
          in: query
          required: false
          description: Filter by transaction reason.
          schema:
            type: string
            description: Reason for the transaction.
            example: top_up
            enum:
              - top_up
              - credit_allocation
              - invoice_void
              - invoice_application
              - void
        - name: credit_allocation_code
          in: query
          required: false
          description: Filter by credit allocation code, including removed allocations.
          schema:
            type: string
            description: Credit allocation code.
            example: monthly
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWalletTransactionsPaginated'
              example:
                wallet_transactions:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    lago_wallet_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    wallet_code: prepaid
                    lago_invoice_id: null
                    lago_credit_allocation_id: null
                    credit_allocation_code: null
                    direction: outbound
                    status: settled
                    reason: invoice_application
                    allocation_type: null
                    currency: USD
                    purchase_amount_cents: null
                    credit_amount_cents: 500
                    remaining_credit_amount_cents: null
                    priority: null
                    settled_at: '2022-04-29T08:59:51.123456Z'
                    failed_at: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                meta:
                  next_cursor: null
                  prev_cursor: null
        '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'
  /contracts/{contract_external_id}/wallets/{wallet_code}/transactions/{id}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
      - name: id
        in: path
        required: true
        description: Wallet transaction identifier.
        schema:
          type: string
          description: Wallet transaction identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    get:
      tags:
        - contract_wallet_transactions
      summary: Retrieve a contract wallet transaction
      description: Returns one transaction belonging to the wallet. Requires the product catalog to be enabled and wallet_transaction read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findContractWalletTransaction
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractWalletTransaction'
        '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'
  /plans/{plan_code}/wallets/{wallet_code}/alerts:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
    get:
      tags:
        - plan_wallet_alerts
      summary: List all wallet alerts
      description: Returns the complete list, newest first, without pagination metadata. Pagination parameters are rejected. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findAllPlanWalletAlerts
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlertsCollection'
              example:
                alerts:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    lago_wallet_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    wallet_code: prepaid
                    currency: USD
                    code: low_balance
                    name: null
                    alert_type: balance
                    direction: decreasing
                    thresholds:
                      - code: warning
                        value: '100.0'
                        recurring: false
                        notify_on:
                          - triggered
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    plan_code: standard
                    lago_contract_id: null
                    external_contract_id: null
                    contract_code: null
                    external_customer_id: null
                    previous_value: null
                    last_processed_at: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
        - plan_wallet_alerts
      summary: Create a wallet alert
      description: Creates an alert template, copied to new contract wallets. Only one alert per balance type is allowed. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: createPlanWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
  /plans/{plan_code}/wallets/{wallet_code}/alerts/{code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
      - name: code
        in: path
        required: true
        description: Alert code.
        schema:
          type: string
          description: Alert code.
          example: low_balance
    get:
      tags:
        - plan_wallet_alerts
      summary: Retrieve a wallet alert
      description: Returns the alert. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findPlanWalletAlert
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - plan_wallet_alerts
      summary: Update a wallet alert
      description: PUT and PATCH accept partial updates to the name and thresholds. Sending code or alert_type is rejected. A supplied threshold list replaces the existing list. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: updatePlanWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
    patch:
      tags:
        - plan_wallet_alerts
      summary: Update a wallet alert
      description: PUT and PATCH accept partial updates to the name and thresholds. Sending code or alert_type is rejected. A supplied threshold list replaces the existing list. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: patchPlanWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
    delete:
      tags:
        - plan_wallet_alerts
      summary: Delete a wallet alert
      description: Deletes the alert and its thresholds. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: destroyPlanWalletAlert
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /contracts/{contract_external_id}/wallets/{wallet_code}/alerts:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
    get:
      tags:
        - contract_wallet_alerts
      summary: List all wallet alerts
      description: Returns the complete list, newest first, without pagination metadata. Pagination parameters are rejected. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findAllContractWalletAlerts
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlertsCollection'
              example:
                alerts:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    lago_wallet_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    wallet_code: prepaid
                    currency: USD
                    code: low_balance
                    name: null
                    alert_type: balance
                    direction: decreasing
                    thresholds:
                      - code: warning
                        value: '100.0'
                        recurring: false
                        notify_on:
                          - triggered
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    plan_code: null
                    lago_contract_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    external_contract_id: contract_123
                    contract_code: default
                    external_customer_id: customer_123
                    previous_value: '500.0'
                    last_processed_at: '2022-04-29T08:59:51.123456Z'
        '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'
    post:
      tags:
        - contract_wallet_alerts
      summary: Create a wallet alert
      description: Creates an alert. Only one alert per balance type is allowed. The contract must be live and the wallet must not be terminated. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: createContractWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
  /contracts/{contract_external_id}/wallets/{wallet_code}/alerts/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: wallet_code
        in: path
        required: true
        description: Wallet code.
        schema:
          type: string
          description: Wallet code.
          example: prepaid
      - name: code
        in: path
        required: true
        description: Alert code.
        schema:
          type: string
          description: Alert code.
          example: low_balance
    get:
      tags:
        - contract_wallet_alerts
      summary: Retrieve a wallet alert
      description: Returns the alert. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: findContractWalletAlert
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
    put:
      tags:
        - contract_wallet_alerts
      summary: Update a wallet alert
      description: PUT and PATCH accept partial updates to the name and thresholds. Sending code or alert_type is rejected. A supplied threshold list replaces the existing list. The contract must be live and the wallet must not be terminated. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: updateContractWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
    patch:
      tags:
        - contract_wallet_alerts
      summary: Update a wallet alert
      description: PUT and PATCH accept partial updates to the name and thresholds. Sending code or alert_type is rejected. A supplied threshold list replaces the existing list. The contract must be live and the wallet must not be terminated. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: patchContractWalletAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CatalogWalletAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
    delete:
      tags:
        - contract_wallet_alerts
      summary: Delete a wallet alert
      description: Deletes the alert and its thresholds. The contract must be live and the wallet must not be terminated. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method. Catalog wallets must also be enabled for the organization.
      operationId: destroyContractWalletAlert
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CatalogWalletAlert'
        '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'
  /contracts/{contract_external_id}/alerts:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External contract identifier shared by all contract versions.
        schema:
          type: string
          description: External contract identifier shared by all contract versions.
          example: contract_123
    get:
      tags:
        - contract_alerts
      summary: List all contract alerts
      description: Returns a cursor-paginated list of alerts shared by all versions of this external contract identifier. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: findAllContractAlerts
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/after'
        - $ref: '#/components/parameters/before'
        - $ref: '#/components/parameters/include_total_count'
        - $ref: '#/components/parameters/created_at_from'
        - $ref: '#/components/parameters/created_at_to'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlertsPaginated'
              example:
                alerts:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    external_contract_id: contract_123
                    code: usage_warning
                    name: null
                    alert_type: usage_amount
                    scope: []
                    direction: increasing
                    thresholds:
                      - code: warning
                        value: '100.0'
                        recurring: false
                        notify_on:
                          - triggered
                          - resolved
                    previous_value: '0.0'
                    last_processed_at: null
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
                meta:
                  next_cursor: null
                  prev_cursor: null
        '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'
    post:
      tags:
        - contract_alerts
      summary: Create a contract alert
      description: Creates an alert for a live contract. Requires a premium license and the contract alerts feature. Use an empty scope array to monitor all metered products for a usage_amount alert. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: createContractAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAlertCreateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlert'
        '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'
  /contracts/{contract_external_id}/alerts/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External contract identifier shared by all contract versions.
        schema:
          type: string
          description: External contract identifier shared by all contract versions.
          example: contract_123
      - name: code
        in: path
        required: true
        description: Alert code.
        schema:
          type: string
          description: Alert code.
          example: usage_warning
    get:
      tags:
        - contract_alerts
      summary: Retrieve a contract alert
      description: Returns an alert shared by all contract versions with the external identifier. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: findContractAlert
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlert'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - contract_alerts
      summary: Update a contract alert
      description: PUT and PATCH accept partial updates to name and thresholds. Sending code, alert_type or scope is rejected. Requires at least one live contract with the external identifier. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: updateContractAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlert'
        '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'
    patch:
      tags:
        - contract_alerts
      summary: Update a contract alert
      description: PUT and PATCH accept partial updates to name and thresholds. Sending code, alert_type or scope is rejected. Requires at least one live contract with the external identifier. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: patchContractAlert
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContractAlertUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlert'
        '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'
    delete:
      tags:
        - contract_alerts
      summary: Delete a contract alert
      description: Soft-deletes the alert and deletes its thresholds. Requires the product catalog to be enabled and alert read or write permission on the API key, according to the HTTP method.
      operationId: destroyContractAlert
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractAlert'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /plans/{plan_code}/entitlements:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
    get:
      tags:
        - plan_entitlements
      summary: List all entitlements
      description: Returns all plan entitlements without pagination metadata. Pagination parameters are rejected on every entitlement action. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: findAllPlanEntitlements
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlementsCollection'
              example:
                plan_entitlements:
                  - lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    plan_code: standard
                    feature_code: analytics
                    values:
                      - privilege_code: seats
                        value: 10
                    created_at: '2022-04-29T08:59:51.123456Z'
                    updated_at: '2022-04-29T08:59:51.123456Z'
                    deleted_at: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      tags:
        - plan_entitlements
      summary: Replace plan entitlements
      description: Replaces the feature set. Omitted features are removed; an empty entitlements object removes every entitlement. A nonempty privilege map replaces the values for that feature; an empty feature map preserves its existing values. Pagination and expansions are rejected. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: replacePlanEntitlements
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EntitlementsUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlementsCollection'
        '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'
    patch:
      tags:
        - plan_entitlements
      summary: Update entitlements
      description: Merges the supplied feature and privilege values, preserving omitted entries. An empty entitlements object changes nothing. Pagination and expansions are rejected. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: updatePlanEntitlements
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EntitlementsUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlementsCollection'
        '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'
  /plans/{plan_code}/entitlements/{code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
      - name: code
        in: path
        required: true
        description: Feature code.
        schema:
          type: string
          description: Feature code.
          example: analytics
    get:
      tags:
        - plan_entitlements
      summary: Retrieve a plan entitlement
      description: Returns the plan entitlement. Pagination and expansions are rejected. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: findPlanEntitlement
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlement'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      tags:
        - plan_entitlements
      summary: Delete an entitlement
      description: Soft-deletes the plan entitlement and returns its previous values. Pagination and expansions are rejected. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: destroyPlanEntitlement
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlement'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /plans/{plan_code}/entitlements/{code}/privileges/{privilege_code}:
    parameters:
      - name: plan_code
        in: path
        required: true
        description: Catalog plan code.
        schema:
          type: string
          description: Catalog plan code.
          example: standard
      - name: code
        in: path
        required: true
        description: Feature code.
        schema:
          type: string
          description: Feature code.
          example: analytics
      - name: privilege_code
        in: path
        required: true
        description: Privilege code.
        schema:
          type: string
          description: Privilege code.
          example: seats
    delete:
      tags:
        - plan_entitlements
      summary: Delete an entitlement privilege
      description: Removes one privilege value and returns the entitlement with its remaining values. Pagination and expansions are rejected. Requires the product catalog to be enabled and plan read or write permission on the API key, according to the HTTP method.
      operationId: destroyPlanEntitlementPrivilege
      x-lago-cli-action: delete-privilege
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanEntitlement'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /contracts/{contract_external_id}/entitlements:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
    get:
      tags:
        - contract_entitlements
      summary: List all entitlements
      description: Returns all effective contract entitlements without pagination metadata. Pagination parameters are rejected on every entitlement action. Requires the product catalog to be enabled and contract read or write permission on the API key, according to the HTTP method.
      operationId: findAllContractEntitlements
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractEntitlementsCollection'
              example:
                entitlements:
                  - lago_contract_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
                    feature_code: analytics
                    source: plan
                    values:
                      - privilege_code: seats
                        value: 20
                        plan_value: 10
                        source: contract
        '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'
    patch:
      tags:
        - contract_entitlements
      summary: Update entitlements
      description: Merges the supplied feature and privilege values, preserving omitted entries. Only live contracts (draft, pending or active) can be edited. Values equal to the plan value remove the corresponding contract override. An empty entitlements object changes nothing. Pagination and expansions are rejected. Requires the product catalog to be enabled and contract read or write permission on the API key, according to the HTTP method.
      operationId: updateContractEntitlements
      requestBody:
        required: true
        description: Request payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EntitlementsUpdateInput'
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractEntitlementsCollection'
        '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'
  /contracts/{contract_external_id}/entitlements/{code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: code
        in: path
        required: true
        description: Feature code.
        schema:
          type: string
          description: Feature code.
          example: analytics
    delete:
      tags:
        - contract_entitlements
      summary: Delete an entitlement
      description: Removes the effective feature from the contract and returns the entitlement as it applied before removal. Only live contracts can be edited. Pagination and expansions are rejected. Requires the product catalog to be enabled and contract read or write permission on the API key, according to the HTTP method.
      operationId: destroyContractEntitlement
      x-lago-cli-action: delete
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractEntitlement'
        '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'
  /contracts/{contract_external_id}/entitlements/{code}/privileges/{privilege_code}:
    parameters:
      - name: contract_external_id
        in: path
        required: true
        description: External identifier of the contract.
        schema:
          type: string
          description: External identifier of the contract.
          example: contract_123
      - $ref: '#/components/parameters/contract_code'
      - name: code
        in: path
        required: true
        description: Feature code.
        schema:
          type: string
          description: Feature code.
          example: analytics
      - name: privilege_code
        in: path
        required: true
        description: Privilege code.
        schema:
          type: string
          description: Privilege code.
          example: seats
    delete:
      tags:
        - contract_entitlements
      summary: Delete an entitlement privilege
      description: Removes one privilege value and returns the entitlement with its remaining values. Only live contracts can be edited. Pagination and expansions are rejected. Requires the product catalog to be enabled and contract read or write permission on the API key, according to the HTTP method.
      operationId: destroyContractEntitlementPrivilege
      x-lago-cli-action: delete-privilege
      responses:
        '200':
          description: Successful response
          headers:
            X-Lago-Endpoint-Status:
              $ref: '#/components/headers/EndpointStatus'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContractEntitlement'
        '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:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  parameters:
    limit:
      name: limit
      in: query
      description: Maximum number of records per page. Values outside the supported range return 400.
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 100
        default: 20
        example: 20
    after:
      name: after
      in: query
      description: Opaque next_cursor from a previous response. Returns the next page. Cannot be combined with before or include_total_count=true. Keep the same filters when paging.
      required: false
      schema:
        type: string
        example: eyJ2IjoxLCJvIjp7InQiOiJ0YXhlcyIsInMiOiJjcmVhdGVkX2F0OmRlc2MsaWQ6ZGVzYyJ9LCJrIjpbIjIwMjItMDQtMjlUMDg6NTk6NTEuMDAwMDAwWiIsIjFhOTAxYTkwLTFhOTAtMWE5MC0xYTkwLTFhOTAxYTkwMWE5MCJdfQ
    before:
      name: before
      in: query
      description: Opaque prev_cursor from a previous response. Returns the previous page in the same list order. Cannot be combined with after or include_total_count=true. Keep the same filters when paging.
      required: false
      schema:
        type: string
        example: eyJ2IjoxLCJvIjp7InQiOiJ0YXhlcyIsInMiOiJjcmVhdGVkX2F0OmRlc2MsaWQ6ZGVzYyJ9LCJrIjpbIjIwMjItMDQtMjlUMDg6NTk6NTEuMDAwMDAwWiIsIjFhOTAxYTkwLTFhOTAtMWE5MC0xYTkwLTFhOTAxYTkwMWE5MCJdfQ
    include_total_count:
      name: include_total_count
      in: query
      description: Requests the total number of matching records. Supported only on the first page, without after or before. The count can be estimated; total_count_estimated is then present and true.
      required: false
      schema:
        type: boolean
        default: false
        example: true
    created_at_from:
      name: created_at_from
      in: query
      description: Inclusive lower bound on the creation time, as an ISO 8601 date or timestamp. A date starts at midnight UTC. Invalid values return 422.
      required: false
      schema:
        type: string
        example: '2022-04-01T00:00:00Z'
    created_at_to:
      name: created_at_to
      in: query
      description: Inclusive upper bound on the creation time, as an ISO 8601 date or timestamp. A date includes that whole UTC day. Invalid values return 422.
      required: false
      schema:
        type: string
        example: '2022-04-30T23:59:59Z'
    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:
    TaxObject:
      type: object
      required:
        - lago_id
        - name
        - code
        - rate
        - description
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          format: uuid
          description: Unique identifier of the tax, created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
        name:
          type: string
          description: Name of the tax.
          example: VAT
        code:
          type: string
          description: Unique code of the tax within the organization.
          example: standard_vat
        rate:
          type: number
          description: Percentage rate of the tax, returned as a JSON number.
          example: 20
        description:
          type:
            - string
            - 'null'
          description: Internal description of the tax.
          example: Standard VAT
        created_at:
          type: string
          format: date-time
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
        updated_at:
          type: string
          format: date-time
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T09:30:00.123456Z'
        deleted_at:
          type:
            - string
            - 'null'
          format: date-time
          description: UTC deletion timestamp, with microsecond precision. It is null until the tax is deleted.
          example: null
      example:
        lago_id: 1a901a90-1a90-1a90-1a90-1a901a901a90
        name: VAT
        code: standard_vat
        rate: 20
        description: Standard VAT
        created_at: '2022-04-29T08:59:51.123456Z'
        updated_at: '2022-04-29T09:30:00.123456Z'
        deleted_at: null
    CursorPaginationMeta:
      type: object
      required:
        - next_cursor
        - prev_cursor
      dependentRequired:
        total_count_estimated:
          - total_count
      properties:
        next_cursor:
          type:
            - string
            - 'null'
          description: Opaque cursor to pass as after for the next page. It is null when there is no next page.
          example: null
        prev_cursor:
          type:
            - string
            - 'null'
          description: Opaque cursor to pass as before for the previous page. It is null when there is no previous page.
          example: null
        total_count:
          type: integer
          minimum: 0
          description: Number of matching records, returned only when include_total_count is true on the first page. The count can be estimated.
          example: 42
        total_count_estimated:
          type: boolean
          enum:
            - true
          description: Present and true only when total_count is an estimate. Omitted for an exact count.
          example: true
    TaxesPaginated:
      type: object
      required:
        - taxes
        - meta
      properties:
        taxes:
          type: array
          description: Tax rates on the requested page.
          items:
            $ref: '#/components/schemas/TaxObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    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
    TaxBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          minLength: 1
          description: Name of the tax. It cannot be blank.
          example: VAT
        code:
          type: string
          minLength: 1
          description: Unique code of the tax within the organization, including deleted taxes. It cannot be blank.
          example: standard_vat
        rate:
          type:
            - number
            - string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          description: Percentage rate of the tax. Accepts a number or a decimal string.
          example: 20
        description:
          type:
            - string
            - 'null'
          description: Internal description of the tax. Set to null to clear it.
          example: Standard VAT
    TaxCreateInput:
      type: object
      required:
        - tax
      properties:
        tax:
          allOf:
            - $ref: '#/components/schemas/TaxBaseInput'
            - type: object
              required:
                - name
                - code
                - rate
    Tax:
      type: object
      required:
        - tax
      properties:
        tax:
          $ref: '#/components/schemas/TaxObject'
    TaxUpdateInput:
      type: object
      required:
        - tax
      properties:
        tax:
          $ref: '#/components/schemas/TaxBaseInput'
    ProductCategoryObject:
      type: object
      description: Product Category.
      required:
        - lago_id
        - name
        - code
        - description
        - invoice_display_name
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Invoice display name.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    ProductCategoriesPaginated:
      type: object
      description: product categories list.
      required:
        - product_categories
        - meta
      properties:
        product_categories:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ProductCategoryObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ProductCategoryBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name shown in the catalog.
          example: Compute
        code:
          type: string
          description: Unique code within the organization.
          example: example_code
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        description:
          type:
            - string
            - 'null'
          description: Internal description.
          example: Compute charges.
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Name used on invoices. Defaults to the name when blank.
          example: Compute
    ProductCategoryCreateInput:
      type: object
      description: Create product category.
      required:
        - product_category
      properties:
        product_category:
          allOf:
            - $ref: '#/components/schemas/ProductCategoryBaseInput'
            - type: object
              required:
                - name
                - code
    ProductCategory:
      type: object
      description: product category response.
      required:
        - product_category
      properties:
        product_category:
          $ref: '#/components/schemas/ProductCategoryObject'
    ProductCategoryUpdateInput:
      type: object
      description: Update product category.
      required:
        - product_category
      properties:
        product_category:
          $ref: '#/components/schemas/ProductCategoryBaseInput'
    BillableMetricObject:
      type: object
      description: Billable Metric.
      required:
        - lago_id
        - name
        - code
        - description
        - aggregation_type
        - weighted_interval
        - recurring
        - rounding_function
        - rounding_precision
        - field_name
        - expression
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        aggregation_type:
          type: string
          description: How event values are aggregated.
          example: count_agg
          enum:
            - count_agg
            - sum_agg
            - max_agg
            - unique_count_agg
            - weighted_sum_agg
            - latest_agg
        weighted_interval:
          type:
            - string
            - 'null'
          description: Weighting interval for weighted_sum_agg.
          example: seconds
          enum:
            - seconds
            - null
        recurring:
          type: boolean
          description: Recurring.
          example: false
        rounding_function:
          type:
            - string
            - 'null'
          description: Rounding applied to the aggregated quantity.
          example: round
          enum:
            - round
            - ceil
            - floor
            - null
        rounding_precision:
          type:
            - integer
            - 'null'
          description: Rounding precision.
          example: 1
        field_name:
          type:
            - string
            - 'null'
          description: Field name.
          example: example
        expression:
          type:
            - string
            - 'null'
          description: Expression.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    ProductObject:
      type: object
      description: Product.
      required:
        - lago_id
        - name
        - code
        - description
        - invoice_display_name
        - created_at
        - updated_at
        - deleted_at
        - product_category_code
        - billable_metric_code
        - product_type
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: Example
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Invoice display name.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        product_category_code:
          type:
            - string
            - 'null'
          description: Code of the category, or null for an uncategorized product.
          example: compute
        billable_metric_code:
          type:
            - string
            - 'null'
          description: Code of the billable metric. Required for metered products and absent for fixed products.
          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
        product_category:
          anyOf:
            - $ref: '#/components/schemas/ProductCategoryObject'
            - type: 'null'
          description: Present only with expands[]=product_category on retrieval.
        billable_metric:
          anyOf:
            - $ref: '#/components/schemas/BillableMetricObject'
            - type: 'null'
          description: Present only with expands[]=billable_metric on retrieval.
    ProductsPaginated:
      type: object
      description: products list.
      required:
        - products
        - meta
      properties:
        products:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ProductObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ProductBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name shown in the catalog.
          example: Compute
        code:
          type: string
          description: Unique code within the organization.
          example: example_code
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        description:
          type:
            - string
            - 'null'
          description: Internal description.
          example: Compute charges.
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Name used on invoices. Defaults to the name when blank.
          example: Compute
        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
        product_category_code:
          type:
            - string
            - 'null'
          description: Category code. Omit or clear it to leave the product uncategorized.
          example: compute
        billable_metric_code:
          type: string
          description: Billable metric code. Required for metered products and not allowed for fixed products.
          example: api_requests
    ProductCreateInput:
      type: object
      description: Create product.
      required:
        - product
      properties:
        product:
          allOf:
            - $ref: '#/components/schemas/ProductBaseInput'
            - type: object
              required:
                - name
                - code
                - product_type
    Product:
      type: object
      description: product response.
      required:
        - product
      properties:
        product:
          $ref: '#/components/schemas/ProductObject'
    ProductUpdateInput:
      type: object
      description: Update a product.
      required:
        - product
      properties:
        product:
          type: object
          minProperties: 1
          properties:
            name:
              type: string
              description: Name shown in the catalog.
              example: Compute
            code:
              type: string
              description: Unique code within the organization.
              example: example_code
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            description:
              type:
                - string
                - 'null'
              description: Internal description.
              example: Compute charges.
            invoice_display_name:
              type:
                - string
                - 'null'
              description: Name used on invoices. Defaults to the name when blank.
              example: Compute
            product_category_code:
              type:
                - string
                - 'null'
              description: Category code. Null or an empty string removes the category.
              example: compute
    ProductFilterValueObject:
      type: object
      description: A value matched against a filter key defined by the product billable metric.
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: Billable metric filter key.
          example: region
        value:
          type:
            - string
            - 'null'
          description: Value to match. Null or an omitted value selects all configured values for this key.
          example: eu
    ProductFilterObject:
      type: object
      description: Product Filter.
      required:
        - lago_id
        - name
        - code
        - description
        - invoice_display_name
        - created_at
        - updated_at
        - deleted_at
        - product_code
        - product_category_code
        - values
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Invoice display name.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        product_code:
          type: string
          description: Code of the parent product.
          example: api_requests
        product_category_code:
          type:
            - string
            - 'null'
          description: Code of the product category.
          example: compute
        values:
          type: array
          description: Filter key and value matches. An empty list is returned after deletion.
          items:
            $ref: '#/components/schemas/ProductFilterValueObject'
    ProductFiltersPaginated:
      type: object
      description: filters list.
      required:
        - filters
        - meta
      properties:
        filters:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ProductFilterObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ProductFilterValueInput:
      type: object
      description: A value matched against a filter key defined by the product billable metric.
      required:
        - key
      properties:
        key:
          type: string
          description: Billable metric filter key.
          example: region
        value:
          type:
            - string
            - 'null'
          description: Value to match. Null or an omitted value selects all configured values for this key.
          example: eu
    ProductFilterBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name shown in the catalog.
          example: Compute
        code:
          type: string
          description: Unique code within the organization.
          example: example_code
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        description:
          type:
            - string
            - 'null'
          description: Internal description.
          example: Compute charges.
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Name used on invoices. Defaults to the name when blank.
          example: Compute
        values:
          type: array
          description: Matches against keys of the product billable metric. Cannot be empty.
          items:
            $ref: '#/components/schemas/ProductFilterValueInput'
          minItems: 1
    ProductFilterCreateInput:
      type: object
      description: Create filter.
      required:
        - filter
      properties:
        filter:
          allOf:
            - $ref: '#/components/schemas/ProductFilterBaseInput'
            - type: object
              required:
                - name
                - code
                - values
    ProductFilter:
      type: object
      description: filter response.
      required:
        - filter
      properties:
        filter:
          $ref: '#/components/schemas/ProductFilterObject'
    ProductFilterUpdateInput:
      type: object
      description: Update filter.
      required:
        - filter
      properties:
        filter:
          $ref: '#/components/schemas/ProductFilterBaseInput'
    RateTierObject:
      type: object
      description: Pricing tier. Its lower bound is the preceding upper bound; from_value is not returned.
      required:
        - to_value
      properties:
        to_value:
          type:
            - string
            - 'null'
          description: Upper bound of this tier, sent as a decimal string. Null marks the final, open-ended tier.
          example: null
        flat_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_unit_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        rate:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
    RatePropertiesObject:
      type: object
      description: Pricing configuration for the selected rate model. Standard requires amount; package also requires package_size. Graduated, volume and graduated_percentage models use their matching ranges array. Custom properties remain model-specific.
      not:
        required:
          - pricing_group_keys
        properties:
          pricing_group_keys: {}
      properties:
        amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        free_units:
          type: integer
          description: Free units per billing period.
          example: 0
        package_size:
          type: integer
          description: Units in one package.
          example: 100
        rate:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        fixed_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        free_units_per_events:
          type:
            - integer
            - 'null'
          description: Number of free transactions.
          example: 0
        free_units_per_total_aggregation:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_transaction_min_amount:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_transaction_max_amount:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        graduated_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierObject'
        volume_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierObject'
        graduated_percentage_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierObject'
      additionalProperties: true
    RateCardRateObject:
      type: object
      description: Rate Card Rate.
      required:
        - lago_id
        - code
        - rate_card_code
        - status
        - rate_model
        - rate_properties
        - min_amount_cents
        - billing_interval_count
        - billing_interval_unit
        - applied_pricing_unit_conversion_rate
        - effective_from
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        code:
          type: string
          description: Code.
          example: example
        rate_card_code:
          type:
            - string
            - 'null'
          description: Code of the parent rate card.
          example: compute_usd
        status:
          type: string
          description: Status derived from the effective-dated rate timeline.
          example: pending
          enum:
            - pending
            - active
            - terminated
        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:
          $ref: '#/components/schemas/RatePropertiesObject'
        min_amount_cents:
          type: integer
          description: Minimum amount, in cents.
          example: 100
        billing_interval_count:
          type: integer
          description: Billing interval count.
          example: 1
        billing_interval_unit:
          type: string
          description: Unit of the billing interval.
          example: day
          enum:
            - day
            - week
            - month
            - year
        applied_pricing_unit_conversion_rate:
          type:
            - string
            - 'null'
          description: Applied pricing unit conversion rate. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        effective_from:
          type: string
          description: Effective from.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    RateCardObject:
      type: object
      description: Rate Card.
      required:
        - lago_id
        - name
        - code
        - description
        - created_at
        - updated_at
        - deleted_at
        - product_code
        - product_filter_code
        - currency
        - billing_timing
        - proration
        - display_on_invoice
        - regroup_paid_fees
        - applied_pricing_unit_code
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        product_code:
          type: string
          description: Code of the priced product.
          example: api_requests
        product_filter_code:
          type:
            - string
            - 'null'
          description: Code of the priced filter, or null for the product default.
          example: eu
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        billing_timing:
          type: string
          description: When fees are billed.
          example: arrears
          enum:
            - arrears
            - advance
        proration:
          type: boolean
          description: Proration.
          example: false
        display_on_invoice:
          type: boolean
          description: Display on invoice.
          example: false
        regroup_paid_fees:
          type:
            - string
            - 'null'
          description: Whether paid advance fees are regrouped into an invoice. Null keeps fees standalone.
          example: invoice
          enum:
            - invoice
            - null
        applied_pricing_unit_code:
          type:
            - string
            - 'null'
          description: Applied pricing unit code.
          example: example
        active_rate:
          anyOf:
            - $ref: '#/components/schemas/RateCardRateObject'
            - type: 'null'
          description: Present only with expands[]=active_rate. Null until a rate becomes effective.
        rates:
          type: array
          description: Present only with expands[]=rates. Sorted by effective_from, newest first.
          items:
            $ref: '#/components/schemas/RateCardRateObject'
        taxes:
          type: array
          description: Present only with expands[]=taxes.
          items:
            $ref: '#/components/schemas/TaxObject'
        product:
          $ref: '#/components/schemas/ProductObject'
          description: Present only with expands[]=product.
        product_filter:
          anyOf:
            - $ref: '#/components/schemas/ProductFilterObject'
            - type: 'null'
          description: Present only with expands[]=product_filter.
    RateCardsPaginated:
      type: object
      description: rate cards list.
      required:
        - rate_cards
        - meta
      properties:
        rate_cards:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/RateCardObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    RateTierInput:
      type: object
      description: Pricing tier. Upper bounds must increase and the final tier must have a null upper bound. Do not send from_value.
      not:
        required:
          - from_value
        properties:
          from_value: {}
      properties:
        to_value:
          type:
            - string
            - number
            - 'null'
          description: Upper bound of this tier, sent as a decimal string. Null marks the final, open-ended tier.
          example: null
        flat_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_unit_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        rate:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
    RatePropertiesInput:
      type: object
      description: Pricing configuration for the selected rate model. Standard requires amount; package also requires package_size. Graduated, volume and graduated_percentage models use their matching ranges array. Custom properties remain model-specific.
      not:
        required:
          - pricing_group_keys
        properties:
          pricing_group_keys: {}
      properties:
        amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        free_units:
          type: integer
          description: Free units per billing period.
          example: 0
        package_size:
          type: integer
          description: Units in one package.
          example: 100
        rate:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        fixed_amount:
          type:
            - number
            - string
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        free_units_per_events:
          type:
            - integer
            - 'null'
          description: Number of free transactions.
          example: 0
        free_units_per_total_aggregation:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_transaction_min_amount:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        per_transaction_max_amount:
          type:
            - number
            - string
            - 'null'
          description: Amount, as a number or decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        graduated_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierInput'
        volume_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierInput'
        graduated_percentage_ranges:
          type: array
          description: Ordered pricing tiers. The final tier is open-ended.
          items:
            $ref: '#/components/schemas/RateTierInput'
      additionalProperties: true
    RateCardRateBaseInput:
      type: object
      minProperties: 1
      properties:
        code:
          type: string
          description: Code unique within the rate card.
          example: standard_2030
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        effective_from:
          type: string
          description: Effective timestamp. It cannot be before today in the organization timezone, must be unique on the card, and must be after the active rate. Arrears rates start at the beginning of the day.
          example: '2030-01-01T00:00:00Z'
          format: date-time
        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:
          $ref: '#/components/schemas/RatePropertiesInput'
        min_amount_cents:
          type: integer
          description: Minimum charge in cents. Allowed only for arrears billing. Defaults to 0 on creation.
          example: 0
          minimum: 0
        billing_interval_count:
          type: integer
          description: Number of billing interval units. Defaults to 1 on creation.
          example: 1
          minimum: 1
        billing_interval_unit:
          type: string
          description: Unit of the billing interval.
          example: day
          enum:
            - day
            - week
            - month
            - year
        applied_pricing_unit_conversion_rate:
          type:
            - string
            - 'null'
          description: Conversion rate for the applied pricing unit. Required when the card uses a pricing unit. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
    RateCardBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name shown in the catalog.
          example: Compute
        code:
          type: string
          description: Unique code within the organization.
          example: example_code
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        description:
          type:
            - string
            - 'null'
          description: Internal description.
          example: Compute charges.
        currency:
          type: string
          description: ISO 4217 billing currency.
          example: USD
          pattern: ^[A-Z]{3}$
        billing_timing:
          type: string
          description: When fees are billed.
          example: arrears
          enum:
            - arrears
            - advance
          default: arrears
        proration:
          type: boolean
          description: Whether charges are prorated.
          example: false
          default: false
        display_on_invoice:
          type: boolean
          description: Whether generated fees are shown on invoices.
          example: true
          default: true
        regroup_paid_fees:
          type:
            - string
            - 'null'
          description: Only for hidden advance fees. Null keeps paid fees standalone.
          example: invoice
          enum:
            - invoice
            - null
        applied_pricing_unit_code:
          type:
            - string
            - 'null'
          description: Pricing unit code, or null for currency pricing.
          example: tokens
        tax_codes:
          type: array
          description: Tax codes to assign. An empty array clears the assignments.
          items:
            type: string
            description: Tax code.
            example: standard_vat
        product_code:
          type: string
          description: Code of the product being priced.
          example: api_requests
        product_filter_code:
          type:
            - string
            - 'null'
          description: Filter code belonging to this product.
          example: eu
        rates:
          type: array
          description: Initial effective-dated rates. A failure rolls back the card and its rates.
          items:
            allOf:
              - $ref: '#/components/schemas/RateCardRateBaseInput'
              - type: object
                required:
                  - code
                  - effective_from
                  - rate_model
                  - billing_interval_unit
    RateCardCreateInput:
      type: object
      description: Create rate card.
      required:
        - rate_card
      properties:
        rate_card:
          allOf:
            - $ref: '#/components/schemas/RateCardBaseInput'
            - type: object
              required:
                - name
                - code
                - currency
                - product_code
    RateCard:
      type: object
      description: rate card response.
      required:
        - rate_card
      properties:
        rate_card:
          $ref: '#/components/schemas/RateCardObject'
    RateCardUpdateInput:
      type: object
      description: Update a rate card.
      required:
        - rate_card
      properties:
        rate_card:
          type: object
          minProperties: 1
          properties:
            name:
              type: string
              description: Name shown in the catalog.
              example: Compute
            code:
              type: string
              description: Unique code within the organization.
              example: example_code
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            description:
              type:
                - string
                - 'null'
              description: Internal description.
              example: Compute charges.
            currency:
              type: string
              description: ISO 4217 billing currency.
              example: USD
              pattern: ^[A-Z]{3}$
            billing_timing:
              type: string
              description: When fees are billed.
              example: arrears
              enum:
                - arrears
                - advance
            proration:
              type: boolean
              description: Whether charges are prorated.
              example: false
            display_on_invoice:
              type: boolean
              description: Whether generated fees are shown on invoices.
              example: true
            regroup_paid_fees:
              type:
                - string
                - 'null'
              description: Only for hidden advance fees. Null keeps paid fees standalone.
              example: invoice
              enum:
                - invoice
                - null
            applied_pricing_unit_code:
              type:
                - string
                - 'null'
              description: Pricing unit code, or null for currency pricing.
              example: tokens
            tax_codes:
              type: array
              description: Tax codes to assign. An empty array clears the assignments.
              items:
                type: string
                description: Tax code.
                example: standard_vat
    RateCardRatesCollection:
      type: object
      description: rates list.
      required:
        - rates
      properties:
        rates:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/RateCardRateObject'
    RateCardRateCreateInput:
      type: object
      description: Create rate.
      required:
        - rate
      properties:
        rate:
          allOf:
            - $ref: '#/components/schemas/RateCardRateBaseInput'
            - type: object
              required:
                - code
                - effective_from
                - rate_model
                - billing_interval_unit
    RateCardRate:
      type: object
      description: rate response.
      required:
        - rate
      properties:
        rate:
          $ref: '#/components/schemas/RateCardRateObject'
    RateCardRateUpdateInput:
      type: object
      description: Update rate.
      required:
        - rate
      properties:
        rate:
          $ref: '#/components/schemas/RateCardRateBaseInput'
    CatalogPlanObject:
      type: object
      description: Catalog Plan.
      required:
        - lago_id
        - name
        - code
        - description
        - invoice_display_name
        - currency
        - created_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Invoice display name.
          example: example
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        taxes:
          type: array
          description: Present only with expands[]=taxes on retrieval.
          items:
            $ref: '#/components/schemas/TaxObject'
    CatalogPlansPaginated:
      type: object
      description: plans list.
      required:
        - plans
        - meta
      properties:
        plans:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/CatalogPlanObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    CatalogPlanBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name shown in the catalog.
          example: Compute
        code:
          type: string
          description: Unique code within the organization.
          example: example_code
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        description:
          type:
            - string
            - 'null'
          description: Internal description.
          example: Compute charges.
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Name used on invoices. Defaults to the name when blank.
          example: Compute
        currency:
          type: string
          description: ISO 4217 billing currency.
          example: USD
          pattern: ^[A-Z]{3}$
        tax_codes:
          type: array
          description: Tax codes to assign. An empty array clears the assignments.
          items:
            type: string
            description: Tax code.
            example: standard_vat
    CatalogPlanCreateInput:
      type: object
      description: Create plan.
      required:
        - plan
      properties:
        plan:
          allOf:
            - $ref: '#/components/schemas/CatalogPlanBaseInput'
            - type: object
              required:
                - name
                - code
                - currency
    CatalogPlan:
      type: object
      description: plan response.
      required:
        - plan
      properties:
        plan:
          $ref: '#/components/schemas/CatalogPlanObject'
    CatalogPlanUpdateInput:
      type: object
      description: Update plan.
      required:
        - plan
      properties:
        plan:
          $ref: '#/components/schemas/CatalogPlanBaseInput'
    PlanAppliedRateCardObject:
      type: object
      description: Plan Applied Rate Card.
      required:
        - lago_id
        - plan_code
        - rate_card_code
        - product_code
        - product_filter_code
        - units
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        plan_code:
          type: string
          description: Code of the plan.
          example: standard
        rate_card_code:
          type: string
          description: Code of the applied rate card.
          example: compute_usd
        product_code:
          type: string
          description: Code of the product priced by the applied rate card.
          example: api_requests
        product_filter_code:
          type:
            - string
            - 'null'
          description: Code of the product filter priced by the applied rate card, or null for the product default.
          example: eu
        units:
          type:
            - string
            - 'null'
          description: Quantity. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    PlanAppliedRateCardsPaginated:
      type: object
      description: applied rate cards list.
      required:
        - applied_rate_cards
        - meta
      properties:
        applied_rate_cards:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PlanAppliedRateCardObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    RateOverrideInput:
      type: object
      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:
          $ref: '#/components/schemas/RatePropertiesInput'
        min_amount_cents:
          type: integer
          description: Minimum charge in cents. Allowed only for arrears billing.
          example: 0
          minimum: 0
          default: 0
        billing_interval_count:
          type:
            - integer
            - 'null'
          description: Number of billing interval units. Omit or set to null to inherit the rate interval count.
          example: 1
          minimum: 1
        billing_interval_unit:
          type:
            - string
            - 'null'
          description: Unit of the billing interval.
          example: day
          enum:
            - day
            - week
            - month
            - year
            - null
        pricing_unit_conversion_rate:
          type:
            - string
            - 'null'
          description: Conversion rate. Required when the rate card uses a pricing unit. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
      required:
        - rate_model
      description: A complete pricing override. Structural fields such as currency, billing timing and proration cannot be overridden.
    RatePhaseBaseInput:
      type: object
      minProperties: 1
      properties:
        code:
          type: string
          description: Code unique within the applied rate card.
          example: introductory
          pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
        position:
          type: integer
          description: One-based sequence position.
          example: 1
          minimum: 1
        name:
          type:
            - string
            - 'null'
          description: Name of the phase.
          example: Introductory period
        billing_interval_cycle_count:
          type:
            - integer
            - 'null'
          description: Number of billing cycles. Only the final phase is indefinite, represented by null.
          example: 1
          minimum: 1
        rate_override:
          description: Pricing override. On update, null removes the existing override.
          anyOf:
            - $ref: '#/components/schemas/RateOverrideInput'
            - type: 'null'
    PlanAppliedRateCardBaseInput:
      type: object
      minProperties: 1
      properties:
        rate_card_code:
          type: string
          description: Code of the rate card to attach.
          example: compute_usd
        units:
          type:
            - string
            - 'null'
          description: Quantity for fixed pricing. Null uses the default quantity. Sent as a decimal string.
          example: '1.5'
          pattern: ^[0-9]+(\.[0-9]+)?$
        rate_phases:
          type:
            - array
            - 'null'
          description: Complete phase sequence with positions exactly 1 through the number of phases. Omitted or null creates one default indefinite phase. An explicit empty list is rejected.
          items:
            allOf:
              - $ref: '#/components/schemas/RatePhaseBaseInput'
              - type: object
                required:
                  - code
                  - position
          minItems: 1
    PlanAppliedRateCardCreateInput:
      type: object
      description: Create applied rate card.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          allOf:
            - $ref: '#/components/schemas/PlanAppliedRateCardBaseInput'
            - type: object
              required:
                - rate_card_code
    PlanAppliedRateCard:
      type: object
      description: applied rate card response.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          $ref: '#/components/schemas/PlanAppliedRateCardObject'
    PlanAppliedRateCardUpdateInput:
      type: object
      description: Update an applied rate card.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          type: object
          minProperties: 1
          properties:
            units:
              type:
                - string
                - 'null'
              description: Quantity for fixed pricing. Null uses the default quantity. Sent as a decimal string.
              example: '1.5'
              pattern: ^[0-9]+(\.[0-9]+)?$
    RateOverrideObject:
      type: object
      description: Rate Override.
      required:
        - lago_id
        - rate_model
        - rate_properties
        - min_amount_cents
        - billing_interval_count
        - billing_interval_unit
        - pricing_unit_conversion_rate
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        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:
          $ref: '#/components/schemas/RatePropertiesObject'
        min_amount_cents:
          type: integer
          description: Minimum amount, in cents.
          example: 100
        billing_interval_count:
          type:
            - integer
            - 'null'
          description: Billing interval count.
          example: 1
        billing_interval_unit:
          type:
            - string
            - 'null'
          description: Unit of the billing interval.
          example: day
          enum:
            - day
            - week
            - month
            - year
            - null
        pricing_unit_conversion_rate:
          type:
            - string
            - 'null'
          description: Pricing unit conversion rate. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    RatePhaseObject:
      type: object
      description: Rate Phase.
      required:
        - lago_id
        - code
        - position
        - name
        - billing_interval_cycle_count
        - rate_override
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        code:
          type: string
          description: Code.
          example: example
        position:
          type: integer
          description: Position.
          example: 1
        name:
          type:
            - string
            - 'null'
          description: Name.
          example: example
        billing_interval_cycle_count:
          type:
            - integer
            - 'null'
          description: Billing interval cycle count.
          example: 1
        rate_override:
          anyOf:
            - $ref: '#/components/schemas/RateOverrideObject'
            - type: 'null'
          description: Pricing override, or null to use the effective rate card rate.
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    PlanRatePhasesCollection:
      type: object
      description: rate phases list.
      required:
        - rate_phases
      properties:
        rate_phases:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/RatePhaseObject'
    RatePhaseCreateInput:
      type: object
      description: Create rate phase.
      required:
        - rate_phase
      properties:
        rate_phase:
          description: Single phase to insert. If position is omitted, a finite phase is inserted before the final indefinite phase; otherwise it is appended.
          allOf:
            - $ref: '#/components/schemas/RatePhaseBaseInput'
            - type: object
              required:
                - code
    PlanRatePhase:
      type: object
      description: rate phase response.
      required:
        - rate_phase
      properties:
        rate_phase:
          $ref: '#/components/schemas/RatePhaseObject'
    RatePhaseUpdateInput:
      type: object
      description: Update rate phase.
      required:
        - rate_phase
      properties:
        rate_phase:
          $ref: '#/components/schemas/RatePhaseBaseInput'
    ContractAppliedRateCardObject:
      type: object
      description: Contract Applied Rate Card.
      required:
        - lago_id
        - external_contract_id
        - rate_card_code
        - product_code
        - product_filter_code
        - units
        - effective_date
        - billing_anchor_date
        - next_billing_at
        - created_at
        - updated_at
        - deleted_at
        - billing_scope
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_contract_id:
          type: string
          description: External identifier of the contract.
          example: contract_123
        rate_card_code:
          type: string
          description: Code of the applied rate card.
          example: compute_usd
        product_code:
          type: string
          description: Code of the product priced by the applied rate card.
          example: api_requests
        product_filter_code:
          type:
            - string
            - 'null'
          description: Code of the product filter priced by the applied rate card, or null for the product default.
          example: eu
        units:
          type:
            - string
            - 'null'
          description: Quantity. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        effective_date:
          type: string
          description: Effective date.
          example: '2022-04-29'
          format: date
        billing_anchor_date:
          type: string
          description: Billing anchor date.
          example: '2022-04-29'
          format: date
        next_billing_at:
          type:
            - string
            - 'null'
          description: Next billing at.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        billing_scope:
          type: string
          description: Groups priced segments within a billing cycle or bills each segment separately. Defaults to cycle.
          example: cycle
          enum:
            - cycle
            - segment
    ContractAppliedRateCardsPaginated:
      type: object
      description: applied rate cards list.
      required:
        - applied_rate_cards
        - meta
      properties:
        applied_rate_cards:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractAppliedRateCardObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ContractAppliedRateCardBaseInput:
      type: object
      minProperties: 1
      properties:
        rate_card_code:
          type: string
          description: Code of the rate card to attach.
          example: compute_usd
        units:
          type:
            - string
            - 'null'
          description: Quantity for fixed pricing. Null uses the default quantity. Sent as a decimal string.
          example: '1.5'
          pattern: ^[0-9]+(\.[0-9]+)?$
        rate_phases:
          type:
            - array
            - 'null'
          description: Complete phase sequence with positions exactly 1 through the number of phases. Omitted or null creates one default indefinite phase. An explicit empty list is rejected.
          items:
            allOf:
              - $ref: '#/components/schemas/RatePhaseBaseInput'
              - type: object
                required:
                  - code
                  - position
          minItems: 1
        billing_anchor_date:
          type:
            - string
            - 'null'
          description: Billing anchor for this applied card. Defaults to the contract anchor.
          example: null
          format: date
        billing_scope:
          type: string
          description: Groups priced segments within a billing cycle or bills each segment separately. Defaults to cycle.
          example: cycle
          enum:
            - cycle
            - segment
          default: cycle
    ContractAppliedRateCardCreateInput:
      type: object
      description: Create applied rate card.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          allOf:
            - $ref: '#/components/schemas/ContractAppliedRateCardBaseInput'
            - type: object
              required:
                - rate_card_code
    ContractAppliedRateCard:
      type: object
      description: applied rate card response.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          $ref: '#/components/schemas/ContractAppliedRateCardObject'
    ContractAppliedRateCardUpdateInput:
      type: object
      description: Update an applied rate card.
      required:
        - applied_rate_card
      properties:
        applied_rate_card:
          type: object
          minProperties: 1
          properties:
            units:
              type:
                - string
                - 'null'
              description: Quantity for fixed pricing. Null uses the default quantity. Sent as a decimal string.
              example: '1.5'
              pattern: ^[0-9]+(\.[0-9]+)?$
            billing_anchor_date:
              type: string
              description: Billing anchor for this applied card. Null is rejected. Omit the field to keep the current anchor.
              example: '2022-04-29'
              format: date
            billing_scope:
              type: string
              description: Groups priced segments within a billing cycle or bills each segment separately. Omit the field to keep the current scope.
              example: cycle
              enum:
                - cycle
                - segment
    ContractRatePhasesCollection:
      type: object
      description: rate phases list.
      required:
        - rate_phases
      properties:
        rate_phases:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/RatePhaseObject'
    ContractRatePhase:
      type: object
      description: rate phase response.
      required:
        - rate_phase
      properties:
        rate_phase:
          $ref: '#/components/schemas/RatePhaseObject'
    CustomerObject:
      type: object
      description: Customer.
      required:
        - lago_id
        - billing_entity_code
        - external_id
        - account_type
        - name
        - firstname
        - lastname
        - customer_type
        - sequential_id
        - slug
        - country
        - address_line1
        - address_line2
        - state
        - zipcode
        - email
        - city
        - url
        - phone
        - logo_url
        - legal_name
        - legal_number
        - currency
        - tax_identification_number
        - timezone
        - applicable_timezone
        - external_salesforce_id
        - finalize_zero_amount_invoice
        - skip_invoice_custom_sections
        - invoice_grace_period
        - periodic_invoice_issuing_date_anchor
        - periodic_invoice_issuing_date_adjustment
        - payment_provider
        - payment_provider_code
        - provider_customer_id
        - provider_payment_methods
        - document_locale
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        billing_entity_code:
          type: string
          description: Code of the customer billing entity.
          example: main
        external_id:
          type: string
          description: Unique customer identifier in your application.
          example: customer_123
        account_type:
          type: string
          description: Account type.
          example: customer
          enum:
            - customer
            - partner
        name:
          type:
            - string
            - 'null'
          description: Name.
          example: example
        firstname:
          type:
            - string
            - 'null'
          description: Firstname.
          example: example
        lastname:
          type:
            - string
            - 'null'
          description: Lastname.
          example: example
        customer_type:
          type:
            - string
            - 'null'
          description: Type of customer.
          example: company
          enum:
            - company
            - individual
            - null
        sequential_id:
          type:
            - integer
            - 'null'
          description: Sequential id.
          example: 100
        slug:
          type:
            - string
            - 'null'
          description: Slug.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: example
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        url:
          type:
            - string
            - 'null'
          description: Url.
          example: example
        phone:
          type:
            - string
            - 'null'
          description: Phone.
          example: example
        logo_url:
          type:
            - string
            - 'null'
          description: Logo url.
          example: example
        legal_name:
          type:
            - string
            - 'null'
          description: Legal name.
          example: example
        legal_number:
          type:
            - string
            - 'null'
          description: Legal number.
          example: example
        currency:
          type:
            - string
            - 'null'
          description: Currency as an ISO 4217 code.
          example: USD
        tax_identification_number:
          type:
            - string
            - 'null'
          description: Tax identification number.
          example: example
        timezone:
          type:
            - string
            - 'null'
          description: Timezone.
          example: example
        applicable_timezone:
          type: string
          description: Timezone used for customer billing.
          example: Europe/Paris
        external_salesforce_id:
          type:
            - string
            - 'null'
          description: External salesforce id.
          example: example
        finalize_zero_amount_invoice:
          type: string
          description: Whether invoices with a zero amount are finalized.
          example: inherit
          enum:
            - inherit
            - skip
            - finalize
        skip_invoice_custom_sections:
          type: boolean
          description: Skip invoice custom sections.
          example: false
        invoice_grace_period:
          type:
            - integer
            - 'null'
          description: Invoice grace period.
          example: 1
        periodic_invoice_issuing_date_anchor:
          type:
            - string
            - 'null'
          description: Anchor used to determine the issuing date of periodic invoices.
          example: current_period_end
        periodic_invoice_issuing_date_adjustment:
          type:
            - string
            - 'null'
          description: Adjustment applied to the periodic invoice issuing date.
          example: keep_anchor
        payment_provider:
          type:
            - string
            - 'null'
          description: Payment provider.
          example: example
        payment_provider_code:
          type:
            - string
            - 'null'
          description: Payment provider code.
          example: example
        provider_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier in the payment provider.
          example: cus_example
        provider_payment_methods:
          type:
            - array
            - 'null'
          description: Payment methods allowed by the provider.
          items:
            type: string
            description: Payment method type.
            example: card
        document_locale:
          type:
            - string
            - 'null'
          description: Document locale.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        x402_agent_address:
          type:
            - string
            - 'null'
          description: Agent address. Present only when x402 payments are enabled.
          example: '0x0000000000000000000000000000000000000000'
    InvoiceCustomSectionObject:
      type: object
      description: Invoice Custom Section.
      required:
        - lago_id
        - code
        - name
        - description
        - details
        - display_name
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        code:
          type: string
          description: Code.
          example: example
        name:
          type: string
          description: Name.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        details:
          type:
            - string
            - 'null'
          description: Details.
          example: example
        display_name:
          type:
            - string
            - 'null'
          description: Display name.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    ContractObject:
      type: object
      description: Contract.
      required:
        - lago_id
        - external_id
        - code
        - lago_customer_id
        - external_customer_id
        - name
        - plan_code
        - status
        - consolidate_invoice
        - purchase_order_number
        - billing_anchor_date
        - effective_billing_anchor_date
        - skip_invoice_custom_sections
        - started_at
        - ended_at
        - terminated_at
        - canceled_at
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_id:
          type: string
          description: External id.
          example: example
        code:
          type:
            - string
            - 'null'
          description: Immutable contract code. Null for existing contracts created without a code.
          example: initial
        lago_customer_id:
          type: string
          description: Customer identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        name:
          type:
            - string
            - 'null'
          description: Name.
          example: example
        plan_code:
          type:
            - string
            - 'null'
          description: Optional plan code. Plan-less contracts use directly attached rate cards.
          example: standard
        status:
          type: string
          description: Lifecycle status. A draft never bills until it is published.
          example: pending
          enum:
            - draft
            - pending
            - active
            - terminated
            - canceled
        consolidate_invoice:
          type: boolean
          description: Consolidate invoice.
          example: false
        purchase_order_number:
          type:
            - string
            - 'null'
          description: Purchase order number.
          example: example
        billing_anchor_date:
          type:
            - string
            - 'null'
          description: Optional billing anchor.
          example: null
          format: date
        effective_billing_anchor_date:
          type:
            - string
            - 'null'
          description: Resolved billing anchor.
          example: null
          format: date
        skip_invoice_custom_sections:
          type: boolean
          description: Skip invoice custom sections.
          example: false
        started_at:
          type:
            - string
            - 'null'
          description: Started at.
          example: null
          format: date-time
        ended_at:
          type:
            - string
            - 'null'
          description: Ended at.
          example: null
          format: date-time
        terminated_at:
          type:
            - string
            - 'null'
          description: Terminated at.
          example: null
          format: date-time
        canceled_at:
          type:
            - string
            - 'null'
          description: Canceled at.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        applied_rate_cards:
          type: array
          description: Present only with expands[]=applied_rate_cards.
          items:
            $ref: '#/components/schemas/ContractAppliedRateCardObject'
        plan:
          anyOf:
            - $ref: '#/components/schemas/CatalogPlanObject'
            - type: 'null'
          description: Present only with expands[]=plan.
        customer:
          $ref: '#/components/schemas/CustomerObject'
          description: Present only with expands[]=customer.
        invoice_custom_sections:
          type: array
          description: Present only with expands[]=invoice_custom_sections.
          items:
            $ref: '#/components/schemas/InvoiceCustomSectionObject'
    ContractsPaginated:
      type: object
      description: contracts list.
      required:
        - contracts
        - meta
      properties:
        contracts:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ContractBaseInput:
      type: object
      minProperties: 1
      properties:
        external_id:
          type: string
          description: Unique identifier for a live contract in your application.
          example: contract_123
        code:
          type: string
          minLength: 1
          description: Immutable contract code. Must be unique for this external ID within the organization, including canceled and terminated contracts.
          example: initial
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        name:
          type:
            - string
            - 'null'
          description: Contract name.
          example: Annual agreement
        plan_code:
          type:
            - string
            - 'null'
          description: Optional plan code. Plan-less contracts use directly attached rate cards.
          example: standard
        status:
          type:
            - string
            - 'null'
          description: Set to draft to prepare the contract without billing it, whatever its start date, until it is published. Omitted or null, the start date decides between pending and active. Any other value answers 422 value_is_invalid. Requires Lago v1.58.0 or later; older servers ignore it and create a contract that bills.
          example: draft
          enum:
            - draft
            - null
        billing_anchor_date:
          type:
            - string
            - 'null'
          description: Optional billing anchor.
          example: null
          format: date
        started_at:
          type:
            - string
            - 'null'
          description: Start timestamp. Defaults to now. A future start creates a pending contract. Required for a draft (422 value_is_mandatory otherwise).
          example: null
          format: date-time
        ended_at:
          type:
            - string
            - 'null'
          description: Optional end timestamp. Must be after the start and not already in the past.
          example: null
          format: date-time
        consolidate_invoice:
          type: boolean
          description: Whether invoices can consolidate compatible contracts.
          example: true
        purchase_order_number:
          type:
            - string
            - 'null'
          description: Purchase order reference.
          example: PO-123
        invoice_custom_section:
          type: object
          description: Invoice section selection.
          required: []
          properties:
            skip_invoice_custom_sections:
              type: boolean
              description: Whether to skip invoice custom sections.
              example: false
            invoice_custom_section_codes:
              type: array
              description: Invoice custom section codes.
              items:
                type: string
                description: Section code.
                example: legal_terms
    ContractCreateInput:
      type: object
      description: Create contract.
      required:
        - contract
      properties:
        contract:
          allOf:
            - $ref: '#/components/schemas/ContractBaseInput'
            - type: object
              required:
                - external_id
                - external_customer_id
                - code
    Contract:
      type: object
      description: contract response.
      required:
        - contract
      properties:
        contract:
          $ref: '#/components/schemas/ContractObject'
    ContractUpdateInput:
      type: object
      description: Update a contract.
      required:
        - contract
      properties:
        contract:
          type: object
          minProperties: 1
          properties:
            name:
              type:
                - string
                - 'null'
              description: Contract name.
              example: Annual agreement
            status:
              type: string
              description: Accepted only when it equals the contract's current status, as when sending back a contract read from the API. Any other value answers 422 value_is_invalid, and so does null. A status changes only by publishing or deleting the contract. Since Lago v1.58.0; earlier servers ignore it.
              example: draft
              enum:
                - draft
                - pending
                - active
            plan_code:
              type:
                - string
                - 'null'
              description: Optional plan code. Plan-less contracts use directly attached rate cards.
              example: standard
            billing_anchor_date:
              type:
                - string
                - 'null'
              description: Optional billing anchor.
              example: null
              format: date
            started_at:
              type:
                - string
                - 'null'
              description: Start timestamp. Editable on a draft or pending contract. On a pending contract, a start of today or earlier activates it; a draft stays a draft until it is published. An active contract accepts only its stored value.
              example: null
              format: date-time
            ended_at:
              type:
                - string
                - 'null'
              description: Optional end timestamp. Must be after the start and not already in the past.
              example: null
              format: date-time
            consolidate_invoice:
              type: boolean
              description: Whether invoices can consolidate compatible contracts.
              example: true
            purchase_order_number:
              type:
                - string
                - 'null'
              description: Purchase order reference.
              example: PO-123
            invoice_custom_section:
              type: object
              description: Invoice section selection.
              required: []
              properties:
                skip_invoice_custom_sections:
                  type: boolean
                  description: Whether to skip invoice custom sections.
                  example: false
                invoice_custom_section_codes:
                  type: array
                  description: Invoice custom section codes.
                  items:
                    type: string
                    description: Section code.
                    example: legal_terms
    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
    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'
    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'
    ContractUsage:
      type: object
      description: current usage response.
      required:
        - current_usage
      properties:
        current_usage:
          $ref: '#/components/schemas/ContractUsageObject'
    FeePricingUnitDetailsObject:
      type: object
      description: Fee Pricing Unit Details.
      required:
        - lago_pricing_unit_id
        - pricing_unit_code
        - short_name
        - amount_cents
        - precise_amount_cents
        - unit_amount_cents
        - precise_unit_amount
        - conversion_rate
      properties:
        lago_pricing_unit_id:
          type: string
          description: Pricing unit identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        pricing_unit_code:
          type: string
          description: Pricing unit code.
          example: tokens
        short_name:
          type: string
          description: Short name.
          example: example
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        precise_amount_cents:
          type: string
          description: Precise amount cents. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        unit_amount_cents:
          type: integer
          description: Unit amount cents.
          example: 100
        precise_unit_amount:
          type: string
          description: Precise unit amount. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        conversion_rate:
          type: string
          description: Conversion rate. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
    FeeAppliedTaxObject:
      type: object
      description: Fee Applied Tax.
      required:
        - lago_id
        - lago_fee_id
        - lago_tax_id
        - tax_name
        - tax_code
        - tax_rate
        - tax_description
        - amount_cents
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_fee_id:
          type: string
          description: Identifier of the taxed record.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_tax_id:
          type:
            - string
            - 'null'
          description: Tax identifier. Null when the tax was removed or supplied by a provider.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        tax_name:
          type: string
          description: Tax name.
          example: example
        tax_code:
          type: string
          description: Tax code.
          example: example
        tax_rate:
          type: number
          description: Tax rate.
          example: 20
        tax_description:
          type:
            - string
            - 'null'
          description: Tax description.
          example: example
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    InvoiceObject:
      type: object
      description: Invoice.
      required:
        - lago_id
        - number
        - invoice_type
        - status
        - payment_status
        - billing_entity_code
        - lago_customer_id
        - external_customer_id
        - currency
        - issuing_date
        - payment_due_date
        - payment_overdue
        - purchase_order_number
        - fees_amount_cents
        - sub_total_excluding_taxes_amount_cents
        - taxes_amount_cents
        - sub_total_including_taxes_amount_cents
        - credit_notes_amount_cents
        - total_amount_cents
        - total_offsetted_credit_note_amount_cents
        - total_paid_amount_cents
        - total_due_amount_cents
        - pdf_url
        - xml_url
        - payment_dispute_lost_at
        - voided_at
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        number:
          type: string
          description: Number.
          example: example
        invoice_type:
          type: string
          description: Type of invoice. Advance fees are named advance_fees rather than the v1 advance_charges value.
          example: contract
          enum:
            - contract
            - advance_fees
            - subscription
            - add_on
            - credit
            - one_off
            - progressive_billing
            - credit_purchase
        status:
          type: string
          description: Invoice lifecycle status.
          example: generating
          enum:
            - generating
            - draft
            - open
            - finalized
            - voided
            - failed
            - closed
            - pending
            - deleted
        payment_status:
          type: string
          description: Payment status.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
        billing_entity_code:
          type: string
          description: Code of the invoice billing entity.
          example: main
        lago_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        currency:
          type:
            - string
            - 'null'
          description: Currency as an ISO 4217 code.
          example: USD
        issuing_date:
          type:
            - string
            - 'null'
          description: Issuing date.
          example: null
          format: date
        payment_due_date:
          type:
            - string
            - 'null'
          description: Payment due date.
          example: null
          format: date
        payment_overdue:
          type:
            - boolean
            - 'null'
          description: Payment overdue.
          example: false
        purchase_order_number:
          type:
            - string
            - 'null'
          description: Purchase order number.
          example: example
        fees_amount_cents:
          type: integer
          description: Fees amount cents.
          example: 100
        sub_total_excluding_taxes_amount_cents:
          type: integer
          description: Sub total excluding taxes amount cents.
          example: 100
        taxes_amount_cents:
          type: integer
          description: Taxes amount cents.
          example: 100
        sub_total_including_taxes_amount_cents:
          type: integer
          description: Sub total including taxes amount cents.
          example: 100
        credit_notes_amount_cents:
          type: integer
          description: Credit notes amount cents.
          example: 100
        total_amount_cents:
          type: integer
          description: Total amount cents.
          example: 100
        total_offsetted_credit_note_amount_cents:
          type: integer
          description: Total applied credit note offsets, in cents.
          example: 0
        total_paid_amount_cents:
          type: integer
          description: Total paid amount cents.
          example: 100
        total_due_amount_cents:
          type: integer
          description: Amount still due, in cents.
          example: 1000
        pdf_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        xml_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        payment_dispute_lost_at:
          type:
            - string
            - 'null'
          description: Payment dispute lost at.
          example: null
          format: date-time
        voided_at:
          type:
            - string
            - 'null'
          description: Voided at.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        fees:
          type: array
          description: Present only with expands[]=fees. At most 1000 fees may be expanded; use GET /fees for larger invoices.
          items:
            $ref: '#/components/schemas/FeeObject'
        applied_taxes:
          type: array
          description: Present only with expands[]=applied_taxes.
          items:
            $ref: '#/components/schemas/InvoiceAppliedTaxObject'
        customer:
          $ref: '#/components/schemas/CustomerObject'
          description: Present only with expands[]=customer.
        contracts:
          type: array
          description: Present only with expands[]=contracts. Contracts are derived from fee provenance.
          items:
            $ref: '#/components/schemas/ContractObject'
        applied_invoice_custom_sections:
          type: array
          description: Present only with expands[]=applied_invoice_custom_sections.
          items:
            $ref: '#/components/schemas/AppliedInvoiceCustomSectionObject'
        error_details:
          type: array
          description: Present only with expands[]=error_details.
          items:
            $ref: '#/components/schemas/ErrorDetailObject'
    FeeObject:
      type: object
      description: Fee.
      required:
        - lago_id
        - lago_invoice_id
        - fee_type
        - lago_customer_id
        - external_customer_id
        - lago_contract_id
        - external_contract_id
        - lago_product_id
        - product_code
        - lago_product_category_id
        - product_category_code
        - lago_product_filter_id
        - product_filter_code
        - lago_rate_card_id
        - rate_card_code
        - lago_rate_id
        - rate_code
        - lago_rate_override_id
        - lago_true_up_parent_fee_id
        - lago_true_up_fee_id
        - event_transaction_id
        - display_on_invoice
        - product_invoice_display_name
        - product_category_invoice_display_name
        - product_filter_invoice_display_name
        - filters
        - billing_timing
        - grouped_by
        - currency
        - units
        - total_aggregated_units
        - events_count
        - unit_amount_cents
        - precise_unit_amount_cents
        - amount_cents
        - sub_total_excluding_taxes_amount_cents
        - taxes_amount_cents
        - total_amount_cents
        - amount_details
        - pricing_unit_details
        - payment_status
        - from_datetime
        - to_datetime
        - succeeded_at
        - failed_at
        - refunded_at
        - created_at
        - updated_at
        - deleted_at
        - lago_wallet_id
        - wallet_code
        - lago_wallet_transaction_id
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_invoice_id:
          type:
            - string
            - 'null'
          description: Identifier of the related invoice.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        fee_type:
          type: string
          description: Product fee or wallet credit purchase fee. The fees endpoints return product fees; invoice fee expansions can also include credit purchases.
          example: product
          enum:
            - product
            - credit_purchase
        lago_customer_id:
          type:
            - string
            - 'null'
          description: Identifier of the related customer.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type:
            - string
            - 'null'
          description: External customer id.
          example: example
        lago_contract_id:
          type:
            - string
            - 'null'
          description: Identifier of the related contract.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_contract_id:
          type:
            - string
            - 'null'
          description: External contract id.
          example: example
        lago_product_id:
          type:
            - string
            - 'null'
          description: Identifier of the related product.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        product_code:
          type:
            - string
            - 'null'
          description: Product code.
          example: example
        lago_product_category_id:
          type:
            - string
            - 'null'
          description: Identifier of the related product category.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        product_category_code:
          type:
            - string
            - 'null'
          description: Product category code.
          example: example
        lago_product_filter_id:
          type:
            - string
            - 'null'
          description: Identifier of the related product filter.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        product_filter_code:
          type:
            - string
            - 'null'
          description: Product filter code.
          example: example
        lago_rate_card_id:
          type:
            - string
            - 'null'
          description: Identifier of the related rate card.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        rate_card_code:
          type:
            - string
            - 'null'
          description: Rate card code.
          example: example
        lago_rate_id:
          type:
            - string
            - 'null'
          description: Identifier of the related rate.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        rate_code:
          type:
            - string
            - 'null'
          description: Rate code.
          example: example
        lago_rate_override_id:
          type:
            - string
            - 'null'
          description: Identifier of the related rate override.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_true_up_parent_fee_id:
          type:
            - string
            - 'null'
          description: Identifier of the related true up parent fee.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_true_up_fee_id:
          type:
            - string
            - 'null'
          description: Identifier of the related true up fee.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        event_transaction_id:
          type:
            - string
            - 'null'
          description: Transaction identifier of the advance-billing event.
          example: event_123
        display_on_invoice:
          type:
            - boolean
            - 'null'
          description: Whether the rate card displays this fee on invoices.
          example: true
        product_invoice_display_name:
          type:
            - string
            - 'null'
          description: Product invoice display name.
          example: example
        product_category_invoice_display_name:
          type:
            - string
            - 'null'
          description: Product category invoice display name.
          example: example
        product_filter_invoice_display_name:
          type:
            - string
            - 'null'
          description: Product filter invoice display name.
          example: example
        filters:
          type:
            - object
            - 'null'
          description: Product filter matches saved with the fee. Older fees can fall back to current filter values.
          additionalProperties:
            type: array
            description: Values selected for this key.
            items:
              type:
                - string
                - 'null'
              description: Selected filter value.
              example: eu
        billing_timing:
          type: string
          description: When the fee is billed.
          example: advance
          enum:
            - advance
            - arrears
        grouped_by:
          type: object
          description: Grouped by.
          additionalProperties: true
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        units:
          type: string
          description: Quantity. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        total_aggregated_units:
          type:
            - string
            - 'null'
          description: Total aggregated units. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        events_count:
          type:
            - integer
            - 'null'
          description: Events count.
          example: 1
        unit_amount_cents:
          type: integer
          description: Unit amount cents.
          example: 100
        precise_unit_amount_cents:
          type: string
          description: Precise unit amount in cents. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        sub_total_excluding_taxes_amount_cents:
          type: integer
          description: Fee amount after discounts and before tax, in cents.
          example: 1000
        taxes_amount_cents:
          type: integer
          description: Taxes amount cents.
          example: 100
        total_amount_cents:
          type: integer
          description: Fee amount including tax, in cents.
          example: 1200
        amount_details:
          type: object
          description: Amount details.
          additionalProperties: true
        pricing_unit_details:
          anyOf:
            - $ref: '#/components/schemas/FeePricingUnitDetailsObject'
            - type: 'null'
          description: Pricing unit amounts, or null when no pricing unit is used.
        payment_status:
          type: string
          description: Payment status of the fee.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
            - refunded
        from_datetime:
          type:
            - string
            - 'null'
          description: Start of the billed period, when available.
          example: null
          format: date-time
        to_datetime:
          type:
            - string
            - 'null'
          description: End of the billed period, when available.
          example: null
          format: date-time
        succeeded_at:
          type:
            - string
            - 'null'
          description: Succeeded at.
          example: null
          format: date-time
        failed_at:
          type:
            - string
            - 'null'
          description: Failed at.
          example: null
          format: date-time
        refunded_at:
          type:
            - string
            - 'null'
          description: Refunded at.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        applied_taxes:
          type: array
          description: Present only with expands[]=applied_taxes.
          items:
            $ref: '#/components/schemas/FeeAppliedTaxObject'
        invoice:
          anyOf:
            - $ref: '#/components/schemas/InvoiceObject'
            - type: 'null'
          description: Present only with expands[]=invoice.
        product:
          anyOf:
            - $ref: '#/components/schemas/ProductObject'
            - type: 'null'
          description: Present only with expands[]=product.
        product_filter:
          anyOf:
            - $ref: '#/components/schemas/ProductFilterObject'
            - type: 'null'
          description: Present only with expands[]=product_filter.
        rate_card:
          anyOf:
            - $ref: '#/components/schemas/RateCardObject'
            - type: 'null'
          description: Present only with expands[]=rate_card.
        rate:
          anyOf:
            - $ref: '#/components/schemas/RateCardRateObject'
            - type: 'null'
          description: Present only with expands[]=rate.
        contract:
          anyOf:
            - $ref: '#/components/schemas/ContractObject'
            - type: 'null'
          description: Present only with expands[]=contract.
        customer:
          anyOf:
            - $ref: '#/components/schemas/CustomerObject'
            - type: 'null'
          description: Present only with expands[]=customer.
        lago_wallet_id:
          type:
            - string
            - 'null'
          description: Identifier of the wallet funded by a credit purchase, or null for a product fee.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        wallet_code:
          type:
            - string
            - 'null'
          description: Code of the wallet funded by a credit purchase, or null for a product fee.
          example: prepaid
        lago_wallet_transaction_id:
          type:
            - string
            - 'null'
          description: Identifier of the credit purchase wallet transaction, or null for a product fee.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    InvoiceAppliedTaxObject:
      type: object
      description: Invoice Applied Tax.
      required:
        - lago_id
        - lago_invoice_id
        - lago_tax_id
        - tax_name
        - tax_code
        - tax_rate
        - tax_description
        - amount_cents
        - fees_amount_cents
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_invoice_id:
          type: string
          description: Identifier of the taxed record.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_tax_id:
          type:
            - string
            - 'null'
          description: Tax identifier. Null when the tax was removed or supplied by a provider.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        tax_name:
          type: string
          description: Tax name.
          example: example
        tax_code:
          type: string
          description: Tax code.
          example: example
        tax_rate:
          type: number
          description: Tax rate.
          example: 20
        tax_description:
          type:
            - string
            - 'null'
          description: Tax description.
          example: example
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        fees_amount_cents:
          type: integer
          description: Fees amount cents.
          example: 100
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    AppliedInvoiceCustomSectionObject:
      type: object
      description: Applied Invoice Custom Section.
      required:
        - lago_id
        - lago_invoice_id
        - code
        - details
        - display_name
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_invoice_id:
          type: string
          description: Invoice identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        code:
          type: string
          description: Code.
          example: example
        details:
          type:
            - string
            - 'null'
          description: Details.
          example: example
        display_name:
          type:
            - string
            - 'null'
          description: Display name.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    ErrorDetailObject:
      type: object
      description: Error attached to an invoice.
      required:
        - lago_id
        - error_code
        - details
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        error_code:
          type: string
          description: Error category.
          example: not_provided
          enum:
            - not_provided
            - tax_error
            - tax_voiding_error
            - invoice_generation_error
        details:
          type: object
          description: Details.
          additionalProperties: true
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    InvoicesPaginated:
      type: object
      description: invoices list.
      required:
        - invoices
        - meta
      properties:
        invoices:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/InvoiceObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    Invoice:
      type: object
      description: invoice response.
      required:
        - invoice
      properties:
        invoice:
          $ref: '#/components/schemas/InvoiceObject'
    InvoiceBaseInput:
      type: object
      minProperties: 1
      properties:
        payment_status:
          type: string
          description: Payment status.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
    InvoiceUpdateInput:
      type: object
      description: Update invoice.
      required:
        - invoice
      properties:
        invoice:
          $ref: '#/components/schemas/InvoiceBaseInput'
    FeesPaginated:
      type: object
      description: fees list.
      required:
        - fees
        - meta
      properties:
        fees:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/FeeObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    Fee:
      type: object
      description: fee response.
      required:
        - fee
      properties:
        fee:
          $ref: '#/components/schemas/FeeObject'
    FeeBaseInput:
      type: object
      minProperties: 1
      properties:
        payment_status:
          type: string
          description: Payment status of the fee.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
            - refunded
    FeeUpdateInput:
      type: object
      description: Update fee.
      required:
        - fee
      properties:
        fee:
          $ref: '#/components/schemas/FeeBaseInput'
    VoidInvoiceInput:
      type: object
      properties:
        generate_credit_note:
          type: boolean
          description: Whether to generate credit notes. Requires a premium license.
          example: false
        refund_amount:
          type: integer
          description: Requested refund amount, in cents.
          example: 0
        credit_amount:
          type: integer
          description: Requested credit amount, in cents.
          example: 0
    ResendEmailInput:
      type: object
      properties:
        to:
          type: array
          description: Recipients. When omitted or empty, the customer email is used.
          items:
            type: string
            description: Email recipient.
            example: billing@acme.example
            format: email
        cc:
          type: array
          description: Additional recipients.
          items:
            type: string
            description: Email recipient.
            example: billing@acme.example
            format: email
        bcc:
          type: array
          description: Additional recipients.
          items:
            type: string
            description: Email recipient.
            example: billing@acme.example
            format: email
    PaymentMethodSelectionInput:
      type: object
      description: Payment method selection. Omit to use the configured default.
      properties:
        payment_method_type:
          type: string
          description: How the payment is collected.
          example: provider
          enum:
            - provider
            - manual
        payment_method_id:
          type: string
          description: Identifier of a payment method belonging to the customer.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
    RetryInvoicePaymentInput:
      type: object
      properties:
        payment_method:
          $ref: '#/components/schemas/PaymentMethodSelectionInput'
    InvoicePaymentUrlObject:
      type: object
      description: Invoice payment URL.
      required:
        - lago_customer_id
        - external_customer_id
        - payment_provider
        - lago_invoice_id
        - payment_url
      properties:
        lago_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        payment_provider:
          type:
            - string
            - 'null'
          description: Payment provider.
          example: stripe
        lago_invoice_id:
          type: string
          description: Invoice identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        payment_url:
          type: string
          description: URL where the customer can pay.
          example: https://payments.example/invoice
          format: uri
    InvoicePaymentUrl:
      type: object
      description: payment url response.
      required:
        - payment_url
      properties:
        payment_url:
          $ref: '#/components/schemas/InvoicePaymentUrlObject'
    PaymentObject:
      type: object
      description: Payment.
      required:
        - lago_id
        - lago_customer_id
        - external_customer_id
        - lago_payable_id
        - payable_type
        - lago_invoice_ids
        - amount_cents
        - currency
        - status
        - payment_status
        - payment_type
        - reference
        - payment_provider_code
        - payment_provider_type
        - provider_payment_id
        - provider_customer_id
        - next_action
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_customer_id:
          type: string
          description: Customer identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        lago_payable_id:
          type:
            - string
            - 'null'
          description: Identifier of the invoice or payment request being paid.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        payable_type:
          type: string
          description: Type of payable record.
          example: Invoice
          enum:
            - Invoice
            - PaymentRequest
        lago_invoice_ids:
          type: array
          description: Invoices covered by the payment.
          items:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        status:
          type: string
          description: Status.
          example: example
        payment_status:
          type:
            - string
            - 'null'
          description: Normalized payment status.
          example: pending
          enum:
            - pending
            - processing
            - succeeded
            - failed
            - null
        payment_type:
          type: string
          description: How the payment was collected.
          example: provider
          enum:
            - provider
            - manual
            - x402
        reference:
          type:
            - string
            - 'null'
          description: Reference.
          example: example
        payment_provider_code:
          type:
            - string
            - 'null'
          description: Payment provider code.
          example: stripe_main
        payment_provider_type:
          type:
            - string
            - 'null'
          description: Payment provider type.
          example: stripe
        provider_payment_id:
          type:
            - string
            - 'null'
          description: Provider payment id.
          example: example
        provider_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier within the payment provider.
          example: cus_example
        next_action:
          type:
            - object
            - 'null'
          description: Provider instructions needed to complete the payment.
          additionalProperties: true
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    PaymentsPaginated:
      type: object
      description: payments list.
      required:
        - payments
        - meta
      properties:
        payments:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PaymentObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    PaymentBaseInput:
      type: object
      minProperties: 1
      properties:
        invoice_id:
          type: string
          description: Identifier of the invoice being paid.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        amount_cents:
          type: integer
          description: Amount paid, in cents.
          example: 1000
          minimum: 1
        reference:
          type: string
          description: Manual payment reference.
          example: wire_transfer_123
          minLength: 1
          maxLength: 40
        paid_at:
          type:
            - string
            - 'null'
          description: Payment timestamp. Defaults to now.
          example: null
          format: date-time
    PaymentCreateInput:
      type: object
      description: Create payment.
      required:
        - payment
      properties:
        payment:
          allOf:
            - $ref: '#/components/schemas/PaymentBaseInput'
            - type: object
              required:
                - invoice_id
                - amount_cents
                - reference
    Payment:
      type: object
      description: payment response.
      required:
        - payment
      properties:
        payment:
          $ref: '#/components/schemas/PaymentObject'
    PaymentRequestObject:
      type: object
      description: Payment Request.
      required:
        - lago_id
        - lago_customer_id
        - external_customer_id
        - email
        - amount_cents
        - currency
        - payment_status
        - lago_invoice_ids
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_customer_id:
          type: string
          description: Customer identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        payment_status:
          type: string
          description: Payment status.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
        lago_invoice_ids:
          type: array
          description: Invoices included in the payment request.
          items:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    PaymentRequestsPaginated:
      type: object
      description: payment requests list.
      required:
        - payment_requests
        - meta
      properties:
        payment_requests:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PaymentRequestObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    PaymentRequestBaseInput:
      type: object
      minProperties: 1
      properties:
        external_customer_id:
          type: string
          description: External customer identifier.
          example: customer_123
        lago_invoice_ids:
          type: array
          description: Customer invoices to include.
          items:
            type: string
            description: Invoice identifier.
            example: 1a901a90-1a90-1a90-1a90-1a901a901a90
            format: uuid
          minItems: 1
        email:
          type:
            - string
            - 'null'
          description: Recipient email. Defaults to the customer email.
          example: billing@acme.example
          format: email
        payment_method:
          $ref: '#/components/schemas/PaymentMethodSelectionInput'
    PaymentRequestCreateInput:
      type: object
      description: Create payment request.
      required:
        - payment_request
      properties:
        payment_request:
          allOf:
            - $ref: '#/components/schemas/PaymentRequestBaseInput'
            - type: object
              required:
                - external_customer_id
                - lago_invoice_ids
    PaymentRequest:
      type: object
      description: payment request response.
      required:
        - payment_request
      properties:
        payment_request:
          $ref: '#/components/schemas/PaymentRequestObject'
    PaymentReceiptObject:
      type: object
      description: Payment Receipt.
      required:
        - lago_id
        - number
        - lago_payment_id
        - pdf_url
        - xml_url
        - pdf_url_expires_at
        - xml_url_expires_at
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        number:
          type: string
          description: Number.
          example: example
        lago_payment_id:
          type: string
          description: Payment identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        pdf_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        xml_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        pdf_url_expires_at:
          type:
            - string
            - 'null'
          description: Expiry of the PDF URL. Null when no PDF URL is available.
          example: null
          format: date-time
        xml_url_expires_at:
          type:
            - string
            - 'null'
          description: Expiry of the XML URL. Null when no XML URL is available.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        payment:
          $ref: '#/components/schemas/PaymentObject'
          description: Present only with expands[]=payment on retrieval.
    PaymentReceiptsPaginated:
      type: object
      description: payment receipts list.
      required:
        - payment_receipts
        - meta
      properties:
        payment_receipts:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PaymentReceiptObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    PaymentReceipt:
      type: object
      description: payment receipt response.
      required:
        - payment_receipt
      properties:
        payment_receipt:
          $ref: '#/components/schemas/PaymentReceiptObject'
    CreditNoteItemObject:
      type: object
      description: A fee credited by the credit note.
      required:
        - lago_fee_id
        - amount_cents
      properties:
        lago_fee_id:
          type: string
          description: Credited fee identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        amount_cents:
          type: integer
          description: Credited fee amount excluding tax, in cents.
          example: 100
    CreditNoteAppliedTaxObject:
      type: object
      description: Credit Note Applied Tax.
      required:
        - lago_tax_id
        - tax_name
        - tax_code
        - tax_rate
        - tax_description
        - base_amount_cents
        - amount_cents
      properties:
        lago_tax_id:
          type:
            - string
            - 'null'
          description: Tax identifier, when a local tax still exists.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        tax_name:
          type: string
          description: Tax name.
          example: example
        tax_code:
          type: string
          description: Tax code.
          example: example
        tax_rate:
          type: number
          description: Tax rate.
          example: 20
        tax_description:
          type:
            - string
            - 'null'
          description: Tax description.
          example: example
        base_amount_cents:
          type: integer
          description: Base amount cents.
          example: 100
        amount_cents:
          type: integer
          description: Amount cents.
          example: 100
    CreditNoteErrorDetailObject:
      type: object
      description: Error attached to a credit note.
      required:
        - lago_id
        - error_code
        - details
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        error_code:
          type: string
          description: Error category.
          example: not_provided
          enum:
            - not_provided
            - tax_error
            - tax_voiding_error
            - invoice_generation_error
        details:
          type: object
          description: Details.
          additionalProperties: true
    CreditNoteObject:
      type: object
      description: Credit Note.
      required:
        - lago_id
        - billing_entity_code
        - sequential_id
        - number
        - lago_invoice_id
        - invoice_number
        - purchase_order_number
        - issuing_date
        - credit_status
        - refund_status
        - reason
        - description
        - currency
        - sub_total_excluding_taxes_amount_cents
        - taxes_amount_cents
        - sub_total_including_taxes_amount_cents
        - total_amount_cents
        - balance_amount_cents
        - credit_amount_cents
        - refund_amount_cents
        - offset_amount_cents
        - file_url
        - xml_url
        - self_billed
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        billing_entity_code:
          type: string
          description: Code of the invoice billing entity.
          example: main
        sequential_id:
          type: integer
          description: Sequential id.
          example: 1
        number:
          type: string
          description: Number.
          example: example
        lago_invoice_id:
          type: string
          description: Invoice identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        invoice_number:
          type: string
          description: Invoice number.
          example: INV-001
        purchase_order_number:
          type:
            - string
            - 'null'
          description: Purchase order reference.
          example: PO-123
        issuing_date:
          type: string
          description: Issuing date.
          example: '2022-04-29'
          format: date
        credit_status:
          type:
            - string
            - 'null'
          description: Credit balance status.
          example: available
          enum:
            - available
            - consumed
            - voided
            - null
        refund_status:
          type:
            - string
            - 'null'
          description: Refund status.
          example: pending
          enum:
            - pending
            - succeeded
            - failed
            - null
        reason:
          type: string
          description: Reason for issuing the credit note.
          example: duplicated_charge
          enum:
            - duplicated_charge
            - product_unsatisfactory
            - order_change
            - order_cancellation
            - fraudulent_charge
            - other
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: Example
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        sub_total_excluding_taxes_amount_cents:
          type: integer
          description: Credited amount excluding tax, in cents.
          example: 100
        taxes_amount_cents:
          type: integer
          description: Taxes amount cents.
          example: 100
        sub_total_including_taxes_amount_cents:
          type: integer
          description: Credited amount including tax, in cents.
          example: 120
        total_amount_cents:
          type: integer
          description: Total amount cents.
          example: 100
        balance_amount_cents:
          type: integer
          description: Balance amount cents.
          example: 100
        credit_amount_cents:
          type: integer
          description: Credit amount cents.
          example: 100
        refund_amount_cents:
          type: integer
          description: Refund amount cents.
          example: 100
        offset_amount_cents:
          type: integer
          description: Offset amount cents.
          example: 100
        file_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        xml_url:
          type:
            - string
            - 'null'
          description: Document download URL, or null while the document is unavailable.
          example: https://documents.example/invoice.pdf
          format: uri
        self_billed:
          type: boolean
          description: Whether the invoice is self-billed.
          example: false
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        items:
          type: array
          description: Present only with expands[]=items.
          items:
            $ref: '#/components/schemas/CreditNoteItemObject'
        applied_taxes:
          type: array
          description: Present only with expands[]=applied_taxes.
          items:
            $ref: '#/components/schemas/CreditNoteAppliedTaxObject'
        customer:
          $ref: '#/components/schemas/CustomerObject'
          description: Present only with expands[]=customer.
        error_details:
          type: array
          description: Present only with expands[]=error_details. These entries do not include timestamps.
          items:
            $ref: '#/components/schemas/CreditNoteErrorDetailObject'
        metadata:
          type:
            - object
            - 'null'
          description: Present only with expands[]=metadata. Null when no metadata exists.
          additionalProperties: true
    CreditNotesPaginated:
      type: object
      description: credit notes list.
      required:
        - credit_notes
        - meta
      properties:
        credit_notes:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/CreditNoteObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    CreditNoteItemInput:
      type: object
      description: A fee to credit.
      required:
        - fee_id
        - amount_cents
      properties:
        fee_id:
          type: string
          description: Identifier of a fee belonging to the invoice.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        amount_cents:
          type:
            - number
            - string
          pattern: ^-?[0-9]+(\.[0-9]+)?$
          description: Amount in cents, accepted as a number or a decimal string.
          example: 100
    CreditNoteBaseInput:
      type: object
      minProperties: 1
      properties:
        invoice_id:
          type: string
          description: Invoice identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        reason:
          type: string
          description: Reason for issuing the credit note.
          example: duplicated_charge
          enum:
            - duplicated_charge
            - product_unsatisfactory
            - order_change
            - order_cancellation
            - fraudulent_charge
            - other
          default: other
        description:
          type:
            - string
            - 'null'
          description: Description of the adjustment.
          example: Partial credit
        credit_amount_cents:
          type: integer
          description: Amount credited to the customer balance, in cents.
          example: 100
        refund_amount_cents:
          type: integer
          description: Amount to refund, in cents.
          example: 0
        offset_amount_cents:
          type: integer
          description: Amount offset against the invoice balance, in cents.
          example: 0
        metadata:
          type:
            - object
            - 'null'
          description: Metadata as an object of key-value pairs. At most 50 keys are allowed. Keys are limited to 100 characters and values to 255 characters. Values must be strings or null.
          additionalProperties:
            type:
              - string
              - 'null'
            description: Metadata value. Null represents an empty value.
            example: example
            maxLength: 255
          maxProperties: 50
          propertyNames:
            maxLength: 100
        items:
          type: array
          description: Invoice fees to credit.
          items:
            $ref: '#/components/schemas/CreditNoteItemInput'
    CreditNoteCreateInput:
      type: object
      description: Create credit note.
      required:
        - credit_note
      properties:
        credit_note:
          allOf:
            - $ref: '#/components/schemas/CreditNoteBaseInput'
            - type: object
              required:
                - invoice_id
                - items
    CreditNote:
      type: object
      description: credit note response.
      required:
        - credit_note
      properties:
        credit_note:
          $ref: '#/components/schemas/CreditNoteObject'
    CreditNoteUpdateInput:
      type: object
      description: Update a credit note.
      required:
        - credit_note
      properties:
        credit_note:
          type: object
          minProperties: 1
          properties:
            refund_status:
              type:
                - string
                - 'null'
              description: Refund status.
              example: pending
              enum:
                - pending
                - succeeded
                - failed
                - null
            metadata:
              type:
                - object
                - 'null'
              description: Metadata as an object of key-value pairs. At most 50 keys are allowed. Keys are limited to 100 characters and values to 255 characters. Values must be strings or null.
              additionalProperties:
                type:
                  - string
                  - 'null'
                description: Metadata value. Null represents an empty value.
                example: example
                maxLength: 255
              maxProperties: 50
              propertyNames:
                maxLength: 100
    CreditNoteEstimateInput:
      type: object
      description: Estimate a credit note.
      required:
        - credit_note
      properties:
        credit_note:
          type: object
          description: Invoice and fee credits.
          required:
            - invoice_id
            - items
          properties:
            invoice_id:
              type: string
              description: Invoice identifier.
              example: 1a901a90-1a90-1a90-1a90-1a901a901a90
              format: uuid
            items:
              type: array
              description: Fees to credit.
              items:
                $ref: '#/components/schemas/CreditNoteItemInput'
    EstimatedCreditNoteObject:
      type: object
      description: An estimate, not a persisted credit note.
      required:
        - lago_invoice_id
        - invoice_number
        - currency
        - sub_total_excluding_taxes_amount_cents
        - taxes_amount_cents
        - sub_total_including_taxes_amount_cents
        - total_amount_cents
        - max_creditable_amount_cents
        - max_refundable_amount_cents
        - items
        - applied_taxes
      properties:
        lago_invoice_id:
          type: string
          description: Invoice identifier.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        invoice_number:
          type: string
          description: Invoice number.
          example: INV-001
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        sub_total_excluding_taxes_amount_cents:
          type: integer
          description: Estimated amount excluding tax, in cents.
          example: 100
        taxes_amount_cents:
          type: integer
          description: Estimated tax amount, in cents.
          example: 20
        sub_total_including_taxes_amount_cents:
          type: integer
          description: Estimated amount including tax, in cents.
          example: 120
        total_amount_cents:
          type: integer
          description: Estimated total amount, in cents.
          example: 120
        max_creditable_amount_cents:
          type: integer
          description: Maximum amount that can be credited, in cents.
          example: 120
        max_refundable_amount_cents:
          type: integer
          description: Maximum refundable amount, in cents.
          example: 120
        items:
          type: array
          description: Estimated fee credits. Always included.
          items:
            $ref: '#/components/schemas/CreditNoteItemObject'
        applied_taxes:
          type: array
          description: Estimated taxes. Always included.
          items:
            $ref: '#/components/schemas/CreditNoteAppliedTaxObject'
    EstimatedCreditNote:
      type: object
      description: estimated credit note response.
      required:
        - estimated_credit_note
      properties:
        estimated_credit_note:
          $ref: '#/components/schemas/EstimatedCreditNoteObject'
    MetadataInput:
      type: object
      properties:
        metadata:
          type: object
          description: Metadata keys and values. Omitted metadata defaults to an empty object. At most 50 keys are allowed. Keys are limited to 100 characters and values to 255 characters. Values must be strings or null.
          additionalProperties:
            type:
              - string
              - 'null'
            description: Metadata value. Null represents an empty value.
            example: example
            maxLength: 255
          example:
            reference: example
          maxProperties: 50
          propertyNames:
            maxLength: 100
    Metadata:
      type: object
      description: Metadata response.
      required:
        - metadata
      properties:
        metadata:
          type:
            - object
            - 'null'
          description: Metadata as an object of key-value pairs.
          additionalProperties: true
    ShippingAddressObject:
      type: object
      description: Shipping address.
      required:
        - address_line1
        - address_line2
        - city
        - zipcode
        - state
        - country
      properties:
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: FR
    CustomerMetadataObject:
      type: object
      description: Customer Metadata.
      required:
        - lago_id
        - key
        - value
        - display_on_invoice
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        key:
          type: string
          description: Key.
          example: example
        value:
          type: string
          description: Value.
          example: example
        display_on_invoice:
          type: boolean
          description: Whether this value is displayed on invoices.
          example: false
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    IntegrationCustomerObject:
      type: object
      description: Customer mapping to an integration. Provider-specific settings are included as additional top-level fields.
      required:
        - lago_id
        - external_customer_id
        - type
        - integration_code
        - code
        - is_default
        - category
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier in the integration.
          example: customer_123
        type:
          type:
            - string
            - 'null'
          description: Integration type.
          example: netsuite
          enum:
            - netsuite
            - anrok
            - avalara
            - xero
            - hubspot
            - salesforce
            - quickbooks
            - null
        integration_code:
          type:
            - string
            - 'null'
          description: Integration code.
          example: anrok
        code:
          type:
            - string
            - 'null'
          description: Mapping code.
          example: default
        is_default:
          type: boolean
          description: Whether this mapping is the default.
          example: false
        category:
          type:
            - string
            - 'null'
          description: Integration category.
          example: payment
          enum:
            - payment
            - tax
            - accounting
            - crm
            - null
      additionalProperties: true
    CustomerEndpointObject:
      allOf:
        - $ref: '#/components/schemas/CustomerObject'
        - type: object
          required:
            - shipping_address
          properties:
            shipping_address:
              $ref: '#/components/schemas/ShippingAddressObject'
              description: Shipping address of the customer.
            metadata:
              type: array
              description: Customer metadata. Included only with expands[]=metadata.
              items:
                $ref: '#/components/schemas/CustomerMetadataObject'
            taxes:
              type: array
              description: Customer taxes. Included only with expands[]=taxes.
              items:
                $ref: '#/components/schemas/TaxObject'
            integration_customers:
              type: array
              description: Integration mappings. Included only with expands[]=integration_customers.
              items:
                $ref: '#/components/schemas/IntegrationCustomerObject'
    CustomersPaginated:
      type: object
      description: customers list.
      required:
        - customers
        - meta
      properties:
        customers:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/CustomerEndpointObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ShippingAddressInput:
      type: object
      description: Shipping address.
      required: []
      properties:
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: FR
    CustomerBaseInput:
      type: object
      minProperties: 1
      properties:
        external_id:
          type: string
          description: Unique customer identifier in your application. On update, changes are ignored if the customer has subscriptions, invoices, add-ons, wallets or currency-based coupons.
          example: customer_123
        name:
          type:
            - string
            - 'null'
          description: Name.
          example: example
        firstname:
          type:
            - string
            - 'null'
          description: Firstname.
          example: example
        lastname:
          type:
            - string
            - 'null'
          description: Lastname.
          example: example
        customer_type:
          type:
            - string
            - 'null'
          description: Type of customer.
          example: company
          enum:
            - company
            - individual
            - null
        account_type:
          type: string
          description: Account type. Requires revenue share to be enabled. On update, changes are ignored if the customer has subscriptions, invoices, add-ons, wallets or currency-based coupons.
          example: customer
          enum:
            - customer
            - partner
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        phone:
          type:
            - string
            - 'null'
          description: Phone.
          example: example
        url:
          type:
            - string
            - 'null'
          description: Url.
          example: example
        logo_url:
          type:
            - string
            - 'null'
          description: Logo url.
          example: example
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: example
        legal_name:
          type:
            - string
            - 'null'
          description: Legal name.
          example: example
        legal_number:
          type:
            - string
            - 'null'
          description: Legal number.
          example: example
        tax_identification_number:
          type:
            - string
            - 'null'
          description: Tax identification number.
          example: example
        currency:
          type:
            - string
            - 'null'
          description: Currency as an ISO 4217 code.
          example: USD
        timezone:
          type:
            - string
            - 'null'
          description: Timezone. Requires a premium license; otherwise the value is ignored.
          example: example
        finalize_zero_amount_invoice:
          type:
            - string
            - 'null'
          description: Whether to finalize zero-amount invoices. Null resets this setting to inherit.
          example: inherit
          enum:
            - inherit
            - skip
            - finalize
            - null
        skip_invoice_custom_sections:
          type: boolean
          description: Skip invoice custom sections.
          example: false
        external_salesforce_id:
          type:
            - string
            - 'null'
          description: External salesforce id.
          example: example
        billing_entity_code:
          type: string
          description: Code of the customer billing entity.
          example: main
        invoice_grace_period:
          type:
            - integer
            - 'null'
          description: Invoice grace period. Requires a premium license; otherwise the value is ignored.
          example: 1
        payment_provider:
          type:
            - string
            - 'null'
          description: Payment provider.
          example: example
        payment_provider_code:
          type:
            - string
            - 'null'
          description: Payment provider code.
          example: example
        provider_customer_id:
          type:
            - string
            - 'null'
          description: Customer identifier in the payment provider.
          example: cus_example
        provider_payment_methods:
          type:
            - array
            - 'null'
          description: Payment methods allowed by the provider.
          items:
            type: string
            description: Payment method type.
            example: card
        document_locale:
          type:
            - string
            - 'null'
          description: Document locale.
          example: example
        periodic_invoice_issuing_date_anchor:
          type:
            - string
            - 'null'
          description: Date used to issue periodic invoices.
          example: current_period_end
          enum:
            - current_period_end
            - next_period_start
            - null
        periodic_invoice_issuing_date_adjustment:
          type:
            - string
            - 'null'
          description: Adjustment applied to periodic invoice issuing dates.
          example: keep_anchor
          enum:
            - keep_anchor
            - align_with_finalization_date
            - null
        sync:
          type: boolean
          description: Whether to run payment-provider synchronization before returning the response rather than in a background job.
          example: false
        sync_with_provider:
          type: boolean
          description: Whether to create or synchronize the customer with the selected payment provider.
          example: false
        shipping_address:
          $ref: '#/components/schemas/ShippingAddressInput'
        tax_codes:
          type: array
          description: Tax codes to assign. An empty array removes the assignments.
          items:
            type: string
            description: Tax codes to assign. An empty array removes the assignments.
            example: vat
        invoice_custom_section_codes:
          type: array
          description: Invoice custom section codes to assign. An empty array removes the assignments.
          items:
            type: string
            description: Invoice custom section codes to assign. An empty array removes the assignments.
            example: legal
        metadata:
          type: array
          description: Customer metadata. At most five entries. On update, this is a full replacement. Include id for each existing entry to keep or update it. Entries without id are created, not matched by key. Omitted entries are deleted.
          items:
            type: object
            description: Customer metadata entry. For a new entry, key and value are required. For an existing entry, send its id and any fields to change.
            properties:
              id:
                type:
                  - string
                  - 'null'
                description: Existing metadata identifier.
                example: 1a901a90-1a90-1a90-1a90-1a901a901a90
                format: uuid
              key:
                type: string
                description: Metadata key.
                example: reference
                maxLength: 20
              value:
                type: string
                description: Metadata value.
                example: '123'
                maxLength: 100
              display_on_invoice:
                type: boolean
                description: Whether to display the value on invoices. Defaults to false when omitted, including when updating an existing entry.
                example: false
                default: false
            anyOf:
              - required:
                  - id
                properties:
                  id:
                    type: string
              - required:
                  - key
                  - value
          maxItems: 5
        integration_customers:
          type: array
          description: Integration mappings. Only one entry per integration type is accepted. On update, this is a full replacement. Include id for each existing mapping to keep or update it. Omitted mappings are deleted.
          items:
            type: object
            description: Customer integration mapping.
            required:
              - integration_type
            properties:
              id:
                type:
                  - string
                  - 'null'
                description: Existing mapping identifier.
                example: 1a901a90-1a90-1a90-1a90-1a901a901a90
                format: uuid
              code:
                type: string
                description: Mapping code.
                example: default
              external_customer_id:
                type: string
                description: Customer identifier in the integration.
                example: customer_123
              integration_type:
                type: string
                description: Integration type.
                example: netsuite
                enum:
                  - netsuite
                  - okta
                  - anrok
                  - avalara
                  - xero
                  - hubspot
                  - salesforce
              integration_code:
                type: string
                description: Integration code.
                example: anrok
              subsidiary_id:
                type: string
                description: Provider subsidiary identifier.
                example: subsidiary_123
              sync_with_provider:
                type: boolean
                description: Whether to synchronize the mapping with the provider.
                example: false
              targeted_object:
                type: string
                description: Object targeted in the integration.
                example: customer
    CustomerCreateInput:
      type: object
      description: Create customer.
      required:
        - customer
      properties:
        customer:
          allOf:
            - $ref: '#/components/schemas/CustomerBaseInput'
            - type: object
              required:
                - external_id
              properties:
                metadata:
                  type: array
                  items:
                    type: object
                    required:
                      - key
                      - value
    Customer:
      type: object
      description: customer response.
      required:
        - customer
      properties:
        customer:
          $ref: '#/components/schemas/CustomerEndpointObject'
    CustomerUpdateInput:
      type: object
      description: Update customer.
      required:
        - customer
      properties:
        customer:
          $ref: '#/components/schemas/CustomerBaseInput'
    OrganizationObject:
      type: object
      description: Organization.
      required:
        - lago_id
        - name
        - slug
        - email
        - events_store
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type: string
          description: Name.
          example: example
        slug:
          type: string
          description: Slug.
          example: example
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        events_store:
          type: string
          description: Event storage used by the organization.
          example: clickhouse
          enum:
            - clickhouse
            - postgres
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    Organization:
      type: object
      description: organization response.
      required:
        - organization
      properties:
        organization:
          $ref: '#/components/schemas/OrganizationObject'
    OrganizationUpdateInput:
      type: object
      description: Organization update.
      required:
        - organization
      properties:
        organization:
          type: object
          minProperties: 1
          properties:
            email:
              type:
                - string
                - 'null'
              description: Organization email.
              example: billing@acme.example
            slug:
              type: string
              description: Organization slug.
              example: acme
    BillingEntityObject:
      type: object
      description: Billing Entity.
      required:
        - code
        - name
        - default_currency
        - country
        - address_line1
        - address_line2
        - phone
        - city
        - state
        - zipcode
        - einvoicing
        - email
        - legal_name
        - legal_number
        - timezone
        - email_settings
        - document_numbering
        - document_number_prefix
        - tax_identification_number
        - finalize_zero_amount_invoice
        - invoice_footer
        - invoice_grace_period
        - document_locale
        - eu_tax_management
        - periodic_invoice_issuing_date_anchor
        - periodic_invoice_issuing_date_adjustment
        - lago_id
        - is_default
        - logo_url
        - created_at
        - updated_at
        - archived_at
        - deleted_at
      properties:
        code:
          type: string
          description: Code.
          example: example
        name:
          type: string
          description: Name.
          example: example
        default_currency:
          type: string
          description: Default currency.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: example
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        phone:
          type:
            - string
            - 'null'
          description: Phone.
          example: example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        einvoicing:
          type: boolean
          description: Einvoicing.
          example: false
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        legal_name:
          type:
            - string
            - 'null'
          description: Legal name.
          example: example
        legal_number:
          type:
            - string
            - 'null'
          description: Legal number.
          example: example
        timezone:
          type: string
          description: Timezone.
          example: example
        email_settings:
          type: array
          description: Enabled email notification types.
          items:
            type: string
            description: Enabled email notification types.
            example: invoice.finalized
        document_numbering:
          type: string
          description: Document numbering scope.
          example: per_customer
          enum:
            - per_customer
            - per_billing_entity
        document_number_prefix:
          type:
            - string
            - 'null'
          description: Document number prefix.
          example: example
        tax_identification_number:
          type:
            - string
            - 'null'
          description: Tax identification number.
          example: example
        finalize_zero_amount_invoice:
          type: boolean
          description: Finalize zero amount invoice.
          example: false
        invoice_footer:
          type:
            - string
            - 'null'
          description: Invoice footer.
          example: Example
        invoice_grace_period:
          type: integer
          description: Invoice grace period.
          example: 1
        document_locale:
          type: string
          description: Document locale.
          example: example
        eu_tax_management:
          type:
            - boolean
            - 'null'
          description: Eu tax management.
          example: false
        periodic_invoice_issuing_date_anchor:
          type:
            - string
            - 'null'
          description: Date used to issue periodic invoices.
          example: current_period_end
          enum:
            - current_period_end
            - next_period_start
            - null
        periodic_invoice_issuing_date_adjustment:
          type:
            - string
            - 'null'
          description: Adjustment applied to periodic invoice issuing dates.
          example: keep_anchor
          enum:
            - keep_anchor
            - align_with_finalization_date
            - null
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        is_default:
          type: boolean
          description: Whether this is the organization default billing entity.
          example: false
        logo_url:
          type:
            - string
            - 'null'
          description: Logo URL.
          example: https://cdn.acme.example/logo.png
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        archived_at:
          type:
            - string
            - 'null'
          description: Archived at.
          example: null
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
        taxes:
          type: array
          description: Assigned taxes. Included only with expands[]=taxes.
          items:
            $ref: '#/components/schemas/TaxObject'
        selected_invoice_custom_sections:
          type: array
          description: Selected sections. Included only with expands[]=selected_invoice_custom_sections.
          items:
            $ref: '#/components/schemas/InvoiceCustomSectionObject'
    BillingEntitiesPaginated:
      type: object
      description: billing entities list.
      required:
        - billing_entities
        - meta
      properties:
        billing_entities:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/BillingEntityObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    BillingEntityBaseInput:
      type: object
      minProperties: 1
      properties:
        code:
          type: string
          description: Unique code among active billing entities.
          example: example_code
        name:
          type: string
          description: Name.
          example: example
        default_currency:
          type: string
          description: Default currency.
          example: example
        country:
          type:
            - string
            - 'null'
          description: Country.
          example: example
        address_line1:
          type:
            - string
            - 'null'
          description: Address line1.
          example: example
        address_line2:
          type:
            - string
            - 'null'
          description: Address line2.
          example: example
        phone:
          type:
            - string
            - 'null'
          description: Phone.
          example: example
        city:
          type:
            - string
            - 'null'
          description: City.
          example: example
        state:
          type:
            - string
            - 'null'
          description: State.
          example: example
        zipcode:
          type:
            - string
            - 'null'
          description: Zipcode.
          example: example
        einvoicing:
          type: boolean
          description: Einvoicing.
          example: false
        email:
          type:
            - string
            - 'null'
          description: Email.
          example: billing@acme.example
        legal_name:
          type:
            - string
            - 'null'
          description: Legal name.
          example: example
        legal_number:
          type:
            - string
            - 'null'
          description: Legal number.
          example: example
        timezone:
          type: string
          description: Timezone.
          example: example
        email_settings:
          type: array
          description: Enabled email notification types.
          items:
            type: string
            description: Enabled email notification types.
            example: invoice.finalized
        document_numbering:
          type: string
          description: Document numbering scope.
          example: per_customer
          enum:
            - per_customer
            - per_billing_entity
        document_number_prefix:
          type:
            - string
            - 'null'
          description: Document number prefix.
          example: example
        tax_identification_number:
          type:
            - string
            - 'null'
          description: Tax identification number.
          example: example
        finalize_zero_amount_invoice:
          type: boolean
          description: Finalize zero amount invoice.
          example: false
        invoice_footer:
          type:
            - string
            - 'null'
          description: Invoice footer.
          example: Example
        invoice_grace_period:
          type: integer
          description: Invoice grace period.
          example: 1
        document_locale:
          type: string
          description: Document locale.
          example: example
        eu_tax_management:
          type: boolean
          description: Eu tax management.
          example: false
        periodic_invoice_issuing_date_anchor:
          type: string
          description: Date used to issue periodic invoices.
          example: current_period_end
          enum:
            - current_period_end
            - next_period_start
        periodic_invoice_issuing_date_adjustment:
          type: string
          description: Adjustment applied to periodic invoice issuing dates.
          example: keep_anchor
          enum:
            - keep_anchor
            - align_with_finalization_date
        logo:
          type: string
          description: PNG or JPEG logo encoded as a base64 data URL.
          example: data:image/png;base64,aGVsbG8=
          pattern: ^data:image/(png|jpe?g);base64,[A-Za-z0-9+/=\s]+$
        tax_codes:
          type: array
          description: Tax codes to assign. An empty array removes the assignments.
          items:
            type: string
            description: Tax codes to assign. An empty array removes the assignments.
            example: vat
        invoice_custom_section_codes:
          type: array
          description: Invoice custom section codes to assign. An empty array removes the assignments.
          items:
            type: string
            description: Invoice custom section codes to assign. An empty array removes the assignments.
            example: legal
    BillingEntityCreateInput:
      type: object
      description: Create billing entity.
      required:
        - billing_entity
      properties:
        billing_entity:
          allOf:
            - $ref: '#/components/schemas/BillingEntityBaseInput'
            - type: object
              required:
                - code
                - name
    BillingEntity:
      type: object
      description: billing entity response.
      required:
        - billing_entity
      properties:
        billing_entity:
          $ref: '#/components/schemas/BillingEntityObject'
    BillingEntityUpdateInput:
      type: object
      description: Update billing entity.
      required:
        - billing_entity
      properties:
        billing_entity:
          $ref: '#/components/schemas/BillingEntityBaseInput'
    BillableMetricFilterObject:
      type: object
      description: Billable Metric Filter.
      required:
        - lago_id
        - key
        - values
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        key:
          type: string
          description: Key.
          example: example
        values:
          type: array
          description: Allowed values, sorted alphabetically.
          items:
            type: string
            description: Allowed values, sorted alphabetically.
            example: eu
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    BillableMetricEndpointObject:
      allOf:
        - $ref: '#/components/schemas/BillableMetricObject'
        - type: object
          properties:
            filters:
              type: array
              description: Filters defined by this metric. Included only with expands[]=filters.
              items:
                $ref: '#/components/schemas/BillableMetricFilterObject'
    BillableMetricsPaginated:
      type: object
      description: billable metrics list.
      required:
        - billable_metrics
        - meta
      properties:
        billable_metrics:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/BillableMetricEndpointObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    BillableMetricBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type: string
          description: Name.
          example: example
        code:
          type: string
          description: Code.
          example: example
        description:
          type:
            - string
            - 'null'
          description: Description.
          example: example
        field_name:
          type:
            - string
            - 'null'
          description: Field name.
          example: example
        expression:
          type:
            - string
            - 'null'
          description: Expression.
          example: example
        rounding_precision:
          type:
            - integer
            - 'null'
          description: Rounding precision.
          example: 1
        aggregation_type:
          type: string
          description: Aggregation method. field_name is required except for count_agg.
          example: count_agg
          enum:
            - count_agg
            - sum_agg
            - max_agg
            - unique_count_agg
            - weighted_sum_agg
            - latest_agg
        weighted_interval:
          type:
            - string
            - 'null'
          description: Weighting interval. Required for weighted_sum_agg.
          example: seconds
          enum:
            - seconds
            - null
        recurring:
          type: boolean
          description: Whether values carry over between billing periods.
          example: false
        rounding_function:
          type:
            - string
            - 'null'
          description: Rounding applied to aggregated values.
          example: ceil
          enum:
            - ceil
            - floor
            - round
            - null
        filters:
          type: array
          description: Complete filter definitions. An empty array removes existing filters. Null, malformed filters and non-string values are rejected before any changes are saved.
          items:
            type: object
            description: Billable metric filter.
            required:
              - key
              - values
            properties:
              key:
                type: string
                description: Unique, nonempty filter key.
                example: region
                minLength: 1
              values:
                type: array
                description: Allowed string values.
                items:
                  type: string
                  description: Allowed filter value.
                  example: eu
                minItems: 1
    BillableMetricCreateInput:
      type: object
      description: Create billable metric.
      required:
        - billable_metric
      properties:
        billable_metric:
          allOf:
            - $ref: '#/components/schemas/BillableMetricBaseInput'
            - type: object
              required:
                - name
                - code
                - aggregation_type
    BillableMetric:
      type: object
      description: billable metric response.
      required:
        - billable_metric
      properties:
        billable_metric:
          $ref: '#/components/schemas/BillableMetricEndpointObject'
    BillableMetricUpdateInput:
      type: object
      description: Update billable metric.
      required:
        - billable_metric
      properties:
        billable_metric:
          $ref: '#/components/schemas/BillableMetricBaseInput'
    EventObject:
      type: object
      description: Usage event.
      required:
        - transaction_id
        - external_contract_id
        - code
        - precise_total_amount_cents
        - properties
        - timestamp
      properties:
        transaction_id:
          type: string
          description: Transaction identifier supplied by the sender. It can occur on more than one event.
          example: transaction_123
        external_contract_id:
          type:
            - string
            - 'null'
          description: External contract identifier.
          example: contract_123
        code:
          type: string
          description: Event code.
          example: compute
        precise_total_amount_cents:
          type:
            - string
            - 'null'
          description: Total event amount, in cents. Sent as a decimal string.
          example: '1.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        properties:
          type: object
          description: Event properties.
          additionalProperties: true
        timestamp:
          type: string
          description: Event timestamp, in UTC with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    EventsPaginated:
      type: object
      description: events list.
      required:
        - events
        - meta
      properties:
        events:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/EventObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    EventInput:
      type: object
      description: Event to ingest.
      required:
        - transaction_id
        - code
      properties:
        transaction_id:
          type: string
          description: Transaction identifier supplied by the sender.
          example: transaction_123
          minLength: 1
          maxLength: 1000
        code:
          type: string
          description: Event code.
          example: compute
          minLength: 1
        external_contract_id:
          type:
            - string
            - 'null'
          description: External contract identifier.
          example: contract_123
        timestamp:
          type:
            - number
            - string
          description: Unix timestamp in seconds. Defaults to the request time. Must be on or after 1970-01-01 and before 2300-01-01; deployment-specific time limits may also apply.
          example: 1651222791.123456
        precise_total_amount_cents:
          type:
            - number
            - string
            - 'null'
          description: Finite amount in cents, as a number or decimal string.
          example: '125.5'
        properties:
          type:
            - object
            - 'null'
          additionalProperties: true
          description: Event properties. Defaults to an empty object.
    EventCreateInput:
      type: object
      description: Event ingestion request.
      required:
        - event
      properties:
        event:
          $ref: '#/components/schemas/EventInput'
    Event:
      type: object
      description: event response.
      required:
        - event
      properties:
        event:
          $ref: '#/components/schemas/EventObject'
    EventBatchCreateInput:
      type: object
      description: Batch event ingestion request.
      required:
        - events
      properties:
        events:
          type: array
          description: Events to ingest. The default maximum is 100; deployments can configure a different maximum.
          items:
            $ref: '#/components/schemas/EventInput'
          minItems: 1
    EventsCollection:
      type: object
      description: events list.
      required:
        - events
      properties:
        events:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/EventObject'
    CheckoutUrlObject:
      type: object
      description: Customer checkout URL.
      required:
        - lago_customer_id
        - external_customer_id
        - payment_provider
        - payment_provider_code
        - checkout_url
      properties:
        lago_customer_id:
          type: string
          description: Customer identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: Customer external identifier.
          example: customer_123
        payment_provider:
          type: string
          description: Payment provider.
          example: stripe
        payment_provider_code:
          type: string
          description: Payment provider code.
          example: stripe
        checkout_url:
          type: string
          description: URL of the provider checkout page.
          example: https://pay.acme.example/checkout
          format: uri
    CheckoutUrl:
      type: object
      description: checkout url response.
      required:
        - checkout_url
      properties:
        checkout_url:
          $ref: '#/components/schemas/CheckoutUrlObject'
    PaymentMethodObject:
      type: object
      description: Payment Method.
      required:
        - lago_id
        - lago_customer_id
        - external_customer_id
        - is_default
        - payment_provider_code
        - payment_provider_name
        - payment_provider_type
        - provider_method_id
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_customer_id:
          type: string
          description: Customer identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_customer_id:
          type: string
          description: Customer external identifier.
          example: customer_123
        is_default:
          type: boolean
          description: Is default.
          example: false
        payment_provider_code:
          type:
            - string
            - 'null'
          description: Payment provider code.
          example: stripe
        payment_provider_name:
          type:
            - string
            - 'null'
          description: Payment provider name.
          example: Stripe
        payment_provider_type:
          type:
            - string
            - 'null'
          description: Payment provider type.
          example: stripe
        provider_method_id:
          type: string
          description: Provider method id.
          example: example
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, with microsecond precision. Null until deletion.
          example: null
          format: date-time
    PaymentMethodsPaginated:
      type: object
      description: payment methods list.
      required:
        - payment_methods
        - meta
      properties:
        payment_methods:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PaymentMethodObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    PaymentMethod:
      type: object
      description: payment method response.
      required:
        - payment_method
      properties:
        payment_method:
          $ref: '#/components/schemas/PaymentMethodObject'
    ActivityLogObject:
      type: object
      description: Recorded log entry.
      required:
        - activity_id
        - activity_type
        - activity_source
        - activity_object
        - activity_object_changes
        - user_email
        - resource_id
        - resource_type
        - external_customer_id
        - external_subscription_id
        - logged_at
        - created_at
      properties:
        activity_id:
          type: string
          description: Activity identifier.
          example: activity_123
        activity_type:
          type: string
          description: Activity type.
          example: customer.created
        activity_source:
          type: string
          description: Activity source.
          example: api
        activity_object:
          type: object
          description: Recorded object. JSON-encoded object and array values are parsed one level deep.
          additionalProperties: true
        activity_object_changes:
          type: object
          description: Recorded changes. JSON-encoded object and array values are parsed one level deep.
          additionalProperties: true
        user_email:
          type:
            - string
            - 'null'
          description: Email of the user, if known.
          example: user@acme.example
        resource_id:
          type: string
          description: Affected resource identifier.
          example: resource_123
        resource_type:
          type: string
          description: Affected resource type.
          example: Customer
        external_customer_id:
          type:
            - string
            - 'null'
          description: Customer external identifier.
          example: customer_123
        external_subscription_id:
          type:
            - string
            - 'null'
          description: Subscription external identifier.
          example: subscription_123
        logged_at:
          type: string
          description: Time the event was logged.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        created_at:
          type: string
          description: Time the log record was created.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    ActivityLogsPaginated:
      type: object
      description: activity logs list.
      required:
        - activity_logs
        - meta
      properties:
        activity_logs:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ActivityLogObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ActivityLog:
      type: object
      description: activity log response.
      required:
        - activity_log
      properties:
        activity_log:
          $ref: '#/components/schemas/ActivityLogObject'
    ApiLogObject:
      type: object
      description: Recorded log entry.
      required:
        - request_id
        - client
        - http_method
        - http_status
        - request_origin
        - request_path
        - request_body
        - request_response
        - api_version
        - logged_at
        - created_at
      properties:
        request_id:
          type: string
          description: Request identifier.
          example: request_123
        client:
          type: string
          description: API client.
          example: curl
        http_method:
          type: string
          description: HTTP method.
          example: get
          enum:
            - get
            - post
            - put
            - delete
            - patch
        http_status:
          type: integer
          description: HTTP response status.
          example: 200
        request_origin:
          type: string
          description: Request origin.
          example: https://app.acme.example
        request_path:
          type: string
          description: Request path.
          example: /api/v2/customers
        request_body:
          type: object
          description: Request body. JSON-encoded object and array values are parsed one level deep.
          additionalProperties: true
        request_response:
          type: object
          description: Response body. JSON-encoded object and array values are parsed one level deep.
          additionalProperties: true
        api_version:
          type: string
          description: API version.
          example: v2
        logged_at:
          type: string
          description: Time the event was logged.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        created_at:
          type: string
          description: Time the log record was created.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    ApiLogsPaginated:
      type: object
      description: api logs list.
      required:
        - api_logs
        - meta
      properties:
        api_logs:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ApiLogObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ApiLog:
      type: object
      description: api log response.
      required:
        - api_log
      properties:
        api_log:
          $ref: '#/components/schemas/ApiLogObject'
    SecurityLogObject:
      type: object
      description: Recorded log entry.
      required:
        - log_id
        - log_type
        - log_event
        - user_email
        - resources
        - device_info
        - logged_at
        - created_at
      properties:
        log_id:
          type: string
          description: Log identifier.
          example: log_123
        log_type:
          type: string
          description: Security log type.
          example: user
        log_event:
          type: string
          description: Security event.
          example: user.login
        user_email:
          type:
            - string
            - 'null'
          description: User email, if known.
          example: user@acme.example
        resources:
          type: object
          description: Resources associated with the event.
          additionalProperties: true
        device_info:
          type: object
          description: Device information associated with the event.
          additionalProperties: true
        logged_at:
          type: string
          description: Time the event was logged.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        created_at:
          type: string
          description: Time the log record was created.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    SecurityLogsPaginated:
      type: object
      description: security logs list.
      required:
        - security_logs
        - meta
      properties:
        security_logs:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/SecurityLogObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    SecurityLog:
      type: object
      description: security log response.
      required:
        - security_log
      properties:
        security_log:
          $ref: '#/components/schemas/SecurityLogObject'
    WebhookEventTypeEnum:
      type: string
      description: Webhook event type.
      example: add_on.created
      enum:
        - add_on.created
        - add_on.updated
        - add_on.deleted
        - alert.resolved
        - alert.triggered
        - billable_metric.created
        - billable_metric.updated
        - billable_metric.deleted
        - customer.created
        - customer.updated
        - customer.accounting_provider_created
        - customer.accounting_provider_error
        - customer.crm_provider_created
        - customer.crm_provider_error
        - customer.payment_provider_created
        - customer.payment_provider_error
        - customer.checkout_url_generated
        - customer.tax_provider_error
        - customer.vies_check
        - credit_note.created
        - credit_note.generated
        - credit_note.refund_failure
        - coupon.created
        - coupon.updated
        - coupon.deleted
        - coupon.terminated
        - dunning_campaign.finished
        - event.error
        - events.errors
        - feature.created
        - feature.updated
        - feature.deleted
        - fee.created
        - fee.tax_provider_error
        - invoice.created
        - invoice.one_off_created
        - invoice.paid_credit_added
        - invoice.generated
        - invoice.drafted
        - invoice.ready_to_finalize
        - invoice.voided
        - invoice.deleted
        - invoice.payment_dispute_lost
        - invoice.payment_status_updated
        - invoice.payment_overdue
        - invoice.payment_failure
        - invoice.resynced
        - integration.provider_error
        - order.created
        - order.executed
        - order_form.created
        - order_form.signed
        - order_form.expired
        - order_form.voided
        - payment.succeeded
        - payment.requires_action
        - payment_provider.error
        - payment_receipt.created
        - payment_receipt.generated
        - payment_request.created
        - payment_request.payment_failure
        - payment_request.payment_status_updated
        - plan.created
        - plan.updated
        - plan.deleted
        - product_category.created
        - product_category.updated
        - product_category.deleted
        - product.created
        - product.updated
        - product.deleted
        - product_filter.created
        - product_filter.updated
        - product_filter.deleted
        - rate_card.created
        - rate_card.updated
        - rate_card.deleted
        - rate_card_rate.created
        - rate_card_rate.updated
        - rate_card_rate.deleted
        - plan_rate_card.created
        - plan_rate_card.updated
        - plan_rate_card.deleted
        - contract_rate_card.created
        - contract_rate_card.updated
        - contract_rate_card.deleted
        - contract.created
        - contract.updated
        - contract.published
        - contract.started
        - contract.terminated
        - contract.canceled
        - quote.created
        - quote.approved
        - quote.voided
        - subscription.canceled
        - subscription.incomplete
        - subscription.terminated
        - subscription.started
        - subscription.updated
        - subscription.termination_alert
        - subscription.trial_ended
        - subscription.usage_threshold_reached
        - wallet.created
        - wallet.depleted_ongoing_balance
        - wallet.terminated
        - wallet.updated
        - wallet_transaction.created
        - wallet_transaction.updated
        - wallet_transaction.payment_failure
        - plan_entitlement.created
        - plan_entitlement.updated
        - plan_entitlement.deleted
        - contract_entitlement.created
        - contract_entitlement.updated
        - contract_entitlement.deleted
    WebhookEndpointSigningKeyObject:
      type: object
      description: Webhook endpoint signing key.
      required:
        - lago_id
        - secret_key
        - created_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        secret_key:
          type: string
          pattern: ^whsec_
          description: Secret key to set up a Standard Webhooks library with, prefixed with `whsec_`.
          example: whsec_ZmFrZS1zZWNyZXQtZm9yLWRvY3VtZW50YXRpb24tb25seQ==
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    WebhookEndpointObject:
      type: object
      description: Webhook Endpoint.
      required:
        - lago_id
        - name
        - webhook_url
        - signature_algo
        - event_types
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        name:
          type:
            - string
            - 'null'
          description: Name.
          example: example
        webhook_url:
          type: string
          description: Public URL receiving webhook requests.
          example: https://hooks.acme.example/lago
          format: uri
        signature_algo:
          type: string
          description: Webhook signature algorithm.
          example: standard_webhooks
          enum:
            - jwt
            - hmac
            - standard_webhooks
        event_types:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/WebhookEventTypeEnum'
          description: Event types delivered to this endpoint. Null means all events; an empty array selects none.
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        signing_keys:
          type: array
          description: Signing keys of the endpoint, oldest first, used to verify the webhook-signature header of `standard_webhooks` deliveries. Included only with expands[]=signing_keys.
          items:
            $ref: '#/components/schemas/WebhookEndpointSigningKeyObject'
    WebhookEndpointsPaginated:
      type: object
      description: webhook endpoints list.
      required:
        - webhook_endpoints
        - meta
      properties:
        webhook_endpoints:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/WebhookEndpointObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    WebhookEndpointBaseInput:
      type: object
      minProperties: 1
      properties:
        name:
          type:
            - string
            - 'null'
          description: Endpoint name.
          example: Billing webhooks
        webhook_url:
          type: string
          description: Public URL receiving webhook requests. Private addresses are rejected.
          example: https://hooks.acme.example/lago
          format: uri
        signature_algo:
          type: string
          description: Webhook signature algorithm. Only `standard_webhooks` is accepted, and it is the default on create. Another value returns 422 with `value_is_invalid` on `signature_algo` and the accepted algorithms in `allowed_values`. An existing endpoint keeps its algorithm when the field is omitted or sent with its current value.
          example: standard_webhooks
          enum:
            - standard_webhooks
          default: standard_webhooks
        event_types:
          type:
            - array
            - 'null'
          items:
            anyOf:
              - $ref: '#/components/schemas/WebhookEventTypeEnum'
              - type: string
                enum:
                  - '*'
                example: '*'
          description: Event types to deliver. Null or ["*"] selects all events. Names are trimmed, lowercased and deduplicated. An empty array selects none.
    WebhookEndpointCreateInput:
      type: object
      description: Create webhook endpoint.
      required:
        - webhook_endpoint
      properties:
        webhook_endpoint:
          allOf:
            - $ref: '#/components/schemas/WebhookEndpointBaseInput'
            - type: object
              required:
                - webhook_url
    WebhookEndpoint:
      type: object
      description: webhook endpoint response.
      required:
        - webhook_endpoint
      properties:
        webhook_endpoint:
          $ref: '#/components/schemas/WebhookEndpointObject'
    WebhookEndpointUpdateInput:
      type: object
      description: Update webhook endpoint.
      required:
        - webhook_endpoint
      properties:
        webhook_endpoint:
          $ref: '#/components/schemas/WebhookEndpointBaseInput'
    FeaturePrivilegeObject:
      type: object
      description: Privilege defined by a feature.
      required:
        - lago_id
        - feature_code
        - code
        - name
        - value_type
        - select_options
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        feature_code:
          type: string
          description: Code of the feature.
          example: analytics
        code:
          type: string
          description: Privilege code.
          example: seats
        name:
          type:
            - string
            - 'null'
          description: Privilege name.
          example: Seats
        value_type:
          type: string
          description: Type of entitlement values.
          example: integer
          enum:
            - integer
            - string
            - boolean
            - select
        select_options:
          type:
            - array
            - 'null'
          description: Allowed values for a select privilege, or null for other types.
          items:
            type: string
            description: Allowed value.
            example: premium
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
    FeatureObject:
      type: object
      description: Feature in the product catalog.
      required:
        - lago_id
        - code
        - name
        - description
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        code:
          type: string
          description: Feature code.
          example: analytics
        name:
          type:
            - string
            - 'null'
          description: Feature name.
          example: Analytics
        description:
          type:
            - string
            - 'null'
          description: Feature description.
          example: Analytics access.
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
        privileges:
          type: array
          description: Privileges of the feature. Present only with expands[]=privileges on retrieval or creation.
          items:
            $ref: '#/components/schemas/FeaturePrivilegeObject'
    FeaturesPaginated:
      type: object
      description: FeaturesPaginated response.
      required:
        - features
        - meta
      properties:
        features:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/FeatureObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    FeaturePrivilegeBaseInput:
      type: object
      description: Attributes of a new feature privilege.
      required:
        - code
      properties:
        code:
          type: string
          description: Unique privilege code within the feature.
          example: seats
          maxLength: 255
        name:
          type:
            - string
            - 'null'
          description: Privilege name.
          example: Seats
          maxLength: 255
        value_type:
          type:
            - string
            - 'null'
          description: Type of entitlement values. Omitted or null defaults to string.
          example: string
          enum:
            - integer
            - string
            - boolean
            - select
            - null
          default: string
        select_options:
          type:
            - array
            - 'null'
          description: Allowed string values. Required and nonempty for a select privilege; ignored for other types.
          items:
            type: string
            description: Allowed value.
            example: premium
      allOf:
        - if:
            properties:
              value_type:
                const: select
            required:
              - value_type
          then:
            required:
              - select_options
            properties:
              select_options:
                type: array
                minItems: 1
                items:
                  type: string
                  description: Allowed value.
                  example: premium
    FeatureCreateInput:
      type: object
      description: Request payload.
      required:
        - feature
      properties:
        feature:
          type: object
          description: Resource attributes.
          required:
            - code
          properties:
            code:
              type: string
              description: Unique feature code within the organization.
              example: analytics
              maxLength: 255
            name:
              type:
                - string
                - 'null'
              description: Feature name.
              example: Analytics
              maxLength: 255
            description:
              type:
                - string
                - 'null'
              description: Feature description.
              example: Analytics access.
              maxLength: 600
            privileges:
              type:
                - array
                - 'null'
              description: Initial privileges. At most 50 privileges are allowed.
              items:
                $ref: '#/components/schemas/FeaturePrivilegeBaseInput'
              maxItems: 50
    Feature:
      type: object
      description: Feature response.
      required:
        - feature
      properties:
        feature:
          $ref: '#/components/schemas/FeatureObject'
    FeatureUpdateInput:
      type: object
      description: Request payload.
      required:
        - feature
      properties:
        feature:
          type: object
          description: Resource attributes.
          properties:
            name:
              type:
                - string
                - 'null'
              description: Feature name.
              example: Analytics
              maxLength: 255
            description:
              type:
                - string
                - 'null'
              description: Feature description.
              example: Analytics access.
              maxLength: 600
          minProperties: 1
    FeaturePrivilegesCollection:
      type: object
      description: FeaturePrivilegesCollection response.
      required:
        - privileges
      properties:
        privileges:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/FeaturePrivilegeObject'
    FeaturePrivilegeCreateInput:
      type: object
      description: Request payload.
      required:
        - privilege
      properties:
        privilege:
          $ref: '#/components/schemas/FeaturePrivilegeBaseInput'
    FeaturePrivilege:
      type: object
      description: FeaturePrivilege response.
      required:
        - privilege
      properties:
        privilege:
          $ref: '#/components/schemas/FeaturePrivilegeObject'
    FeaturePrivilegeUpdateInput:
      type: object
      description: Request payload.
      required:
        - privilege
      properties:
        privilege:
          type: object
          description: Resource attributes.
          properties:
            name:
              type:
                - string
                - 'null'
              description: Privilege name.
              example: Seats
              maxLength: 255
            select_options:
              type:
                - array
                - 'null'
              description: Complete list of allowed values for a select privilege. Existing options cannot be removed. Ignored for other privilege types.
              items:
                type: string
                description: Allowed value.
                example: premium
          minProperties: 1
    CatalogWalletSelectorObject:
      description: Selector identifying fees that a wallet can pay.
      oneOf:
        - type: object
          required:
            - type
            - code
          properties:
            type:
              type: string
              enum:
                - fee_type
              description: Selector type.
              example: fee_type
            code:
              type: string
              description: Fee type, fixed or metered.
              example: metered
              enum:
                - fixed
                - metered
        - type: object
          required:
            - type
            - code
          properties:
            type:
              type: string
              enum:
                - product_category
              description: Selector type.
              example: product_category
            code:
              type: string
              description: Product category code.
              example: compute
        - type: object
          required:
            - type
            - code
            - with_product_filters
          properties:
            type:
              type: string
              enum:
                - product
              description: Selector type.
              example: product
            code:
              type: string
              description: Product code.
              example: api_requests
            with_product_filters:
              type: boolean
              description: Whether product filter fees are included.
              example: false
        - type: object
          required:
            - type
            - code
            - product_code
          properties:
            type:
              type: string
              enum:
                - product_filters
              description: Selector type.
              example: product_filters
            code:
              type: string
              description: Product filter code, unique within the product named by product_code.
              example: eu
            product_code:
              type: string
              description: Parent product code. Required for product_filters selectors.
              example: api_requests
    CatalogWalletAppliesToObject:
      type: object
      description: Fee selectors attached to the wallet.
      required:
        - include
      properties:
        include:
          type: array
          description: Fee selectors included in the wallet scope. An empty list allows every fee.
          items:
            $ref: '#/components/schemas/CatalogWalletSelectorObject'
    PlanWalletObject:
      type: object
      description: Wallet template attached to a plan.
      required:
        - lago_id
        - plan_code
        - code
        - name
        - invoice_display_name
        - currency
        - tax_application
        - priority
        - top_up_min_amount_cents
        - top_up_max_amount_cents
        - applies_to
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        plan_code:
          type: string
          description: Code of the catalog plan.
          example: standard
        code:
          type: string
          description: Wallet code, unique within its plan or contract.
          example: prepaid
        name:
          type:
            - string
            - 'null'
          description: Wallet name.
          example: Prepaid credits
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Wallet name displayed on invoices.
          example: Prepaid credits
        currency:
          type: string
          description: Currency as an ISO 4217 code. Must match the plan or contract currency.
          example: USD
          pattern: ^[A-Z]{3}$
        tax_application:
          type: string
          description: Whether tax applies when credits are purchased or consumed.
          example: tax_on_consumption
          enum:
            - tax_on_consumption
            - tax_on_purchase
          default: tax_on_consumption
        priority:
          type: integer
          description: Spending priority, from 1 (highest) to 50 (lowest).
          example: 50
          minimum: 1
          maximum: 50
          default: 50
        top_up_min_amount_cents:
          type:
            - integer
            - 'null'
          description: Minimum top-up amount in cents, or null for no minimum.
          example: 100
          minimum: 0
        top_up_max_amount_cents:
          type:
            - integer
            - 'null'
          description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
          example: 10000
          minimum: 0
        applies_to:
          $ref: '#/components/schemas/CatalogWalletAppliesToObject'
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
        taxes:
          type: array
          description: Taxes attached to the wallet. Present only with expands[]=taxes on retrieval.
          items:
            $ref: '#/components/schemas/TaxObject'
        metadata:
          type:
            - object
            - 'null'
          description: Wallet metadata. Present only with expands[]=metadata on retrieval.
          additionalProperties: true
    PlanWalletsPaginated:
      type: object
      description: PlanWalletsPaginated response.
      required:
        - plan_wallets
        - meta
      properties:
        plan_wallets:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PlanWalletObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    CatalogWalletSelectorInput:
      type: object
      description: Selector identifying fees that a wallet can pay. product_filters requires product_code; only product selectors can enable with_product_filters.
      required:
        - type
        - code
      properties:
        type:
          type: string
          description: Selector type.
          example: fee_type
          enum:
            - fee_type
            - product_category
            - product
            - product_filters
        code:
          type: string
          description: Target code. A fee_type selector accepts fixed or metered.
          example: metered
        product_code:
          type: string
          description: Parent product code. Required for product_filters selectors.
          example: api_requests
        with_product_filters:
          type:
            - boolean
            - 'null'
          description: Includes the product filter fees as well as default product fees. Only product selectors accept true.
          example: false
          default: false
      allOf:
        - if:
            properties:
              type:
                const: product_filters
            required:
              - type
          then:
            required:
              - product_code
        - if:
            properties:
              type:
                enum:
                  - fee_type
                  - product_category
                  - product_filters
            required:
              - type
          then:
            properties:
              with_product_filters:
                enum:
                  - false
                  - null
        - if:
            properties:
              type:
                const: fee_type
            required:
              - type
          then:
            properties:
              code:
                enum:
                  - fixed
                  - metered
    CatalogWalletAppliesToInput:
      type: object
      description: Fee selectors. Omitted include is an empty list. An empty list allows every fee. Exclusion selectors are not supported.
      properties:
        include:
          type:
            - array
            - 'null'
          description: Fee selectors included in the wallet scope. Omitted or null is an empty list and allows every fee.
          items:
            $ref: '#/components/schemas/CatalogWalletSelectorInput'
      not:
        required:
          - exclude
    PlanWalletCreateInput:
      type: object
      description: Request payload.
      required:
        - plan_wallet
      properties:
        plan_wallet:
          type: object
          description: Resource attributes.
          required:
            - code
            - currency
          properties:
            code:
              type: string
              description: Wallet code, unique within its plan or contract.
              example: prepaid
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            name:
              type:
                - string
                - 'null'
              description: Wallet name.
              example: Prepaid credits
            invoice_display_name:
              type:
                - string
                - 'null'
              description: Wallet name displayed on invoices.
              example: Prepaid credits
            currency:
              type: string
              description: Currency as an ISO 4217 code. Must match the plan or contract currency.
              example: USD
              pattern: ^[A-Z]{3}$
            tax_application:
              type:
                - string
                - 'null'
              description: Whether tax applies when credits are purchased or consumed. Omitted or null defaults to tax_on_consumption.
              example: tax_on_consumption
              enum:
                - tax_on_consumption
                - tax_on_purchase
                - null
              default: tax_on_consumption
            priority:
              type:
                - integer
                - 'null'
              description: Spending priority, from 1 (highest) to 50 (lowest). Omitted or null defaults to 50.
              example: 50
              minimum: 1
              maximum: 50
              default: 50
            top_up_min_amount_cents:
              type:
                - integer
                - 'null'
              description: Minimum top-up amount in cents, or null for no minimum.
              example: 100
              minimum: 0
            top_up_max_amount_cents:
              type:
                - integer
                - 'null'
              description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
              example: 10000
              minimum: 0
            tax_codes:
              type:
                - array
                - 'null'
              description: Tax codes attached to the wallet, used only by tax_on_purchase wallets. Omitted, null or an empty array attaches no wallet-specific taxes. For tax_on_purchase, taxes fall back to the plan, then the customer, then the billing entity.
              items:
                type: string
                description: Tax code.
                example: vat
            applies_to:
              anyOf:
                - $ref: '#/components/schemas/CatalogWalletAppliesToInput'
                - type: 'null'
              description: Fee selectors that limit which fees the wallet pays. Omitted, null, an empty object or an empty include list allows every fee.
            metadata:
              type:
                - object
                - 'null'
              description: Metadata keys and values. Omitted or null creates the wallet without metadata.
              additionalProperties:
                type:
                  - string
                  - 'null'
                description: Metadata value.
                example: example
                maxLength: 255
              maxProperties: 50
              example:
                reference: example
              propertyNames:
                maxLength: 100
    PlanWallet:
      type: object
      description: PlanWallet response.
      required:
        - plan_wallet
      properties:
        plan_wallet:
          $ref: '#/components/schemas/PlanWalletObject'
    PlanWalletUpdateInput:
      type: object
      description: Request payload.
      required:
        - plan_wallet
      properties:
        plan_wallet:
          type: object
          description: Resource attributes.
          properties:
            code:
              type: string
              description: Wallet code, unique within its plan or contract.
              example: prepaid
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            name:
              type:
                - string
                - 'null'
              description: Wallet name.
              example: Prepaid credits
            invoice_display_name:
              type:
                - string
                - 'null'
              description: Wallet name displayed on invoices.
              example: Prepaid credits
            currency:
              type: string
              description: Currency as an ISO 4217 code. Must match the plan or contract currency.
              example: USD
              pattern: ^[A-Z]{3}$
            tax_application:
              type: string
              description: Whether tax applies when credits are purchased or consumed.
              example: tax_on_consumption
              enum:
                - tax_on_consumption
                - tax_on_purchase
              default: tax_on_consumption
            priority:
              type: integer
              description: Spending priority, from 1 (highest) to 50 (lowest).
              example: 50
              minimum: 1
              maximum: 50
              default: 50
            top_up_min_amount_cents:
              type:
                - integer
                - 'null'
              description: Minimum top-up amount in cents, or null for no minimum.
              example: 100
              minimum: 0
            top_up_max_amount_cents:
              type:
                - integer
                - 'null'
              description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
              example: 10000
              minimum: 0
            tax_codes:
              type:
                - array
                - 'null'
              description: Complete set of tax codes attached to the wallet, used only by tax_on_purchase wallets. An empty array removes the wallet-specific taxes, so taxes fall back to the plan, then the customer, then the billing entity. Null or omission keeps the current taxes.
              items:
                type: string
                description: Tax code.
                example: vat
            applies_to:
              anyOf:
                - $ref: '#/components/schemas/CatalogWalletAppliesToInput'
                - type: 'null'
              description: Complete fee selector set. An empty object or empty include list clears selectors and allows every fee. Null or omission preserves existing selectors.
            metadata:
              type:
                - object
                - 'null'
              description: Metadata keys and values. Replaces existing metadata; null clears it. Omission preserves it.
              additionalProperties:
                type:
                  - string
                  - 'null'
                description: Metadata value.
                example: example
                maxLength: 255
              maxProperties: 50
              example:
                reference: example
              propertyNames:
                maxLength: 100
          minProperties: 1
    ContractWalletObject:
      type: object
      description: Wallet attached to a contract.
      required:
        - lago_id
        - lago_contract_id
        - external_contract_id
        - contract_code
        - external_customer_id
        - code
        - name
        - invoice_display_name
        - currency
        - tax_application
        - priority
        - top_up_min_amount_cents
        - top_up_max_amount_cents
        - applies_to
        - balance_cents
        - ongoing_balance_cents
        - last_ongoing_balance_sync_at
        - terminated_at
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_contract_id:
          type: string
          description: Identifier of the contract.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_contract_id:
          type: string
          description: External identifier of the contract.
          example: contract_123
        contract_code:
          type:
            - string
            - 'null'
          description: Code of the contract.
          example: default
        external_customer_id:
          type: string
          description: External identifier of the customer.
          example: customer_123
        code:
          type: string
          description: Wallet code, unique within its plan or contract.
          example: prepaid
        name:
          type:
            - string
            - 'null'
          description: Wallet name.
          example: Prepaid credits
        invoice_display_name:
          type:
            - string
            - 'null'
          description: Wallet name displayed on invoices.
          example: Prepaid credits
        currency:
          type: string
          description: Currency as an ISO 4217 code. Must match the plan or contract currency.
          example: USD
          pattern: ^[A-Z]{3}$
        tax_application:
          type: string
          description: Whether tax applies when credits are purchased or consumed.
          example: tax_on_consumption
          enum:
            - tax_on_consumption
            - tax_on_purchase
          default: tax_on_consumption
        priority:
          type: integer
          description: Spending priority, from 1 (highest) to 50 (lowest).
          example: 50
          minimum: 1
          maximum: 50
          default: 50
        top_up_min_amount_cents:
          type:
            - integer
            - 'null'
          description: Minimum top-up amount in cents, or null for no minimum.
          example: 100
          minimum: 0
        top_up_max_amount_cents:
          type:
            - integer
            - 'null'
          description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
          example: 10000
          minimum: 0
        applies_to:
          $ref: '#/components/schemas/CatalogWalletAppliesToObject'
        balance_cents:
          type: integer
          description: Available wallet balance in cents.
          example: 1000
        ongoing_balance_cents:
          type: integer
          description: Wallet balance after ongoing usage, in cents.
          example: 900
        last_ongoing_balance_sync_at:
          type:
            - string
            - 'null'
          description: Time of the last ongoing balance update, or null before the first update.
          example: null
          format: date-time
        terminated_at:
          type:
            - string
            - 'null'
          description: Wallet termination timestamp, or null before termination.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
        taxes:
          type: array
          description: Taxes attached to the wallet. Present only with expands[]=taxes on retrieval.
          items:
            $ref: '#/components/schemas/TaxObject'
        metadata:
          type:
            - object
            - 'null'
          description: Wallet metadata. Present only with expands[]=metadata on retrieval.
          additionalProperties: true
    ContractWalletsPaginated:
      type: object
      description: ContractWalletsPaginated response.
      required:
        - contract_wallets
        - meta
      properties:
        contract_wallets:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractWalletObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ContractWalletCreateInput:
      type: object
      description: Request payload.
      required:
        - contract_wallet
      properties:
        contract_wallet:
          type: object
          description: Resource attributes.
          required:
            - code
            - currency
          properties:
            code:
              type: string
              description: Wallet code, unique within its plan or contract.
              example: prepaid
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            name:
              type:
                - string
                - 'null'
              description: Wallet name.
              example: Prepaid credits
            invoice_display_name:
              type:
                - string
                - 'null'
              description: Wallet name displayed on invoices.
              example: Prepaid credits
            currency:
              type: string
              description: Currency as an ISO 4217 code. Must match the plan or contract currency.
              example: USD
              pattern: ^[A-Z]{3}$
            tax_application:
              type:
                - string
                - 'null'
              description: Whether tax applies when credits are purchased or consumed. Omitted or null defaults to tax_on_consumption.
              example: tax_on_consumption
              enum:
                - tax_on_consumption
                - tax_on_purchase
                - null
              default: tax_on_consumption
            priority:
              type:
                - integer
                - 'null'
              description: Spending priority, from 1 (highest) to 50 (lowest). Omitted or null defaults to 50.
              example: 50
              minimum: 1
              maximum: 50
              default: 50
            top_up_min_amount_cents:
              type:
                - integer
                - 'null'
              description: Minimum top-up amount in cents, or null for no minimum.
              example: 100
              minimum: 0
            top_up_max_amount_cents:
              type:
                - integer
                - 'null'
              description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
              example: 10000
              minimum: 0
            tax_codes:
              type:
                - array
                - 'null'
              description: Tax codes attached to the wallet, used only by tax_on_purchase wallets. Omitted, null or an empty array attaches no wallet-specific taxes. For tax_on_purchase, taxes fall back to the plan, then the customer, then the billing entity.
              items:
                type: string
                description: Tax code.
                example: vat
            applies_to:
              anyOf:
                - $ref: '#/components/schemas/CatalogWalletAppliesToInput'
                - type: 'null'
              description: Fee selectors that limit which fees the wallet pays. Omitted, null, an empty object or an empty include list allows every fee.
            metadata:
              type:
                - object
                - 'null'
              description: Metadata keys and values. Omitted or null creates the wallet without metadata.
              additionalProperties:
                type:
                  - string
                  - 'null'
                description: Metadata value.
                example: example
                maxLength: 255
              maxProperties: 50
              example:
                reference: example
              propertyNames:
                maxLength: 100
    ContractWallet:
      type: object
      description: ContractWallet response.
      required:
        - contract_wallet
      properties:
        contract_wallet:
          $ref: '#/components/schemas/ContractWalletObject'
    ContractWalletUpdateInput:
      type: object
      description: Request payload.
      required:
        - contract_wallet
      properties:
        contract_wallet:
          type: object
          description: Resource attributes.
          properties:
            code:
              type: string
              description: Wallet code, unique within its plan or contract. Cannot be changed after creation.
              example: prepaid
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            name:
              type:
                - string
                - 'null'
              description: Wallet name.
              example: Prepaid credits
            invoice_display_name:
              type:
                - string
                - 'null'
              description: Wallet name displayed on invoices.
              example: Prepaid credits
            currency:
              type: string
              description: Currency as an ISO 4217 code. Must match the plan or contract currency. Cannot be changed after creation.
              example: USD
              pattern: ^[A-Z]{3}$
            tax_application:
              type: string
              description: Whether tax applies when credits are purchased or consumed. Cannot be changed after creation.
              example: tax_on_consumption
              enum:
                - tax_on_consumption
                - tax_on_purchase
              default: tax_on_consumption
            priority:
              type: integer
              description: Spending priority, from 1 (highest) to 50 (lowest).
              example: 50
              minimum: 1
              maximum: 50
              default: 50
            top_up_min_amount_cents:
              type:
                - integer
                - 'null'
              description: Minimum top-up amount in cents, or null for no minimum.
              example: 100
              minimum: 0
            top_up_max_amount_cents:
              type:
                - integer
                - 'null'
              description: Maximum top-up amount in cents, or null for no maximum. Must be at least the minimum when both are set.
              example: 10000
              minimum: 0
            tax_codes:
              type:
                - array
                - 'null'
              description: Complete set of tax codes attached to the wallet, used only by tax_on_purchase wallets. An empty array removes the wallet-specific taxes, so taxes fall back to the plan, then the customer, then the billing entity. Null or omission keeps the current taxes.
              items:
                type: string
                description: Tax code.
                example: vat
            applies_to:
              anyOf:
                - $ref: '#/components/schemas/CatalogWalletAppliesToInput'
                - type: 'null'
              description: Complete fee selector set. An empty object or empty include list clears selectors and allows every fee. Null or omission preserves existing selectors.
            metadata:
              type:
                - object
                - 'null'
              description: Metadata keys and values. Replaces existing metadata; null clears it. Omission preserves it.
              additionalProperties:
                type:
                  - string
                  - 'null'
                description: Metadata value.
                example: example
                maxLength: 255
              maxProperties: 50
              example:
                reference: example
              propertyNames:
                maxLength: 100
          minProperties: 1
    ContractWalletTransactionObject:
      type: object
      description: Transaction of a contract wallet.
      required:
        - lago_id
        - lago_wallet_id
        - wallet_code
        - lago_invoice_id
        - lago_credit_allocation_id
        - credit_allocation_code
        - direction
        - status
        - reason
        - allocation_type
        - currency
        - purchase_amount_cents
        - credit_amount_cents
        - remaining_credit_amount_cents
        - priority
        - settled_at
        - failed_at
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_wallet_id:
          type: string
          description: Identifier of the wallet.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        wallet_code:
          type: string
          description: Wallet code.
          example: prepaid
        lago_invoice_id:
          type:
            - string
            - 'null'
          description: Related invoice identifier, or null.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_credit_allocation_id:
          type:
            - string
            - 'null'
          description: Credit allocation identifier, or null for transactions not created by an allocation.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        credit_allocation_code:
          type:
            - string
            - 'null'
          description: Credit allocation code, or null.
          example: monthly
        direction:
          type: string
          description: Transaction direction.
          example: inbound
          enum:
            - inbound
            - outbound
        status:
          type: string
          description: Transaction status.
          example: settled
          enum:
            - pending
            - settled
            - failed
        reason:
          type: string
          description: Reason for the transaction.
          example: top_up
          enum:
            - top_up
            - credit_allocation
            - invoice_void
            - invoice_application
            - void
        allocation_type:
          type:
            - string
            - 'null'
          description: Trigger of the credit allocation, or null.
          example: billing_cycle
          enum:
            - billing_cycle
            - ongoing_balance
            - null
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        purchase_amount_cents:
          type:
            - integer
            - 'null'
          description: Amount paid to purchase the credit, in cents, or null.
          example: 1000
        credit_amount_cents:
          type: integer
          description: Credit moved by the transaction, in cents.
          example: 1000
        remaining_credit_amount_cents:
          type:
            - integer
            - 'null'
          description: Unspent credit in cents, or null for an outbound transaction.
          example: 500
        priority:
          type:
            - integer
            - 'null'
          description: Spending priority of an inbound transaction, or null for an outbound transaction.
          example: 50
        settled_at:
          type:
            - string
            - 'null'
          description: Settlement timestamp, or null before settlement.
          example: null
          format: date-time
        failed_at:
          type:
            - string
            - 'null'
          description: Failure timestamp, or null when no failure occurred.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    ContractWalletTransactionsPaginated:
      type: object
      description: ContractWalletTransactionsPaginated response.
      required:
        - wallet_transactions
        - meta
      properties:
        wallet_transactions:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractWalletTransactionObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ContractWalletTransaction:
      type: object
      description: ContractWalletTransaction response.
      required:
        - wallet_transaction
      properties:
        wallet_transaction:
          $ref: '#/components/schemas/ContractWalletTransactionObject'
    AlertThresholdObject:
      type: object
      description: Alert threshold.
      required:
        - code
        - value
        - recurring
        - notify_on
      properties:
        code:
          type:
            - string
            - 'null'
          description: Threshold code. Required and unique when resolved notifications are enabled.
          example: warning
        value:
          type: string
          description: Threshold value, sent as a decimal string.
          example: '12.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        recurring:
          type: boolean
          description: Whether the threshold repeats.
          example: false
        notify_on:
          type: array
          description: Events that cause a notification.
          items:
            type: string
            description: Notification event.
            example: triggered
            enum:
              - triggered
              - resolved
    CatalogWalletAlertObject:
      type: object
      description: Wallet alert or plan wallet alert template.
      required:
        - lago_id
        - lago_wallet_id
        - wallet_code
        - currency
        - plan_code
        - lago_contract_id
        - external_contract_id
        - contract_code
        - external_customer_id
        - code
        - name
        - alert_type
        - direction
        - thresholds
        - previous_value
        - last_processed_at
        - created_at
        - updated_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        lago_wallet_id:
          type: string
          description: Identifier of the wallet.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        wallet_code:
          type: string
          description: Wallet code.
          example: prepaid
        currency:
          type: string
          description: Currency as an ISO 4217 code.
          example: USD
        plan_code:
          type:
            - string
            - 'null'
          description: Plan code for a plan wallet template, or null for a contract wallet alert.
          example: standard
        lago_contract_id:
          type:
            - string
            - 'null'
          description: Contract identifier, or null for a plan wallet template.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_contract_id:
          type:
            - string
            - 'null'
          description: External contract identifier, or null for a plan wallet template.
          example: contract_123
        contract_code:
          type:
            - string
            - 'null'
          description: Contract code, or null for a plan wallet template or a contract without a code.
          example: default
        external_customer_id:
          type:
            - string
            - 'null'
          description: External customer identifier, or null for a plan wallet template.
          example: customer_123
        code:
          type: string
          description: Alert code.
          example: low_balance
        name:
          type:
            - string
            - 'null'
          description: Alert name.
          example: Low balance
        alert_type:
          type: string
          description: Wallet balance to monitor.
          example: balance
          enum:
            - balance
            - ongoing_balance
        direction:
          type: string
          description: Direction in which a wallet balance crosses thresholds.
          example: decreasing
          enum:
            - decreasing
        thresholds:
          type: array
          description: Thresholds, ordered by value with the recurring threshold last.
          items:
            $ref: '#/components/schemas/AlertThresholdObject'
        previous_value:
          type:
            - string
            - 'null'
          description: Last monitored value in cents, sent as a decimal string. Null for a template or an alert not yet evaluated.
          example: '12.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        last_processed_at:
          type:
            - string
            - 'null'
          description: Last evaluation timestamp, or null for a template or before evaluation.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
    CatalogWalletAlertsCollection:
      type: object
      description: CatalogWalletAlertsCollection response.
      required:
        - alerts
      properties:
        alerts:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/CatalogWalletAlertObject'
    CatalogWalletAlertThresholdInput:
      type: object
      description: Wallet alert threshold configuration.
      required:
        - value
      properties:
        code:
          type:
            - string
            - 'null'
          description: Threshold code. Required and unique when resolved notifications are enabled.
          example: warning
        value:
          type:
            - integer
            - string
          description: Threshold in whole cents, as an integer or a decimal string with no fractional cents.
          example: '100.0'
          pattern: ^-?[0-9]+(\.0+)?$
        recurring:
          type: boolean
          description: Whether this value is a recurring interval. At most one recurring threshold is allowed.
          example: false
          default: false
        notify_on:
          type: array
          description: Notification events. Must include triggered. Resolved is supported only for a non-recurring threshold with a code.
          items:
            type: string
            description: Notification event.
            example: triggered
            enum:
              - triggered
              - resolved
          default:
            - triggered
    CatalogWalletAlertCreateInput:
      type: object
      description: Request payload.
      required:
        - alert
      properties:
        alert:
          type: object
          description: Resource attributes.
          required:
            - code
            - alert_type
            - thresholds
          properties:
            code:
              type: string
              description: Unique alert code within the wallet.
              example: low_balance
              pattern: ^(?!\.+$)[a-zA-Z0-9_\-.]+$
            name:
              type:
                - string
                - 'null'
              description: Alert name.
              example: Low balance
            alert_type:
              type: string
              description: Wallet balance to monitor. At most one alert of each type is allowed.
              example: balance
              enum:
                - balance
                - ongoing_balance
            thresholds:
              type: array
              description: Complete threshold list, in whole cents. balance alerts cannot have negative threshold lines. Ongoing balance thresholds can be negative.
              items:
                $ref: '#/components/schemas/CatalogWalletAlertThresholdInput'
              minItems: 1
              maxItems: 20
    CatalogWalletAlert:
      type: object
      description: CatalogWalletAlert response.
      required:
        - alert
      properties:
        alert:
          $ref: '#/components/schemas/CatalogWalletAlertObject'
    CatalogWalletAlertUpdateInput:
      type: object
      description: Request payload.
      required:
        - alert
      properties:
        alert:
          type: object
          description: Resource attributes.
          properties:
            name:
              type:
                - string
                - 'null'
              description: Alert name.
              example: Low balance
            thresholds:
              type: array
              description: Complete threshold list, in whole cents. balance alerts cannot have negative threshold lines. Ongoing balance thresholds can be negative.
              items:
                $ref: '#/components/schemas/CatalogWalletAlertThresholdInput'
              minItems: 1
              maxItems: 20
          minProperties: 1
    ContractAlertScopeObject:
      description: Product scope of a contract alert.
      oneOf:
        - type: object
          required:
            - type
            - product_code
            - product_filter_codes
          properties:
            type:
              type: string
              description: Scope type.
              example: contract
              enum:
                - contract
            product_code:
              type: string
              description: Metered product code.
              example: api_requests
            product_filter_codes:
              type: array
              description: One product filter code. Cannot be combined with with_product_filters.
              items:
                type: string
                description: Product filter code.
                example: eu
              minItems: 1
              maxItems: 1
        - type: object
          required:
            - type
            - product_code
            - with_product_filters
          properties:
            type:
              type: string
              description: Scope type.
              example: contract
              enum:
                - contract
            product_code:
              type: string
              description: Metered product code.
              example: api_requests
            with_product_filters:
              type: boolean
              description: Includes all filter rate cards of the selected product. Cannot be combined with product_filter_codes.
              example: false
              default: false
    ContractAlertObject:
      type: object
      description: Usage alert shared by contracts with the same external identifier.
      required:
        - lago_id
        - external_contract_id
        - code
        - name
        - alert_type
        - scope
        - direction
        - thresholds
        - previous_value
        - last_processed_at
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        external_contract_id:
          type: string
          description: External contract identifier monitored by this alert.
          example: contract_123
        code:
          type: string
          description: Unique alert code for the external contract identifier.
          example: usage_warning
        name:
          type:
            - string
            - 'null'
          description: Alert name.
          example: Usage warning
        alert_type:
          type: string
          description: Metric to monitor. usage_units requires a metered product scope.
          example: usage_amount
          enum:
            - usage_amount
            - usage_units
        scope:
          type: array
          description: Alert scope. An empty array monitors all metered products for usage_amount; usage_units requires one product scope.
          items:
            $ref: '#/components/schemas/ContractAlertScopeObject'
          maxItems: 1
        direction:
          type: string
          description: Direction in which the monitored value crosses thresholds.
          example: increasing
          enum:
            - increasing
            - decreasing
        thresholds:
          type: array
          description: Thresholds, ordered by value with the recurring threshold last.
          items:
            $ref: '#/components/schemas/AlertThresholdObject'
        previous_value:
          type: string
          description: Last monitored value, in cents for usage_amount or product units for usage_units, sent as a decimal string.
          example: '12.5'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        last_processed_at:
          type:
            - string
            - 'null'
          description: Last evaluation timestamp, or null before evaluation.
          example: null
          format: date-time
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
    ContractAlertsPaginated:
      type: object
      description: ContractAlertsPaginated response.
      required:
        - alerts
        - meta
      properties:
        alerts:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractAlertObject'
        meta:
          $ref: '#/components/schemas/CursorPaginationMeta'
    ContractAlertScopeInput:
      type: object
      description: Scope of a contract alert. Omit product_filter_codes to select the product default, optionally including all its filters.
      required:
        - type
        - product_code
      properties:
        type:
          type: string
          description: Scope type.
          example: contract
          enum:
            - contract
        product_code:
          type: string
          description: Metered product code.
          example: api_requests
        product_filter_codes:
          type:
            - array
            - 'null'
          description: One product filter code. Cannot be combined with with_product_filters.
          items:
            type: string
            description: Product filter code.
            example: eu
          minItems: 1
          maxItems: 1
        with_product_filters:
          type:
            - boolean
            - 'null'
          description: Includes all filter rate cards of the selected product. Cannot be combined with product_filter_codes.
          example: false
          default: false
      additionalProperties: false
      allOf:
        - if:
            properties:
              product_filter_codes:
                type: array
                items:
                  type: string
                  description: Product filter code.
                  example: eu
            required:
              - product_filter_codes
          then:
            not:
              required:
                - with_product_filters
    AlertThresholdInput:
      type: object
      description: Alert threshold configuration.
      required:
        - value
      properties:
        code:
          type:
            - string
            - 'null'
          description: Threshold code. Required and unique when resolved notifications are enabled.
          example: warning
        value:
          type:
            - number
            - string
          description: Threshold value, as a number or a decimal string. A recurring threshold requires a positive value.
          example: '100.0'
          pattern: ^-?[0-9]+(\.[0-9]+)?$
        recurring:
          type: boolean
          description: Whether this value is a recurring interval. At most one recurring threshold is allowed.
          example: false
          default: false
        notify_on:
          type: array
          description: Notification events. Must include triggered. Resolved is supported only for a non-recurring threshold with a code.
          items:
            type: string
            description: Notification event.
            example: triggered
            enum:
              - triggered
              - resolved
          default:
            - triggered
    ContractAlertCreateInput:
      type: object
      description: Request payload.
      required:
        - alert
      properties:
        alert:
          type: object
          description: Resource attributes.
          required:
            - code
            - alert_type
            - scope
            - thresholds
          properties:
            code:
              type: string
              description: Unique alert code for the external contract identifier.
              example: usage_warning
            name:
              type:
                - string
                - 'null'
              description: Alert name.
              example: Usage warning
            alert_type:
              type: string
              description: Metric to monitor. usage_units requires a metered product scope.
              example: usage_amount
              enum:
                - usage_amount
                - usage_units
            scope:
              type: array
              description: Alert scope. An empty array monitors all metered products for usage_amount; usage_units requires one product scope.
              items:
                $ref: '#/components/schemas/ContractAlertScopeInput'
              maxItems: 1
            thresholds:
              type: array
              description: Complete threshold list, in cents for usage_amount or product units for usage_units. At most one recurring threshold is allowed.
              items:
                $ref: '#/components/schemas/AlertThresholdInput'
              minItems: 1
              maxItems: 20
    ContractAlert:
      type: object
      description: ContractAlert response.
      required:
        - alert
      properties:
        alert:
          $ref: '#/components/schemas/ContractAlertObject'
    ContractAlertUpdateInput:
      type: object
      description: Request payload.
      required:
        - alert
      properties:
        alert:
          type: object
          description: Resource attributes.
          properties:
            name:
              type:
                - string
                - 'null'
              description: Alert name.
              example: Usage warning
            thresholds:
              type:
                - array
                - 'null'
              description: Complete threshold list. Omitted or null preserves existing thresholds; an empty list is rejected.
              items:
                $ref: '#/components/schemas/AlertThresholdInput'
              minItems: 1
              maxItems: 20
          minProperties: 1
    PlanEntitlementValueObject:
      type: object
      description: Value of a plan entitlement privilege.
      required:
        - privilege_code
        - value
      properties:
        privilege_code:
          type: string
          description: Privilege code.
          example: seats
        value:
          type:
            - string
            - integer
            - boolean
            - 'null'
          description: Value cast to the privilege type.
          example: 10
    PlanEntitlementObject:
      type: object
      description: Feature entitlement attached to a catalog plan.
      required:
        - lago_id
        - plan_code
        - feature_code
        - values
        - created_at
        - updated_at
        - deleted_at
      properties:
        lago_id:
          type: string
          description: Unique identifier created by Lago.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        plan_code:
          type:
            - string
            - 'null'
          description: Catalog plan code.
          example: standard
        feature_code:
          type: string
          description: Feature code.
          example: analytics
        values:
          type: array
          description: Privilege values of this entitlement.
          items:
            $ref: '#/components/schemas/PlanEntitlementValueObject'
        created_at:
          type: string
          description: UTC creation timestamp, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        updated_at:
          type: string
          description: UTC timestamp of the last update, with microsecond precision.
          example: '2022-04-29T08:59:51.123456Z'
          format: date-time
        deleted_at:
          type:
            - string
            - 'null'
          description: UTC deletion timestamp, or null until deletion.
          example: null
          format: date-time
    PlanEntitlementsCollection:
      type: object
      description: PlanEntitlementsCollection response.
      required:
        - plan_entitlements
      properties:
        plan_entitlements:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/PlanEntitlementObject'
    EntitlementsUpdateInput:
      type: object
      description: Feature codes mapped to privilege codes and values.
      required:
        - entitlements
      properties:
        entitlements:
          type: object
          description: Map of feature codes to maps of privilege codes and values. Empty feature maps grant a feature without adding values.
          additionalProperties:
            type: object
            description: Privilege codes and their values for this feature.
            additionalProperties:
              type:
                - string
                - integer
                - boolean
              description: Value matching the privilege type.
              example: 10
          example:
            analytics:
              seats: 10
    PlanEntitlement:
      type: object
      description: PlanEntitlement response.
      required:
        - plan_entitlement
      properties:
        plan_entitlement:
          $ref: '#/components/schemas/PlanEntitlementObject'
    ContractEntitlementValueObject:
      type: object
      description: Effective value of a contract entitlement privilege.
      required:
        - privilege_code
        - value
        - plan_value
        - source
      properties:
        privilege_code:
          type: string
          description: Privilege code.
          example: seats
        value:
          type:
            - string
            - integer
            - boolean
            - 'null'
          description: Value cast to the privilege type.
          example: 10
        plan_value:
          type:
            - string
            - integer
            - boolean
            - 'null'
          description: Value inherited from the plan, or null when the plan has no value.
          example: 10
        source:
          type: string
          description: Source of the effective value.
          example: plan
          enum:
            - plan
            - contract
    ContractEntitlementObject:
      type: object
      description: Effective feature entitlement of a contract.
      required:
        - lago_contract_id
        - feature_code
        - source
        - values
      properties:
        lago_contract_id:
          type: string
          description: Identifier of the contract.
          example: 1a901a90-1a90-1a90-1a90-1a901a901a90
          format: uuid
        feature_code:
          type: string
          description: Feature code.
          example: analytics
        source:
          type: string
          description: Source of the feature entitlement. Individual privilege values can have a different source.
          example: plan
          enum:
            - plan
            - contract
        values:
          type: array
          description: Effective privilege values, including plan values and contract overrides.
          items:
            $ref: '#/components/schemas/ContractEntitlementValueObject'
    ContractEntitlementsCollection:
      type: object
      description: ContractEntitlementsCollection response.
      required:
        - entitlements
      properties:
        entitlements:
          type: array
          description: Records in this response.
          items:
            $ref: '#/components/schemas/ContractEntitlementObject'
    ContractEntitlement:
      type: object
      description: ContractEntitlement response.
      required:
        - entitlement
      properties:
        entitlement:
          $ref: '#/components/schemas/ContractEntitlementObject'
  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: []
    UnprocessableEntity:
      description: Invalid fields or filters
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    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
    TooManyRequests:
      description: Payment provider rate limit exceeded
      headers:
        X-Lago-Endpoint-Status:
          $ref: '#/components/headers/EndpointStatus'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            code: too_many_provider_requests
            details:
              - code: too_many_provider_requests
                field: base
                meta:
                  provider_name: stripe
